open channel between ln nodes

This commit is contained in:
keyan 2024-03-09 23:47:32 -06:00
parent c63622b8a4
commit c88ba74268
5 changed files with 62 additions and 25 deletions

View File

@ -89,6 +89,10 @@ IMGPROXY_DOWNLOAD_TIMEOUT=9
# prisma db url
DATABASE_URL="postgresql://sn:password@db:5432/stackernews?schema=public"
###################
# FOR DOCKER ONLY #
###################
# postgres container stuff
POSTGRES_PASSWORD=password
POSTGRES_USER=sn
@ -113,15 +117,15 @@ ZMQ_TX_PORT=28335
LND_REST_PORT=8080
LND_GRPC_PORT=10009
LND_P2P_PORT=9735
# docker exec -u lnd sn_lnd lncli newaddress p2tr --unused
LND_ADDR=bcrt1phujdlvh2ttfdxcsc2c3p3vv6g5uutua9pr846r94ae33636gxy7qkly70z
# docker exec -u lnd sn_lnd lncli newaddress p2wkh --unused
LND_ADDR=bcrt1q7q06n5st4vqq3lssn0rtkrn2qqypghv9xg2xnl
LND_PUBKEY=02cb2e2d5a6c5b17fa67b1a883e2973c82e328fb9bd08b2b156a9e23820c87a490
# stacker lnd container stuff
STACKER_LND_REST_PORT=9090
STACKER_LND_GRPC_PORT=10010
# docker exec -u lnd stacker_lnd lncli newaddress p2tr --unused
STACKER_LND_ADDR=bcrt1pn0ach38n7k5ejxw7e2mx02gqe237em7d9eev3dcd2yst3tlyhtdswkgd89
# docker exec -u lnd stacker_lnd lncli newaddress p2wkh --unused
STACKER_LND_ADDR=bcrt1qfqau4ug9e6rtrvxrgclg58e0r93wshucumm9vu
STACKER_LND_PUBKEY=028093ae52e011d45b3e67f2e0f2cb6c3a1d7f88d2920d408f3ac6db3a56dc4b35
LNCLI_NETWORK=regtest

View File

