You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Go to file
moneroexamples 7c20bdc8de
command line options added to readme
7 years ago
config new option added to config.js 7 years ago
ext sql database file updated 8 years ago
html versioning added to front end and screenshot updated 7 years ago
screenshot versioning added to front end and screenshot updated 7 years ago
sql total_received removed from Accounts table 7 years ago
src command line options added to readme 7 years ago
.gitignore gitignore updated 8 years ago
CMakeLists.txt versioning added to CMakeLists.txt 7 years ago
README.md command line options added to readme 7 years ago
main.cpp ubuntu setup instructions started 7 years ago

README.md

JSON REST service for Monero

Example of using restbed to provide Monero related JSON REST service. For this purpose, a service called Open Monero was developed.

Open Monero

Open Monero is an open source implementation of backend of https://mymonero.com/. The frontend, which includes HTML, CSS, JavaScript were adapted from (and originally developed by) https://mymonero.com/.

Unlike MyMonero, Open Monero's backend is open sourced, free to use, host and modify. Additionally, the following features were added/changed:

  • google analytics, cloudflare, images and flash were removed.
  • transaction fees were set to zero (MyMonero also has now them zero due to problem with its RingCT).
  • the wallets generated use 25 word mnemonics, fully compatible with official monero wallets (13 word mnemonics generated by MyMonero work as usual though).
  • import wallet fee was reduced.
  • added support of testnet network and mainnet network without relying transactions
  • improved handling of mempool, coinbase, locked and unlocked transactions.
  • added dynamic fees for testnet.
  • minimum mixin set to 4.

Screenshot

Open Monero

Limitations

Performance

Open Monero is not as fast as MyMonero. This is because it is basic, easy to understand and straight forward implementation of the backend. Thus, it does not use any catching of transactions, blocks, complex database structures and SQL queries. Also, no ongoing monitoring of user's transactions is happening, since viewkey is not stored. Transaction search threads start when user logs in (viewkey and address are submitted to the search thread), and finish shorty after logout. Once the search thread stops, they can't be restarted without user logging in back, as Open Monero does not store viewkeys.

Host it yourself

The Open Monero consists of four components that need to be setup for it to work:

  • MySql/Mariadb database - it stores user address (viewkey is not stored!), associated transactions, outputs, inputs and transaction import payments information.
  • Frontend - it is virtually same as that of MyMonero, except before mentioned differences. It consists of HTML, CSS, and JavaScript.
  • Monero daemon - daemon must be running and fully sync, as this is where all transaction data is fetched from and used. Daemon also commits txs from the Open Monero into the Monero network.
  • Backend - fully written in C++. It uses restbed to serve JSON REST to the frontend and mysql++ to interface the database. It also accesses Monero blockchain and "talks" with Monero deamon.

Example setup on Ubuntu 16.04

Below are example and basic instructions on how to setup up and run Open Monero on Ubuntu 16.04.

Monero libraries

Monero's libraries and header files are setup is described here:

Compilation of the Open Monero (don't run it yet)

Download Open Monero and compile it. In fact we could postpone compilation to later, but we can just do it now, to see if it compiles. But don't run it yet. It will not work without database, setup frontend, and synced and running monero blockchain.

# need mysql++ libraries 
sudo apt install libmysql++-dev 

git clone https://github.com/moneroexamples/restbed-xmr.git

cd restbed-xmr

mkdir build && cd build

cmake ..

make

Mysql/Mariadb

sudo apt install mysql-server
sudo mysql_secure_installation

Download openmonero.sql provided and setup the openmonero database. openmonero.sql script will drop current openmonero if exist. So don't run it, if you have already some important information in the openmonero database.

Assuming we are still in build folder:

# apply it to mysql
mysql -p -u root < ../sql/openmonero.sql

Lighttpd and frontend

sudo apt-get install lighttpd

Assuming you are still in build folder, copy frontend source files into lighttpd www folder.

sudo mkdir /var/www/html/openmonero
sudo cp -rvf ../html/* /var/www/html/openmonero/

Setup document root in lighttpd.conf into openmonero folder

sudo vim /etc/lighttpd/lighttpd.conf

and change server.document-root into:

server.document-root    = "/var/www/html/openmonero"

Restart lighttpd to see the change:

sudo systemctl restart lighttpd

Go to localhost (http://127.0.0.1) and check if frontend is working.

Run Open Monero

Command line options

./openmonero -h

  -h [ --help ] [=arg(=1)] (=0)         produce help message
  -t [ --testnet ] [=arg(=1)] (=0)      use testnet blockchain
  --do-not-relay [=arg(=1)] (=0)        does not relay txs to other nodes. 
                                        useful when testing construction and 
                                        submiting txs
  --use-ssl [=arg(=1)] (=0)             whether to use ssl (i.e., https) or 
                                        not.
  -p [ --port ] arg (=1984)             default port for restbed service of 
                                        Open Monero
  -b [ --bc-path ] arg                  path to lmdb blockchain
  -d [ --deamon-url ] arg (=http:://127.0.0.1:18081)
                                        monero address string
  -u [ --frontend-url ] arg (=http://127.0.0.1:81)
                                        URl of the Open Monero frotnend.
  -c [ --config-file ] arg (=./config/config.json)
                                        Config file path.

Scrap notes

Generate your own ssl certificate

Setting up https and ssl certificates in restbed

Based on the link above:

# Create Certificate
cd /tmp
openssl genrsa -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
openssl dhparam -out dh2048.pem 2048

Enable it in Firefox or Chrome

Firefox and chrome will not work with that certificate as they cant verify it. To overcome this for development purposes on localhost, just open new tab in the browser used and go to any link from the service, e.g., https://localhost:1984/login. Once you do this, you should get warring about unsecured or un verified certificate. Then you just add it manually as exception.

Also Open Monero generates uses 25 word seeds, which are fully comptabilite with monero-wallet-cli and monero-core.

Test connection using curl

Example of curl https request to the service

curl -k -X POST -d '{"withCredentials":true,"address":"41pJD13rU5r3KZsxzS65tL9zLMpZZCer8aWSi7wj8Xm99BAgXthcj2wgazxdTX9auFAmp3czfJUGH2S3UJfLwDWXUxc3ooC","view_key":"06d1f0f0fd766c75b52b9c597592d06f4bca5cd6dcd3e9bf1859bc78d0d5f80e","create_account":true}' https://localhost:1984/login

Other examples

Other examples can be found on github. Please know that some of the examples/repositories are not finished and may not work as intended.

How can you help?

Constructive criticism, code and website edits are always good. They can be made through github.