From c213590a1d086ab186c16f0a50fe58354fc40c43 Mon Sep 17 00:00:00 2001 From: evan Date: Fri, 10 Jul 2020 13:39:37 -0400 Subject: [PATCH 1/4] run jq on docker instance using bash -c args --- code/docker/setup-channels.sh | 10 +++++----- node_client.asciidoc | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/docker/setup-channels.sh b/code/docker/setup-channels.sh index 36a0405465fc7..a26bc85ce8684 100644 --- a/code/docker/setup-channels.sh +++ b/code/docker/setup-channels.sh @@ -1,10 +1,10 @@ #!/bin/bash echo Getting node IDs -alice_address=$(docker-compose exec -T Alice lncli -n regtest getinfo | jq .identity_pubkey) -bob_address=$(docker-compose exec -T Bob lightning-cli getinfo | jq .id) -wei_address=$(docker-compose exec -T Wei eclair-cli -s -j -p eclair getinfo| jq .nodeId) -gloria_address=$(docker-compose exec -T Gloria lncli -n regtest getinfo | jq .identity_pubkey) +alice_address=$(docker-compose exec -T Alice bash -c "lncli -n regtest getinfo | jq .identity_pubkey") +bob_address=$(docker-compose exec -T Bob bash -c "lightning-cli getinfo | jq .id") +wei_address=$(docker-compose exec -T Wei bash -c "eclair-cli -s -j -p eclair getinfo| jq .nodeId") +gloria_address=$(docker-compose exec -T Gloria bash -c "lncli -n regtest getinfo | jq .identity_pubkey") # The jq command returns JSON strings enclosed in double-quote characters # These will confuse the shell later, because double-quotes have special @@ -40,7 +40,7 @@ docker-compose exec -T Wei eclair-cli -p eclair connect --uri=${gloria_address}@ docker-compose exec -T Wei eclair-cli -p eclair open --nodeId=${gloria_address} --fundingSatoshis=1000000 echo Get 10k sats invoice from Gloria -gloria_invoice=$(docker-compose exec -T Gloria lncli -n regtest addinvoice 10000 | jq .payment_request ) +gloria_invoice=$(docker-compose exec -T Gloria bash -c "lncli -n regtest addinvoice 10000 | jq .payment_request") # Remove quotes gloria_invoice=${gloria_invoice//\"} diff --git a/node_client.asciidoc b/node_client.asciidoc index 9fc425806f185..f596f617f118b 100644 --- a/node_client.asciidoc +++ b/node_client.asciidoc @@ -295,7 +295,7 @@ As you can see, we need to tell +bitcoin-cli+ where the bitcoind data directory All the docker containers also have +jq+ installed, which is a command-line JSON encoder/decoder, to help us process JSON on the command-line or from inside scripts. You can send the JSON output of any command to +jq+ using the +|+ character ("pipe" notation). For example, if we pipe the +getblockchaininfo+ JSON result we got above, we can extract the specific field +blocks+ like this: ---- -$ docker exec bitcoind bitcoin-cli -datadir=/bitcoind getblockchaininfo | jq .blocks +$ docker exec bitcoind bash -c "bitcoin-cli -datadir=/bitcoind getblockchaininfo | jq .blocks" 189 ---- From 4b6c3c34d1809c0ab897c40c31d28349c3c8b803 Mon Sep 17 00:00:00 2001 From: evan Date: Fri, 10 Jul 2020 13:40:07 -0400 Subject: [PATCH 2/4] add missing newline to fix broken apt-get command --- node_client.asciidoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node_client.asciidoc b/node_client.asciidoc index f596f617f118b..5d613ad23c073 100644 --- a/node_client.asciidoc +++ b/node_client.asciidoc @@ -447,7 +447,8 @@ Reading package lists... Done $ sudo apt-get install -y \ autoconf automake build-essential git libtool libgmp-dev \ - libsqlite3-dev python python3 python3-mako net-tools zlib1g-dev \ libsodium-dev gettext + libsqlite3-dev python python3 python3-mako net-tools zlib1g-dev \ + libsodium-dev gettext Reading package lists... Done Building dependency tree From 3a1103136a58e445eead92756de94f1fb18094fb Mon Sep 17 00:00:00 2001 From: evan Date: Fri, 10 Jul 2020 13:40:43 -0400 Subject: [PATCH 3/4] spelling and formatting fixes --- node_client.asciidoc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/node_client.asciidoc b/node_client.asciidoc index 5d613ad23c073..667a771a6263c 100644 --- a/node_client.asciidoc +++ b/node_client.asciidoc @@ -492,6 +492,7 @@ We now have a copy of c-lightning, cloned into the +lightning+ subfolder, and we ==== Compiling the c-lightning source code Next, we use a set of _build scripts_ that are commonly available on many open source projects. These are +configure+ and +make+, and they allow us to: + * Select the build options and check necessary dependencies (+configure+). * Build and install the executables and libraries (+make+). @@ -625,7 +626,7 @@ As before, we start the bitcoind container in one terminal and LND in another. I $ docker run -it --network lnbook --name bitcoind lnbook/bitcoind ---- -Next, we start the LND container we just build. We will need to attach it to the +lnbook+ network and give it a name, just as we did with the other containers: +Next, we start the LND container we just built. We will need to attach it to the +lnbook+ network and give it a name, just as we did with the other containers: ---- $ docker run -it --network lnbook --name lnd lnbook/lnd @@ -783,7 +784,7 @@ As before, we start the bitcoind container in one terminal and the eclair contai $ docker run -it --network lnbook --name bitcoind lnbook/bitcoind ---- -Next, we start the eclair container we just build. We will need to attach it to the +lnbook+ network and give it a name, just as we did with the other containers: +Next, we start the eclair container we just built. We will need to attach it to the +lnbook+ network and give it a name, just as we did with the other containers: ---- $ docker run -it --network lnbook --name eclair lnbook/eclair @@ -912,7 +913,7 @@ Congratulations, you have built Eclair from source and you are ready to code, te === Building a complete network of diverse Lightning Nodes -Our final example, in this section, will bring together all the various containers we have build to form a Lightning network made of diverse (LND, c-lightning, Eclair) node implementations. We will compose the network by connecting the nodes together, opening channels from one node to another, and finally, by routing a payment across these channels. +Our final example, in this section, will bring together all the various containers we have built to form a Lightning network made of diverse (LND, c-lightning, Eclair) node implementations. We will compose the network by connecting the nodes together, opening channels from one node to another, and finally, by routing a payment across these channels. In this example, we will replicate the Lighting network example from <>. Specifically, we will create four Lightning nodes named Alice, Bob, Wei and Gloria. We will connect Alice to Bob, Bob to Wei, and Wei to Gloria. Finally, we will have Gloria create an invoice and have Alice pay that invoice. Since Alice and Gloria are not directly connected, the payment will be routed as an HTLC across all the payment channels. @@ -1005,7 +1006,7 @@ $ docker-compose logs -f Alice Our Lightning network should now be running. As we saw in the previous sections of this chapter, we can issue commands to a running docker container with the +docker exec+ command. Regardless of whether we started the container with +docker run+ or started a bunch of them with +docker-compose up+, we can still access containers individually using the docker commands. -To make things easier, we have a little helper script that sets up the network, issues the invoice and makes the payment. The script is called +setup-channels.sh+ and is a Bash shell script. Keep in mind, this script is not very sophisticated! It "blindly" throws commands at the various nodes and doesn't do any error checking. If the network is running correct and the nodes are funded, then it all works nicely. But, you have to wait a bit for everything to boot up and for the network to mine a few blocks and settle down. This usually takes 1-3 minutes. Once you see the block height at 102 or above on each of the nodes, you are ready. If the script fails, you can stop everything (+docker-compose down+) and try again from the beginning, or you can manually issue the commands in the script one by one and look at the results. +To make things easier, we have a little helper script that sets up the network, issues the invoice and makes the payment. The script is called +setup-channels.sh+ and is a Bash shell script. Keep in mind, this script is not very sophisticated! It "blindly" throws commands at the various nodes and doesn't do any error checking. If the network is running correctly and the nodes are funded, then it all works nicely. But, you have to wait a bit for everything to boot up and for the network to mine a few blocks and settle down. This usually takes 1-3 minutes. Once you see the block height at 102 or above on each of the nodes, you are ready. If the script fails, you can stop everything (+docker-compose down+) and try again from the beginning, or you can manually issue the commands in the script one by one and look at the results. [TIP] ==== From 94a139592550e461c53eb82104ee388c606c0e32 Mon Sep 17 00:00:00 2001 From: evan Date: Fri, 10 Jul 2020 13:41:25 -0400 Subject: [PATCH 4/4] use correct mvn -v flag, not mvn -V --- node_client.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_client.asciidoc b/node_client.asciidoc index 667a771a6263c..7e761eae2532b 100644 --- a/node_client.asciidoc +++ b/node_client.asciidoc @@ -849,7 +849,7 @@ Check that you have the correct version installed and ready to use by running: ---- $ javac -version javac 11.0.7 -$ mvn -V +$ mvn -v Apache Maven 3.6.1 Maven home: /usr/share/maven Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64