@ -40,6 +40,9 @@ services:
opensearch:
condition: service_healthy
restart: true
sn_lnd:
condition: service_healthy
restart: true
env_file:
- .env.sndev
expose:
@ -70,6 +73,9 @@ services:
opensearch:
condition: service_healthy
restart: true
sn_lnd:
condition: service_healthy
restart: true
env_file:
- .env.sndev
volumes:
@ -155,17 +161,7 @@ services:
container_name: bitcoin
restart: unless-stopped
healthcheck:
test: >
bash -c '
set -e
blockcount=$$(bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} getblockcount 2>/dev/null)
if (( blockcount <= 0 )); then
bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} generatetoaddress 10 ${LND_ADDR}
bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} generatetoaddress 10 ${STACKER_LND_ADDR}
exit 1
fi
exit 0
'
test: ["CMD-SHELL", "bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} getblockchaininfo"]
interval: 10s
timeout: 10s
retries: 10
@ -199,14 +195,21 @@ services:
- bitcoin:/home/bitcoin/.bitcoin
labels:
ofelia.enabled: "true"
ofelia.job-exec.minecron.schedule: "@every 2m"
ofelia.job-exec.minecron.schedule: "@every 1m"
ofelia.job-exec.minecron.command: >
bash -c '
echo "Mining a block to sn_lnd..."
bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} generatetoaddress 1 ${LND_ADDR}
sleep 60
echo "Mining a block to stacker_lnd..."
bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} generatetoaddress 1 ${STACKER_LND_ADDR}'
blockcount=$$(bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} getblockcount 2>/dev/null)
if (( blockcount <= 0 )); then
echo "Mining 10 blocks to sn_lnd and stacker_lnd..."
bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} generatetoaddress 100 ${LND_ADDR}
bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} generatetoaddress 100 ${STACKER_LND_ADDR}
else
echo "Mining a block to sn_lnd... ${LND_ADDR}"
bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} generatetoaddress 1 ${LND_ADDR}
echo "Mining a block to stacker_lnd... ${STACKER_LND_ADDR}"
bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} generatetoaddress 1 ${STACKER_LND_ADDR}
fi
'
sn_lnd:
build:
context: ./docker/lnd
@ -215,7 +218,7 @@ services:
container_name: sn_lnd
restart: unless-stopped
healthcheck:
test: ["CMD", "lncli", "getinfo"]
test: ["CMD-SHELL", "lncli", "getinfo"]
interval: 10s
timeout: 10s
retries: 10
@ -249,6 +252,7 @@ services:
- '--maxchansize=1000000000'
- '--allow-circular-route'
- '--bitcoin.defaultchanconfs=0'
- '--maxpendingchannels=10'
expose:
- "${LND_P2P_PORT}"
ports:
@ -256,6 +260,17 @@ services:
- "${LND_GRPC_PORT}:${LND_GRPC_PORT}"
volumes:
- sn_lnd:/home/lnd/.lnd
labels:
ofelia.enabled: "true"
ofelia.job-exec.sn_channel_cron.schedule: "@every 1m"
ofelia.job-exec.sn_channel_cron.command: >
su lnd -c bash -c "
if [ $$(lncli listchannels | jq '.member | length') -ge 1 ]; then
exit 0
else
lncli openchannel --node_key=$STACKER_LND_PUBKEY --connect stacker_lnd:9735 --sat_per_vbyte 1 --min_confs 0 --local_amt=1000000000 --push_amt=500000000
fi
"
stacker_lnd:
build:
context: ./docker/lnd
@ -264,7 +279,7 @@ services:
container_name: stacker_lnd
restart: unless-stopped
healthcheck:
test: ["CMD", "lncli", "getinfo"]
test: ["CMD-SHELL", "lncli", "getinfo"]
interval: 10s
timeout: 10s
retries: 10
@ -275,8 +290,6 @@ services:
restart: true
env_file:
- .env.sndev
environment:
- LN_NODE_FOR=stacker
command:
- 'lnd'
- '--noseedbackup'
@ -300,6 +313,7 @@ services:
- '--maxchansize=1000000000'
- '--allow-circular-route'
- '--bitcoin.defaultchanconfs=0'
- '--maxpendingchannels=10'
expose:
- "${LND_P2P_PORT}"
ports:
@ -307,11 +321,24 @@ services:
- "${STACKER_LND_GRPC_PORT}:${LND_GRPC_PORT}"
volumes:
- stacker_lnd:/home/lnd/.lnd
labels:
ofelia.enabled: "true"
ofelia.job-exec.stacker_channel_cron.schedule: "@every 1m"
ofelia.job-exec.stacker_channel_cron.command: >
su lnd -c bash -c "
if [ $$(lncli listchannels | jq '.member | length') -ge 1 ]; then
exit 0
else
lncli openchannel --node_key=$LND_PUBKEY --connect sn_lnd:9735 --sat_per_vbyte 1 --min_confs 0 --local_amt=1000000000 --push_amt=500000000
fi
"
channdler:
image: mcuadros/ofelia:latest
container_name: channdler
depends_on:
- bitcoin
- sn_lnd
- stacker_lnd
restart: unless-stopped
command: daemon --docker -f label=com.docker.compose.project=${COMPOSE_PROJECT_NAME}
volumes:

View File

@ -1,6 +1,12 @@
FROM polarlightning/lnd:0.17.4-beta
ARG LN_NODE_FOR
ENV LN_NODE_FOR=$LN_NODE_FOR
RUN apt-get update -y \
&& apt-get install -y jq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY ["./$LN_NODE_FOR/regtest/*", "/home/lnd/.lnd/data/chain/bitcoin/regtest/"]
COPY ["./$LN_NODE_FOR/tls.*", "/home/lnd/.lnd/"]

Binary file not shown.

Binary file not shown.