From e60a370d46bb185a5b743e047e0af83b41b1a6ad Mon Sep 17 00:00:00 2001 From: Andrey Samokhvalov Date: Tue, 4 Jul 2017 23:25:24 +0300 Subject: [PATCH] docker: create distinct containers for blockchains Create disctinct containers for Litecoin and Bitcoin, and also change the readme accordingly. --- docker/README.md | 24 ++++++++++-------------- docker/docker-compose.yml | 10 +++++----- docker/ltcd/Dockerfile | 5 ++--- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/docker/README.md b/docker/README.md index 5f72d2ec..a91da799 100644 --- a/docker/README.md +++ b/docker/README.md @@ -63,18 +63,15 @@ bitcoin into. # Init bitcoin network env variable: $ export NETWORK="simnet" -# Run "btcd" node: -$ docker-compose up -d "btcd" - # Run the "Alice" container and log into it: -$ docker-compose up -d "alice" -$ docker exec -i -t "alice" bash +$ docker-compose run -d --name alice lnd_btc +$ docker exec -i -t alice bash # Generate a new backward compatible nested p2sh address for Alice: alice$ lncli newaddress np2wkh # Recreate "btcd" node and set Alice's address as mining address: -$ MINING_ADDRESS= docker-compose up -d "btcd" +$ MINING_ADDRESS= docker-compose up -d btcd # Generate 400 block (we need at least "100 >=" blocks because of coinbase # block maturity and "300 ~=" in order to activate segwit): @@ -93,8 +90,8 @@ Connect `Bob` node to `Alice` node. ```bash # Run "Bob" node and log into it: -$ docker-compose up --no-recreate -d "bob" -$ docker exec -i -t "bob" bash +$ docker-compose up --no-recreate -d --name bob lnd_btc +$ docker exec -i -t bob bash # Get the identity pubkey of "Bob" node: bob$ lncli getinfo @@ -115,7 +112,7 @@ bob$ lncli getinfo } # Get the IP address of "Bob" node: -$ docker inspect "bob" | grep IPAddress +$ docker inspect bob | grep IPAddress # Connect "Alice" to the "Bob" node: alice$ lncli connect @ @@ -198,12 +195,11 @@ bob$ lncli addinvoice --value=10000 # Send payment from "Alice" to "Bob": alice$ lncli sendpayment --pay_req= -# Check "Alice"'s channel balance was decremented accordingly by the payment -# amount -alice$ lncli listchannels +# Check "Alice"'s channel balance +alice$ lncli channelbalance -# Check "Bob"'s channel balance was credited with the payment amount -bob$ lncli listchannels +# Check "Bob"'s channel balance +bob$ lncli channelbalance ``` Now we have open channel in which we sent only one payment, let's imagine diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 00ca1d06..5c9fbd6b 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -77,15 +77,15 @@ services: - shared:/rpc entrypoint: ["./start-lnd.sh"] - alice: + lnd_ltc: extends: lnd - container_name: alice + container_name: lnd_ltc links: - - "btcd:blockchain" + - "ltcd:blockchain" - bob: + lnd_btc: extends: lnd - container_name: bob + container_name: lnd_btc links: - "btcd:blockchain" diff --git a/docker/ltcd/Dockerfile b/docker/ltcd/Dockerfile index 16c0a7ce..c79d27cd 100644 --- a/docker/ltcd/Dockerfile +++ b/docker/ltcd/Dockerfile @@ -14,7 +14,7 @@ EXPOSE 18555 18556 # Expose segnet ports (server, rpc) EXPOSE 28901 28902 -# Grab and install the latest version of roasbeef's fork of btcd and all +# Grab and install the latest version of roasbeef's fork of ltcd and all # related dependencies. WORKDIR $GOPATH/src/github.com/ltcsuite/ltcd RUN git clone https://github.com/ltcsuite/ltcd ./ @@ -25,12 +25,11 @@ RUN go install . ./cmd/ltcctl ./cmd/gencerts RUN mkdir "/rpc" "/root/.ltcd" "/root/.ltcctl" RUN touch "/root/.ltcd/ltcd.conf" -# Manually generate certificate and add all domains, it is needed to connect # "ltcctl" and "lnd" to "ltcd" over docker links. RUN "/go/bin/gencerts" --host="*" --directory="/rpc" --force # Create a volume to house pregenerated RPC credentials. This will be -# shared with any lnd, btcctl containers so they can securely query btcd's RPC +# shared with any lnd, btcctl containers so they can securely query ltcd's RPC # server. # You should NOT do this before certificate generation! # Otherwise manually generated certificate will be overriden with shared