docker: create distinct containers for blockchains

Create disctinct containers for Litecoin and Bitcoin, and also change
the readme accordingly.
This commit is contained in:
Andrey Samokhvalov 2017-07-04 23:25:24 +03:00 committed by Olaoluwa Osuntokun
parent 816b9ada44
commit e60a370d46
3 changed files with 17 additions and 22 deletions

@ -63,18 +63,15 @@ bitcoin into.
# Init bitcoin network env variable: # Init bitcoin network env variable:
$ export NETWORK="simnet" $ export NETWORK="simnet"
# Run "btcd" node:
$ docker-compose up -d "btcd"
# Run the "Alice" container and log into it: # Run the "Alice" container and log into it:
$ docker-compose up -d "alice" $ docker-compose run -d --name alice lnd_btc
$ docker exec -i -t "alice" bash $ docker exec -i -t alice bash
# Generate a new backward compatible nested p2sh address for Alice: # Generate a new backward compatible nested p2sh address for Alice:
alice$ lncli newaddress np2wkh alice$ lncli newaddress np2wkh
# Recreate "btcd" node and set Alice's address as mining address: # Recreate "btcd" node and set Alice's address as mining address:
$ MINING_ADDRESS=<alice_address> docker-compose up -d "btcd" $ MINING_ADDRESS=<alice_address> docker-compose up -d btcd
# Generate 400 block (we need at least "100 >=" blocks because of coinbase # Generate 400 block (we need at least "100 >=" blocks because of coinbase
# block maturity and "300 ~=" in order to activate segwit): # block maturity and "300 ~=" in order to activate segwit):
@ -93,8 +90,8 @@ Connect `Bob` node to `Alice` node.
```bash ```bash
# Run "Bob" node and log into it: # Run "Bob" node and log into it:
$ docker-compose up --no-recreate -d "bob" $ docker-compose up --no-recreate -d --name bob lnd_btc
$ docker exec -i -t "bob" bash $ docker exec -i -t bob bash
# Get the identity pubkey of "Bob" node: # Get the identity pubkey of "Bob" node:
bob$ lncli getinfo bob$ lncli getinfo
@ -115,7 +112,7 @@ bob$ lncli getinfo
} }
# Get the IP address of "Bob" node: # Get the IP address of "Bob" node:
$ docker inspect "bob" | grep IPAddress $ docker inspect bob | grep IPAddress
# Connect "Alice" to the "Bob" node: # Connect "Alice" to the "Bob" node:
alice$ lncli connect <bob_pubkey>@<bob_host> alice$ lncli connect <bob_pubkey>@<bob_host>
@ -198,12 +195,11 @@ bob$ lncli addinvoice --value=10000
# Send payment from "Alice" to "Bob": # Send payment from "Alice" to "Bob":
alice$ lncli sendpayment --pay_req=<encoded_invoice> alice$ lncli sendpayment --pay_req=<encoded_invoice>
# Check "Alice"'s channel balance was decremented accordingly by the payment # Check "Alice"'s channel balance
# amount alice$ lncli channelbalance
alice$ lncli listchannels
# Check "Bob"'s channel balance was credited with the payment amount # Check "Bob"'s channel balance
bob$ lncli listchannels bob$ lncli channelbalance
``` ```
Now we have open channel in which we sent only one payment, let's imagine Now we have open channel in which we sent only one payment, let's imagine

@ -77,15 +77,15 @@ services:
- shared:/rpc - shared:/rpc
entrypoint: ["./start-lnd.sh"] entrypoint: ["./start-lnd.sh"]
alice: lnd_ltc:
extends: lnd extends: lnd
container_name: alice container_name: lnd_ltc
links: links:
- "btcd:blockchain" - "ltcd:blockchain"
bob: lnd_btc:
extends: lnd extends: lnd
container_name: bob container_name: lnd_btc
links: links:
- "btcd:blockchain" - "btcd:blockchain"

@ -14,7 +14,7 @@ EXPOSE 18555 18556
# Expose segnet ports (server, rpc) # Expose segnet ports (server, rpc)
EXPOSE 28901 28902 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. # related dependencies.
WORKDIR $GOPATH/src/github.com/ltcsuite/ltcd WORKDIR $GOPATH/src/github.com/ltcsuite/ltcd
RUN git clone https://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 mkdir "/rpc" "/root/.ltcd" "/root/.ltcctl"
RUN touch "/root/.ltcd/ltcd.conf" 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. # "ltcctl" and "lnd" to "ltcd" over docker links.
RUN "/go/bin/gencerts" --host="*" --directory="/rpc" --force RUN "/go/bin/gencerts" --host="*" --directory="/rpc" --force
# Create a volume to house pregenerated RPC credentials. This will be # 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. # server.
# You should NOT do this before certificate generation! # You should NOT do this before certificate generation!
# Otherwise manually generated certificate will be overriden with shared # Otherwise manually generated certificate will be overriden with shared