From 1efcea585979cb7deec292554260360c83fb516b Mon Sep 17 00:00:00 2001 From: Muhammad Abdullah Abid Date: Tue, 15 Feb 2022 16:29:07 -0800 Subject: add regtest fund docs --- README.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/README.md b/README.md index bcf979d1..3477e53d 100644 --- a/README.md +++ b/README.md @@ -131,3 +131,80 @@ The bitcoind and elementsd nodes can be a pruned if you want to limit the amount I've only tested with Maria. Here's a [schema](https://github.com/asoltys/coinos-server/blob/master/db/schema.sql) to get you started. cat db/schema.sql | mysql -u root -p + + +# Miscellaneous Commands + +## Funding the regtest with bitcoin + +--- +Bitcoin +--- + +generate some blocks + + docker exec -it bitcoin bitcoin-cli -datadir=config/ generatetoaddress 1 $(docker exec -it bitcoin bitcoin-cli -datadir=config/ getnewaddress "" "legacy") + +get balance + + docker exec -it bitcoin bitcoin-cli -datadir=config/ getbalance + +--- +Liquid +--- + +The Liquid network gives you a starting balance of Bitcoin specified in the `config/liquid/elements.conf` file as `initialfreecoins`. + +generate some blocks + + docker exec -it liquid elements-cli -datadir=/home/elements/.elements generatetoaddress 1 $(docker exec -it liquid elements-cli -datadir=/home/elements/.elements getnewaddress) + +get balance + + docker exec -it liquid elements-cli -datadir=/home/elements/.elements getbalance + +--- +Lightning +--- + +get node id of clighting node + + docker exec -it cl lightning-cli getinfo + +connect to clightning node + + docker exec -it lnd lncli --network=regtest --chain=bitcoin connect 029ba19ec5f65f82b1952fd535a86ff136ccc67ff7f91e19c3fcbc83a5224adaee@cl:9735 + +open a channel + + docker exec -it lnd lncli --network=regtest --chain=bitcoin openchannel 029ba19ec5f65f82b1952fd535a86ff136ccc67ff7f91e19c3fcbc83a5224adaee 10000000 + +generate 10 btc blocks + + docker exec -it bitcoin bitcoin-cli -datadir=config/ generatetoaddress 10 $(docker exec -it bitcoin bitcoin-cli -datadir=config/ getnewaddress "" "legacy") + +--- +Test clightning payment +--- + +payment request from clightning + + docker exec -it cl lightning-cli invoice 100000 "test payment" "test desc" + +get full payment request code from field bolt11 + + something like this + + lnbcrt1u1p3qhle9pp5mzn7aezr59tmlmp5mg9x2sa45j8fec5ygmwx6mg2x29qpnnw3j9qdq0w3jhxapqv3jhxccxqyjw5qcqp2sp54tuk3ns3gd66w50hflkzwks0d9z9eelsa8284283zhkug9kevzqq9qyyssqjsprhd38eywg6kp8w7gmwf48hnx0mpd28465v9f595xfrec0dg2jnqdumrmeh9srw32u5t9g6tdy6tdpu47emhkfnu72fnzevvwd0acqxmurkx + +Use this botl11 address and paste in the UI to check + +--- +Check if all three nodes are connected +--- + + curl https://attackme.coinos.io/api/info + + look for nodes array at the end + +--- \ No newline at end of file -- cgit v1.2.3 From b06441cefc3295b03c26eafaf42c5ec0d65430f6 Mon Sep 17 00:00:00 2001 From: Derrick Schwabe Date: Wed, 23 Feb 2022 18:04:06 -0700 Subject: Set sample 'wallet-unlock-password-file' path to match default path as in container so this line needs no edit after uncomment --- sampleconfig/lnd/lnd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sampleconfig/lnd/lnd.conf b/sampleconfig/lnd/lnd.conf index cba6807c..a979284a 100644 --- a/sampleconfig/lnd/lnd.conf +++ b/sampleconfig/lnd/lnd.conf @@ -9,7 +9,7 @@ accept-amp=1 accept-keysend=1 # uncomment this after lnd wallet is initialized -# wallet-unlock-password-file=/path/to/.lnd/pwd +# wallet-unlock-password-file=/root/.lnd/pwd [Bitcoin] bitcoin.active=1 -- cgit v1.2.3 From 38bdf581807686ec652373f98bc33666ae1f796b Mon Sep 17 00:00:00 2001 From: Derrick Schwabe Date: Sun, 27 Feb 2022 21:53:05 -0700 Subject: README updates and a re-ordering of steps/additional clarity produce a working dev deployment --- README.md | 87 +++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index bcf979d1..edee9d78 100644 --- a/README.md +++ b/README.md @@ -15,42 +15,76 @@ This repository contains the code for the backend API server which is implemente ### Getting Started - git clone https://github.com/coinos/coinos-server - cd coinos-server - cp -rf sampleconfig ./config - cp .env.sample .env - cp fx.sample fx - docker network create net - sudo base64 config/lnd/tls.cert | tr -d '\n' - sudo base64 config/lnd/data/chain/bitcoin/regtest/admin.macaroon | tr -d '\n' - docker run -it -v $(pwd):/app --entrypoint yarn asoltys/coinos-server - docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-orphans - docker exec -i mariadb mysql -u root -ppassword < db/schema.sql - docker exec -it liquid elements-cli -conf=/config/elements.conf sendtoaddress AzpsKhC6xE9FEK4aWAzMnbvueMLiSa5ym1xpuYogFkHzWgMHSt8B79aNNbFppQzCSQ2yZ9E4nL6RQJU7 1000000 - docker exec -it lnd lncli create - docker exec -it lnd lncli --network=regtest --chain=bitcoin unlock +```bash +git clone https://github.com/coinos/coinos-server +cd coinos-server +cp -rf sampleconfig ./config +cp .env.sample .env +cp fx.sample fx +docker network create net +docker run -it -v $(pwd):/app --entrypoint yarn asoltys/coinos-server +docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-orphans +docker exec -i mariadb mysql -u root -ppassword < db/schema.sql +docker exec -it liquid elements-cli -conf=/config/elements.conf sendtoaddress AzpsKhC6xE9FEK4aWAzMnbvueMLiSa5ym1xpuYogFkHzWgMHSt8B79aNNbFppQzCSQ2yZ9E4nL6RQJU7 1000000 +``` + +then run this and keep reference to the result for the forthcoming [Config changes] + +```bash +sudo base64 config/lnd/tls.cert | tr -d '\n' +``` +then run this and type a password when prompted, and then 'n' to create new wallet: + +```bash +docker exec -it lnd lncli create +``` +(optionally write down the seed as backup in case you lose the wallet and/or password) + +then uncomment line 12 of [config/lnd/lnd.conf] and update the [pwd file] with the new wallet password you just set. + +then run this and copy/paste the result to another blank file or note: +```bash +sudo base64 config/lnd/data/chain/bitcoin/regtest/admin.macaroon | tr -d '\n' +``` + +then run: +```bash +docker-compose down --remove-orphans +``` +and start it back up again with the same command from before: +```bash +docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-orphans +``` ### Config changes - navigate to config/index.js. - for the lna dictionary, update the values for cert and macaroon. These values can be found in the macaroon and cert files created in the previous section in the root folder of the coinos project. -### Wallet not found issues - If your app logs complain that the wallet was not found, do the following: - docker-compose exec bitcoin bash - bitcoin-cli -datadir=config/ createwallet coinos - exit - docker exec -it lnd lncli --network=regtest --chain=bitcoin unlock +Navigate to `./config/index.js` +Under `lna`, update the values for `cert` and `macaroon` with the output from the respective commands you ran in the section above. +### Wallet not found issues +If your app logs complain that the wallet was not found, do the following: +```bash +docker-compose exec bitcoin bash +bitcoin-cli -datadir=config/ createwallet coinos +exit +docker exec -it lnd lncli --network=regtest --chain=bitcoin unlock +``` +### Spinning down coinos & services +from the root of this repo, run: +```bash +docker-compose down --remove-orphans +``` +--- -Note the last step will take some time on first run as it will download the aforementioned docker images. +Note the initial `docker-compose up` step will take some time on first run as it will download all of the necessary 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. +To shutdown coinos and all of its containers/services, run `docker-compose down --remove-orphans` 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. Or run `purge-except-git.sh` from `./scripts` @@ -131,3 +165,8 @@ The bitcoind and elementsd nodes can be a pruned if you want to limit the amount I've only tested with Maria. Here's a [schema](https://github.com/asoltys/coinos-server/blob/master/db/schema.sql) to get you started. cat db/schema.sql | mysql -u root -p + + +[Config changes]:(#config-changes) +[config/lnd/lnd.conf]:./config/lnd/lnd.conf +[pwd file]:./config/lnd/pwd \ No newline at end of file -- cgit v1.2.3 From 404399ba0c2778a2c5514067cda4ae03a7ad2e2a Mon Sep 17 00:00:00 2001 From: Derrick Schwabe Date: Mon, 28 Feb 2022 18:06:17 -0700 Subject: Additional README tweaks --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index edee9d78..48a05a36 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ docker exec -it lnd lncli create then uncomment line 12 of [config/lnd/lnd.conf] and update the [pwd file] with the new wallet password you just set. -then run this and copy/paste the result to another blank file or note: +then run this and keep reference to the result again: ```bash sudo base64 config/lnd/data/chain/bitcoin/regtest/admin.macaroon | tr -d '\n' ``` @@ -56,6 +56,8 @@ and start it back up again with the same command from before: docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-orphans ``` +For reviewing output, you may run `docker-compose logs` or run the docker-compose up command above but without the `-d `flag + ### Config changes Navigate to `./config/index.js` @@ -168,5 +170,5 @@ I've only tested with Maria. Here's a [schema [Config changes]:(#config-changes) -[config/lnd/lnd.conf]:./config/lnd/lnd.conf -[pwd file]:./config/lnd/pwd \ No newline at end of file +[config/lnd/lnd.conf]:./sampleconfig/lnd/lnd.conf +[pwd file]:./sampleconfig/lnd/pwd \ No newline at end of file -- cgit v1.2.3 From a3da435414900aed7b7078c1c0665859c10e3247 Mon Sep 17 00:00:00 2001 From: Derrick Schwabe Date: Mon, 28 Feb 2022 18:26:11 -0700 Subject: --remove-orphans not needed on spinup if you spin down with docker-compose down --remove-orphans --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48a05a36..918e754c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ cp .env.sample .env cp fx.sample fx docker network create net docker run -it -v $(pwd):/app --entrypoint yarn asoltys/coinos-server -docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-orphans +docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d docker exec -i mariadb mysql -u root -ppassword < db/schema.sql docker exec -it liquid elements-cli -conf=/config/elements.conf sendtoaddress AzpsKhC6xE9FEK4aWAzMnbvueMLiSa5ym1xpuYogFkHzWgMHSt8B79aNNbFppQzCSQ2yZ9E4nL6RQJU7 1000000 ``` -- cgit v1.2.3 From 2a0fd1893dda74a98ed8210487563792adadbb84 Mon Sep 17 00:00:00 2001 From: Derrick Schwabe Date: Mon, 28 Feb 2022 22:21:25 -0700 Subject: Formatting tweaks for consistency with other sections --- README.md | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a2053fdc..391222af 100644 --- a/README.md +++ b/README.md @@ -168,14 +168,12 @@ I've only tested with Maria. Here's a [schema cat db/schema.sql | mysql -u root -p +--- +### Miscellaneous Commands -# Miscellaneous Commands +#### Funding the regtest chain -## Funding the regtest with bitcoin - ---- -Bitcoin ---- +##### Bitcoin generate some blocks @@ -186,8 +184,7 @@ get balance docker exec -it bitcoin bitcoin-cli -datadir=config/ getbalance --- -Liquid ---- +##### Liquid The Liquid network gives you a starting balance of Bitcoin specified in the `config/liquid/elements.conf` file as `initialfreecoins`. @@ -200,8 +197,7 @@ get balance docker exec -it liquid elements-cli -datadir=/home/elements/.elements getbalance --- -Lightning ---- +##### Lightning get node id of clighting node @@ -220,8 +216,7 @@ generate 10 btc blocks docker exec -it bitcoin bitcoin-cli -datadir=config/ generatetoaddress 10 $(docker exec -it bitcoin bitcoin-cli -datadir=config/ getnewaddress "" "legacy") --- -Test clightning payment ---- +#### Test clightning payment payment request from clightning @@ -236,14 +231,13 @@ get full payment request code from field bolt11 Use this botl11 address and paste in the UI to check --- -Check if all three nodes are connected ---- +#### Check if all three nodes are connected curl https://attackme.coinos.io/api/info look for nodes array at the end ---- + [Config changes]:(#config-changes) [config/lnd/lnd.conf]:./sampleconfig/lnd/lnd.conf [pwd file]:./sampleconfig/lnd/pwd -- cgit v1.2.3