diff options
| -rw-r--r-- | README.md | 98 | ||||
| -rw-r--r-- | doc/fund-server-bitcoin-cli.md | 66 | ||||
| -rw-r--r-- | doc/img/50-bitcoin-server-balance.gif | bin | 0 -> 7791 bytes | |||
| -rw-r--r-- | package.json | 2 | ||||
| -rw-r--r-- | routes/bitcoin/receive.js | 2 | ||||
| -rw-r--r-- | routes/liquid/receive.js | 2 |
6 files changed, 162 insertions, 8 deletions
@@ -2,9 +2,95 @@ Coinos is a bitcoin wallet app that supports payments over the <a href="https://bitcoin.org">bitcoin</a>, <a href="https://blockstream.com/liquid/">liquid</a> and <a href="http://lightning.network/">lightning</a> networks. Try it out at <a href="https://coinos.io/">coinos.io</a>. -This repository contains the code for the backend API server which is implemented as a NodeJS application. The code for the frontend UI is tracked separately <a href="https://github.com/asoltys/coinos.io">here</a>. +This repository contains the code for the backend API server which is implemented as a NodeJS application. The code for the frontend UI is tracked separately <a href="https://github.com/asoltys/coinos.io">here</a> (but is automatically installed & started via the Docker way outlined below). -## Requirements +## Install/Run (the Docker way) + +### Requirements + +* <a href="https://docs.docker.com/get-docker/ +">docker</a> and <a href="https://docs.docker.com/compose/install/">docker-compose</a> +* NodeJS (recommended version: 16) +* ~7GB of hard drive space (which will go into /var/lib/docker; primarily for Liquid) + +### Getting Started + git clone [email protected]:coinos/coinos-server.git + git clone [email protected]:coinos/coinos-ui.git + cd coinos-ui + yarn + cd ../coinos-server + yarn + cp -rf sampleconfig ./config + cp .env.sample .env + cp fx.sample fx + mkdir mysql + cp db/schema.sql mysql/ + docker-compose up -d --force-recreate maria + docker exec -i mariadb mysql -u root -ppassword < mysql/schema.sql + docker-compose down + docker-compose up + +Note the last step will take some time on first run as it will download the aforementioned docker images. + +After successful creation of all docker containers coinos will be available at http://localhost:8085 + +To shutdown coinos and all of its containers/services, run `docker-compose down` again. + +At anypoint to purge the database and start with a new one run `rm -rf mysql` and then `mkdir mysql` and then the same steps following from that point as outlined above. + +To review a log of individual containers use `docker-compose app` or `docker-compose maria` etc; container names are available in `docker-compose.yml` or via `docker-compose ps` when they are running. `docker images` will show you a list of the images installed on your system and `docker image rm [IMAGE ID]` removes them. + +#### Volumes and local filesystem changes + +The `docker-compose.yml` specifies volumes that map to the host (ie- your local machine). As per Docker's <a href="https://docs.docker.com/storage/volumes/">volume feature</a> these override what is in the container's 'virtual' filesystem for those folders and instead will map to what is on your local filesystem. As such, changes/developments that occur in these locations will be reflected without needing to restart the containers. + +Additionally <a href="https://github.com/remy/nodemon">Nodemon</a> is setup by default to watch coinos-server directory and will auto-restart the app as changes occur. + +Alternative to allowing nodemon to manage the app, you may enter bash on the docker to start/stop the node app manually ie: + + docker exec -it app bash + node index.js + # ^ starts app manually in a bash session inside the docker + # ( reflecting your local coinos-server directory) + + +To prevent nodemon from starting with the container change the `package.json` `"start"` script value to: `"tail -f /dev/null"` which will then keep the container alive so you may enter an interactive bash as above to start the app manually. + +#### Debugging + +To debug the node app while it is running via Docker, edit `docker-compose.yml` to add `9229` to the ports section for the `app` service: + + ports: + - '3119:3119' + - '9229' + +then get the IP of the app container: + + docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' app + > 192.168.115.72 #outputs the coinos app container IP + +then edit `package.json` start script to: + + "start" : "nodemon --inspect=0.0.0.0 index.js", + +(or use the interactive bash technique above with this same inspect flag) + +restart with `docker-compose restart app` + +then open your browser (Chrome in this example) to the URL`chrome://inspect` then click "Configure" and add the IP address + debugger port to the list of targets ex- `192.168.115.72:92229` + +an inspect link will then display under 'Remote Target'! + + Note the IP address may change between restarts so you may have to rerun the docker inspect command above again to make sure you have the correct IP on following sessions. + +---- + +### Install/Run (without Docker) + +Note the Docker way outlined above is recommended as manual setup requirements/instructions shown below are out of date. + + +#### Requirements * <a href="https://github.com/bitcoin/bitcoin">bitcoind</a> with zmq support * <a href="https://github.com/ElementsProject/elements">elementsd</a> with zmq support @@ -15,18 +101,20 @@ The bitcoind and elementsd nodes can be a pruned if you want to limit the amount The reason for running two lightning nodes is so that one can create invoices while the other sends payments when two coinos users want to pay each other. -## Getting Started +#### Getting Started - git clone https://github.com/asoltys/coinos-server + git clone [email protected]:coinos/coinos-server.git cd coinos-server cp -R ./sampleconfigs ./config <-- edit knexfile.js with DB connection info --> + cp .env.sample .env yarn yarn min ... (or npm run min) <-- This runs the minimal version (Precludes valid connections with bitcoin / liquid / lightning networks) --> (To run full system with 3rd party networks above, edit applicable key values in config/index.js file) -## Database Setup + +#### Database Setup I've only tested with <a href="https://mariadb.org/">Maria</a>. Here's a [schema](https://github.com/asoltys/coinos-server/blob/master/db/schema.sql) to get you started. diff --git a/doc/fund-server-bitcoin-cli.md b/doc/fund-server-bitcoin-cli.md new file mode 100644 index 00000000..29c4bec0 --- /dev/null +++ b/doc/fund-server-bitcoin-cli.md @@ -0,0 +1,66 @@ +## Fund Coinos server (via bitcoin-cli) + +Bitcoin Regtest Mode allows us to create our own Bitcoin sandbox blockchain for use in testing & development. + +In this demo/tutorial we will setup a regtest network along with wallet and some initial bitcoin. + +From the coinos-server dir on your local filesystem (ie- after following the 'Getting Started' section of our [root README]) + +```bash + +docker exec -it bitcoin bash + +# get an address +bitcoin-cli -regtest -datadir=/config -rpcwallet=coinosdev getnewaddress + +# mine a block to the new address +bitcoin-cli -regtest -datadir=/config generatetoaddress 101 theaddressgneratedabove + +# verify you got the reward: +bitcoin-cli -regtest -datadir=/config -conf=./bitcoin.conf -rpcwallet=coinosdev getbalance +> 50.00000000 +``` + + + + +#### Start from scratch + +To purge any existing transactions you made and to recreate all wallets including the coinos wallet (coinosdev) do (assuming coinos-server is running): + +```bash +docker-compose down +sudo rm -rf config/bitcoin +sudo rm -rf config/lightning +sudo rm -rf config/liquid +cp -rf sampleconfig/bitcoin config +cp -rf sampleconfig/lightning config +cp -rf sampleconfig/liquid config +docker-compose up +# app may crash during re-initalization of blockchains so +# restart it again after a few moments if necessary: +docker-compose restart app +``` + + +#### Creating new (Bitcoin native) wallets + +Note the wallet 'coinosdev' is created apart of the initial docker build for our Coinos Bitcoin server. +To create a new wallet (ie- as an alternate or one for yourself) do: + +```bash +bitcoin-cli -regtest -datadir=/config -conf=./bitcoin.conf createwallet me +> # new wallet created in /config/regtest/wallets +``` +and then specify `-rpcwallet=me` (or wallet name of your choice) + + +#### further reading + +On why to generate 101 blocks and some general info on Regtest Mode: + +https://developer.bitcoin.org/examples/testing.html + + +[root README]:https://github.com/coinos/coinos-server + diff --git a/doc/img/50-bitcoin-server-balance.gif b/doc/img/50-bitcoin-server-balance.gif Binary files differnew file mode 100644 index 00000000..2fba5088 --- /dev/null +++ b/doc/img/50-bitcoin-server-balance.gif diff --git a/package.json b/package.json index 352f7bc1..5b72a2b1 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "web-push": "^3.4.4", "wretch": "^1.7.4", "ws": "^7.1.2", - "zeromq": "^5.1.0" + "zeromq": "^6.0.0-beta.6" }, "devDependencies": { "prettier": "^1.18.2" diff --git a/routes/bitcoin/receive.js b/routes/bitcoin/receive.js index dbc5801b..d782627d 100644 --- a/routes/bitcoin/receive.js +++ b/routes/bitcoin/receive.js @@ -1,5 +1,5 @@ const reverse = require("buffer-reverse"); -const zmq = require("zeromq"); +const zmq = require("zeromq/v5-compat"); const { Op } = require("sequelize"); const { fromBase58 } = require("bip32"); diff --git a/routes/liquid/receive.js b/routes/liquid/receive.js index 99bcae2f..c377a6b5 100644 --- a/routes/liquid/receive.js +++ b/routes/liquid/receive.js @@ -1,6 +1,6 @@ const axios = require("axios"); const reverse = require("buffer-reverse"); -const zmq = require("zeromq"); +const zmq = require("zeromq/v5-compat"); const { Op } = require("sequelize"); const { fromBase58 } = require("bip32"); const bitcoin = require("bitcoinjs-lib"); |
