Merge branch 'regtest' into 'main'
feat: multi chain support See merge request lightning-signer/vls-container!3
This commit is contained in:
commit
6290fbb8af
34
README.md
34
README.md
@ -13,6 +13,40 @@ docker volume create lightning_data
|
||||
docker compose up --build
|
||||
```
|
||||
|
||||
## Using Bitcoin Chains
|
||||
|
||||
We have three possible overrides over the default `testnet` configuration in `docker-compose.yml`:
|
||||
- `docker-compose.testnet.yml`
|
||||
- `docker-compose.regtest.yml`
|
||||
- `docker-compose.mainnet.yml`
|
||||
|
||||
To use override we have to pass it down both the config using `-f` flag:
|
||||
```
|
||||
docker compose -f docker-compose.yml -f <override_file> up --build
|
||||
```
|
||||
|
||||
__Note__: Even while using `testnet` running using the override is recommended as that will expose the `P2P` port for `bitcoind` and `P2P` port for `lightningd` on the host.
|
||||
|
||||
## Additional Regtest Commands
|
||||
|
||||
We have to run these commands after bitcoind is up and running.
|
||||
|
||||
Create Wallet:
|
||||
```
|
||||
docker container exec -it bitcoind bitcoin-cli createwallet default
|
||||
```
|
||||
|
||||
Generate Address for node:
|
||||
```
|
||||
docker container exec -it bitcoind bitcoin-cli getnewaddress
|
||||
```
|
||||
|
||||
Generate Blocks
|
||||
```
|
||||
docker container exec -it bitcoind bitcoin-cli generatetoaddress 50 $NODE_ADDRESS
|
||||
|
||||
```
|
||||
|
||||
### References
|
||||
|
||||
- [bitcoind](https://github.com/ruimarinho/docker-bitcoin-core/blob/master/23/alpine/Dockerfile) by @ruimarinho
|
||||
|
@ -2,15 +2,29 @@
|
||||
## bitcoin.conf configuration file. Lines beginning with # are comments.
|
||||
##
|
||||
|
||||
[test]
|
||||
server=1
|
||||
rpcallowip=0.0.0.0/0
|
||||
whitelist=0.0.0.0/0
|
||||
txindex=1
|
||||
blockfilterindex=1
|
||||
|
||||
[main]
|
||||
rpcbind=0.0.0.0
|
||||
rpcuser=rpcuser
|
||||
rpcpassword=VLSsigner1
|
||||
rpcport=8332
|
||||
port=8333
|
||||
|
||||
[test]
|
||||
rpcbind=0.0.0.0
|
||||
rpcuser=rpcuser
|
||||
rpcpassword=VLSsigner1
|
||||
rpcport=18332
|
||||
port=18333
|
||||
|
||||
[regtest]
|
||||
rpcbind=0.0.0.0
|
||||
rpcallowip=0.0.0.0/0
|
||||
whitelist=0.0.0.0/0
|
||||
zmqpubrawblock=tcp://bitcoind:38332
|
||||
zmqpubrawtx=tcp://bitcoind:38333
|
||||
txindex=1
|
||||
blockfilterindex=1
|
||||
rpcuser=rpcuser
|
||||
rpcpassword=VLSsigner1
|
||||
rpcport=38332
|
||||
port=38333
|
9
assets/main-config
Normal file
9
assets/main-config
Normal file
@ -0,0 +1,9 @@
|
||||
network=regtest
|
||||
bitcoin-rpcuser=rpcuser
|
||||
bitcoin-rpcpassword=VLSsigner1
|
||||
bitcoin-rpcport=8332
|
||||
log-level=info
|
||||
max-locktime-blocks=288
|
||||
important-plugin=/usr/bin/clboss
|
||||
clboss-auto-close=true
|
||||
bind-addr=0.0.0.0:9735
|
4
assets/main-env
Normal file
4
assets/main-env
Normal file
@ -0,0 +1,4 @@
|
||||
VLS_PORT=17701
|
||||
VLS_NETWORK=regtest
|
||||
BITCOIND_RPC_URL=http://rpcuser:VLSsigner1@bitcoind:8332
|
||||
RUST_LOG=info
|
9
assets/regtest-config
Normal file
9
assets/regtest-config
Normal file
@ -0,0 +1,9 @@
|
||||
network=regtest
|
||||
bitcoin-rpcuser=rpcuser
|
||||
bitcoin-rpcpassword=VLSsigner1
|
||||
bitcoin-rpcport=38332
|
||||
log-level=info
|
||||
max-locktime-blocks=288
|
||||
important-plugin=/usr/bin/clboss
|
||||
clboss-auto-close=true
|
||||
bind-addr=0.0.0.0:19846
|
4
assets/regtest-env
Normal file
4
assets/regtest-env
Normal file
@ -0,0 +1,4 @@
|
||||
VLS_PORT=17701
|
||||
VLS_NETWORK=regtest
|
||||
BITCOIND_RPC_URL=http://rpcuser:VLSsigner1@bitcoind:38332
|
||||
RUST_LOG=info
|
@ -5,4 +5,5 @@ bitcoin-rpcport=18332
|
||||
log-level=info
|
||||
max-locktime-blocks=288
|
||||
important-plugin=/usr/bin/clboss
|
||||
clboss-auto-close=true
|
||||
clboss-auto-close=true
|
||||
bind-addr=0.0.0.0:19735
|
@ -46,8 +46,8 @@ RUN set -ex \
|
||||
done && \
|
||||
wget -O- https://raw.githubusercontent.com/Kvaciral/kvaciral/main/kvaciral.asc | gpg --import
|
||||
|
||||
ENV BITCOIN_VERSION=23.0
|
||||
ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION}
|
||||
ARG BITCOIN_VERSION=23.0
|
||||
ARG BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION}
|
||||
ARG SHA256SUMS_HASH=aaff81ea001f499e8f6f3221387d7db960d71a3b7a4a2b1aaf2c8060bc94a391
|
||||
|
||||
RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS
|
||||
@ -121,8 +121,6 @@ RUN chmod +x /healthcheck.sh
|
||||
|
||||
VOLUME ["${BITCOIN_DATA}"]
|
||||
|
||||
EXPOSE 8332 8333 18332 18333 18444
|
||||
|
||||
RUN mkdir -p "${BITCOIN_DATA}"
|
||||
RUN chown -R bitcoin:bitcoin "${BITCOIN_DATA}"
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cp -u /bitcoin.conf $BITCOIN_DATA/
|
||||
cp /bitcoin.conf $BITCOIN_DATA/
|
||||
sed -i "1s/^/chain=$BITCOIN_CHAIN\n/" $BITCOIN_DATA/bitcoin.conf
|
||||
|
||||
if [ $(echo "$1" | cut -c1) = "-" ]; then
|
||||
echo "$0: assuming arguments for bitcoind"
|
||||
@ -9,5 +10,11 @@ if [ $(echo "$1" | cut -c1) = "-" ]; then
|
||||
set -- bitcoind "$@"
|
||||
fi
|
||||
|
||||
if [ $(echo "$1" | cut -c1) = "-" ] || [ "$1" = "bitcoind" ]; then
|
||||
echo "$0: setting chain to $BITCOIN_CHAIN"
|
||||
|
||||
set -- "$@" -chain=$BITCOIN_CHAIN
|
||||
fi
|
||||
|
||||
echo
|
||||
exec "$@"
|
||||
exec "$@"
|
||||
|
@ -1 +1 @@
|
||||
bitcoin-cli --chain=$BITCOIN_CHAIN getblockchaininfo
|
||||
bitcoin-cli -chain=$BITCOIN_CHAIN getblockchaininfo
|
25
docker-compose.mainnet.yml
Normal file
25
docker-compose.mainnet.yml
Normal file
@ -0,0 +1,25 @@
|
||||
version: "3.8"
|
||||
name: main
|
||||
services:
|
||||
bitcoin-core:
|
||||
container_name: bitcoind-main
|
||||
expose:
|
||||
- 8332
|
||||
ports:
|
||||
- 8333:8333
|
||||
environment:
|
||||
- BITCOIN_CHAIN=main
|
||||
|
||||
core-lightning:
|
||||
container_name: lightningd-main
|
||||
command:
|
||||
- --conf=/home/lightning/.lightning/main-config
|
||||
- --bitcoin-rpcconnect=bitcoind
|
||||
expose:
|
||||
- 9735
|
||||
ports:
|
||||
- 9735:9735
|
||||
env_file:
|
||||
- ./assets/main-env
|
||||
environment:
|
||||
- BITCOIN_CHAIN=main
|
25
docker-compose.regtest.yml
Normal file
25
docker-compose.regtest.yml
Normal file
@ -0,0 +1,25 @@
|
||||
version: "3.8"
|
||||
name: regtest
|
||||
services:
|
||||
bitcoin-core:
|
||||
container_name: bitcoind-regtest
|
||||
expose:
|
||||
- 38332
|
||||
ports:
|
||||
- 38333:38333
|
||||
environment:
|
||||
- BITCOIN_CHAIN=regtest
|
||||
|
||||
core-lightning:
|
||||
container_name: lightningd-regtest
|
||||
command:
|
||||
- --conf=/home/lightning/.lightning/regtest-config
|
||||
- --bitcoin-rpcconnect=bitcoind
|
||||
expose:
|
||||
- 19846
|
||||
ports:
|
||||
- 19846:19846
|
||||
env_file:
|
||||
- ./assets/regtest-env
|
||||
environment:
|
||||
- BITCOIN_CHAIN=regtest
|
10
docker-compose.testnet.yml
Normal file
10
docker-compose.testnet.yml
Normal file
@ -0,0 +1,10 @@
|
||||
version: "3.8"
|
||||
name: testnet
|
||||
services:
|
||||
bitcoin-core:
|
||||
ports:
|
||||
- 18333:18333
|
||||
|
||||
core-lightning:
|
||||
ports:
|
||||
- 19735:19735
|
@ -4,22 +4,11 @@ services:
|
||||
build:
|
||||
dockerfile: ./bitcoind/Dockerfile
|
||||
image: bitcoind
|
||||
container_name: bitcoind
|
||||
command:
|
||||
- --testnet
|
||||
- -pid=/home/bitcoin/.bitcoin/testnet3/bitcoind-testnet.pid
|
||||
container_name: bitcoind-test
|
||||
volumes:
|
||||
- data:/home/bitcoin/.bitcoin
|
||||
expose:
|
||||
- 8332
|
||||
- 8333
|
||||
- 18332
|
||||
- 18333
|
||||
- 18444
|
||||
ports:
|
||||
- 8333:8333
|
||||
- 18333:18333
|
||||
- 38333:38333
|
||||
networks:
|
||||
LN_testing:
|
||||
aliases:
|
||||
@ -31,31 +20,24 @@ services:
|
||||
build:
|
||||
dockerfile: ./lightningd/Dockerfile
|
||||
image: lightningd
|
||||
container_name: lightningd
|
||||
container_name: lightningd-test
|
||||
command:
|
||||
- --conf=/home/lightning/.lightning/testnet-config
|
||||
- --bitcoin-rpcconnect=bitcoind
|
||||
- --bind-addr=core-lightning:19735
|
||||
- --announce-addr=core-lightning:19735
|
||||
volumes:
|
||||
- clightning:/home/lightning/.lightning
|
||||
expose:
|
||||
- 9735
|
||||
- 9835
|
||||
ports:
|
||||
- 9735:9735
|
||||
- 19735:19735
|
||||
- 19735
|
||||
networks:
|
||||
- LN_testing
|
||||
links:
|
||||
- bitcoin-core:bitcoind
|
||||
depends_on:
|
||||
bitcoin-core:
|
||||
condition: service_healthy
|
||||
restart: true
|
||||
env_file:
|
||||
- ./assets/testnet-env
|
||||
|
||||
environment:
|
||||
- BITCOIN_CHAIN=test
|
||||
|
||||
volumes:
|
||||
data:
|
||||
@ -66,4 +48,4 @@ volumes:
|
||||
external: true
|
||||
|
||||
networks:
|
||||
LN_testing:
|
||||
LN_testing:
|
||||
|
@ -68,15 +68,13 @@ RUN apk update && \
|
||||
sqlite-dev
|
||||
|
||||
ARG LIGHTNINGD_UID=101
|
||||
ENV LIGHTNINGD_USER=lightning
|
||||
ENV LIGHTNINGD_HOME=/home/${LIGHTNINGD_USER}
|
||||
ARG LIGHTNINGD_USER=lightning
|
||||
ARG LIGHTNINGD_HOME=/home/${LIGHTNINGD_USER}
|
||||
ENV LIGHTNINGD_DATA=${LIGHTNINGD_HOME}/.lightning \
|
||||
LIGHTNINGD_RPC_PORT=9835 \
|
||||
LIGHTNINGD_PORT=9735 \
|
||||
BITCOIND_HOME=/root/.bitcoin
|
||||
|
||||
COPY lightningd/entrypoint.sh /entrypoint.sh
|
||||
|
||||
COPY --from=builder /usr/bin/lightningd /usr/bin/
|
||||
COPY --from=builder /usr/bin/lightning-cli /usr/bin/
|
||||
COPY --from=builder /usr/bin/lightning-hsmtool /usr/bin/
|
||||
@ -87,8 +85,15 @@ COPY --from=builder /usr/bin/clboss /usr/bin/clboss
|
||||
|
||||
RUN addgroup -S lightning && adduser -S lightning -G lightning && \
|
||||
mkdir -p ${LIGHTNINGD_DATA} && \
|
||||
touch ${LIGHTNINGD_DATA}/config && \
|
||||
chown -R lightning:lightning "${LIGHTNINGD_DATA}"
|
||||
chown -R lightning:lightning ${LIGHTNINGD_DATA}
|
||||
|
||||
COPY assets/bitcoin.conf "${BITCOIND_HOME}"/bitcoin.conf
|
||||
|
||||
COPY lightningd/entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
COPY lightningd/healthcheck.sh /healthcheck.sh
|
||||
RUN chmod +x /healthcheck.sh
|
||||
|
||||
VOLUME ["${LIGHTNINGD_DATA}"]
|
||||
|
||||
@ -97,11 +102,13 @@ RUN mkdir -p "${BITCOIND_HOME}" && \
|
||||
|
||||
COPY assets/bitcoin.conf "${BITCOIND_HOME}"/bitcoin.conf
|
||||
COPY assets/testnet-config /testnet-config
|
||||
COPY assets/regtest-config /regtest-config
|
||||
COPY assets/main-config /main-config
|
||||
|
||||
USER lightning
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s \
|
||||
CMD lighting-cli --testnet getinfo
|
||||
HEALTHCHECK --interval=10s --timeout=10s --start-period=15s \
|
||||
CMD ["/bin/sh", "-c", "/healthcheck.sh"]
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["lightningd"]
|
||||
|
@ -2,6 +2,8 @@
|
||||
set -e
|
||||
|
||||
cp -u /testnet-config ${LIGHTNINGD_DATA}/testnet-config
|
||||
cp -u /regtest-config ${LIGHTNINGD_DATA}/regtest-config
|
||||
cp -u /main-config ${LIGHTNINGD_DATA}/main-config
|
||||
|
||||
export GREENLIGHT_VERSION=$(lightningd --version)
|
||||
|
||||
|
15
lightningd/healthcheck.sh
Executable file
15
lightningd/healthcheck.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
LIGHTNING_NETWORK=""
|
||||
|
||||
case $BITCOIN_CHAIN in
|
||||
"test") LIGHTNING_NETWORK=testnet ;;
|
||||
"regtest") LIGHTNING_NETWORK=regtest ;;
|
||||
"main") LIGHTNING_NETWORK=bitcoin ;;
|
||||
"signet") LIGHTNING_NETWORK=signet ;;
|
||||
*) echo "Invalid BITCOIN_CHAIN value: $BITCOIN_CHAIN" && exit 1 ;;
|
||||
esac
|
||||
|
||||
lightning-cli --network $LIGHTNING_NETWORK getinfo
|
Loading…
x
Reference in New Issue
Block a user