Bolt12 dev environment (#1702)

* lndk-eclair bolt12 test environment

* use static certs for lndk dev

* move eclair/lndk/cln to wallets profile, force lndk onto x86 platform

* fix port conflict

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: k00b <k00b@stacker.news>
This commit is contained in:
Riccardo Balbo 2024-12-13 19:30:30 +01:00 committed by GitHub
parent bf541aa643
commit 52734940a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 215 additions and 4 deletions

View File

@ -126,6 +126,7 @@ RPC_PORT=18443
P2P_PORT=18444
ZMQ_BLOCK_PORT=28334
ZMQ_TX_PORT=28335
ZMQ_HASHBLOCK_PORT=29000
# sn_lnd container stuff
SN_LND_REST_PORT=8080
@ -134,6 +135,8 @@ SN_LND_P2P_PORT=9735
# docker exec -u lnd sn_lnd lncli newaddress p2wkh --unused
SN_LND_ADDR=bcrt1q7q06n5st4vqq3lssn0rtkrn2qqypghv9xg2xnl
SN_LND_PUBKEY=02cb2e2d5a6c5b17fa67b1a883e2973c82e328fb9bd08b2b156a9e23820c87a490
# sn_lndk stuff
SN_LNDK_GRPC_PORT=10012
# lnd container stuff
LND_REST_PORT=8081
@ -148,6 +151,11 @@ CLN_REST_PORT=9092
CLN_ADDR=bcrt1q02sqd74l4pxedy24fg0qtjz4y2jq7x4lxlgzrx
CLN_PUBKEY=03ca7acec181dbf5e427c682c4261a46a0dd9ea5f35d97acb094e399f727835b90
# sndev cli eclair getnewaddress
# sndev cli eclair getinfo
ECLAIR_ADDR="bcrt1qdus2yml69wsax3unz8pts9h979lc3s4tw0tpf6"
ECLAIR_PUBKEY="02268c74cc07837041131474881f97d497706b89a29f939555da6d094b65bd5af0"
# router lnd container stuff
ROUTER_LND_REST_PORT=8082
ROUTER_LND_GRPC_PORT=10011

5
.gitignore vendored
View File

@ -58,4 +58,7 @@ docker-compose.*.yml
scripts/nwc-keys.json
# lnbits
docker/lnbits/data
docker/lnbits/data
# lndk
!docker/lndk/tls-*.pem

View File

@ -241,12 +241,15 @@ services:
- '-debug=1'
- '-zmqpubrawblock=tcp://0.0.0.0:${ZMQ_BLOCK_PORT}'
- '-zmqpubrawtx=tcp://0.0.0.0:${ZMQ_TX_PORT}'
- '-zmqpubhashblock=tcp://bitcoin:${ZMQ_HASHBLOCK_PORT}'
- '-txindex=1'
- '-dnsseed=0'
- '-upnp=0'
- '-rpcbind=0.0.0.0'
- '-rpcallowip=0.0.0.0/0'
- '-whitelist=0.0.0.0/0'
- '-rpcport=${RPC_PORT}'
- '-deprecatedrpc=signrawtransaction'
- '-rest'
- '-listen=1'
- '-listenonion=0'
@ -262,6 +265,8 @@ services:
volumes:
- bitcoin:/home/bitcoin/.bitcoin
labels:
CLI: "bitcoin-cli"
CLI_ARGS: "-chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS}"
ofelia.enabled: "true"
ofelia.job-exec.minecron.schedule: "@every 1m"
ofelia.job-exec.minecron.command: >
@ -270,12 +275,14 @@ services:
command bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} "$$@"
}
blockcount=$$(bitcoin-cli getblockcount 2>/dev/null)
nodes=(${SN_LND_ADDR} ${LND_ADDR} ${CLN_ADDR} ${ROUTER_LND_ADDR})
nodes=(${SN_LND_ADDR} ${LND_ADDR} ${CLN_ADDR} ${ROUTER_LND_ADDR} ${ECLAIR_ADDR})
if (( blockcount <= 0 )); then
echo "Creating wallet and address..."
bitcoin-cli createwallet ""
nodes+=($$(bitcoin-cli getnewaddress))
echo "Mining 100 blocks to sn_lnd, lnd, cln..."
echo "Mining 100 blocks to sn_lnd, lnd, cln, eclair..."
for addr in "$${nodes[@]}"; do
bitcoin-cli generatetoaddress 100 $$addr
echo "Mining 100 blocks to a random address..."
@ -341,6 +348,10 @@ services:
- '--allow-circular-route'
- '--bitcoin.defaultchanconfs=1'
- '--maxpendingchannels=10'
- '--gossip.sub-batch-delay=1s'
- '--protocol.custom-message=513'
- '--protocol.custom-nodeann=39'
- '--protocol.custom-init=39'
expose:
- "9735"
ports:
@ -363,6 +374,34 @@ services:
fi
"
cpu_shares: "${CPU_SHARES_MODERATE}"
sn_lndk:
platform: linux/x86_64
build:
context: ./docker/lndk
container_name: sn_lndk
restart: unless-stopped
profiles:
- wallets
depends_on:
sn_lnd:
condition: service_healthy
restart: true
env_file: *env_file
command:
- 'lndk'
- '--grpc-host=0.0.0.0'
- '--address=https://sn_lnd:10009'
- '--cert-path=/home/lnd/.lnd/tls.cert'
- '--tls-ip=sn_lndk'
- '--macaroon-path=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon'
ports:
- "${SN_LNDK_GRPC_PORT}:7000"
volumes:
- sn_lnd:/home/lnd/.lnd
labels:
CLI: "lndk-cli --macaroon-path=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon"
CLI_USER: "lndk"
cpu_shares: "${CPU_SHARES_MODERATE}"
lnd:
build:
context: ./docker/lnd
@ -477,7 +516,7 @@ services:
container_name: cln
restart: unless-stopped
profiles:
- payments
- wallets
healthcheck:
<<: *healthcheck
test: ["CMD-SHELL", "su clightning -c 'lightning-cli --network=regtest getinfo'"]
@ -524,6 +563,63 @@ services:
fi
"
cpu_shares: "${CPU_SHARES_MODERATE}"
eclair:
build:
context: ./docker/eclair
args:
- LN_NODE_FOR=stacker
container_name: eclair
profiles:
- wallets
restart: unless-stopped
depends_on:
<<: *depends_on_bitcoin
environment:
<<: *env_file
JAVA_OPTS:
-Declair.printToConsole
-Dakka.loglevel=DEBUG
-Declair.server.port=9735
-Declair.server.public-ips.0=eclair
-Declair.api.binding-ip=0.0.0.0
-Declair.api.enabled=true
-Declair.api.port=8080
-Declair.api.password=pass
-Declair.node-alias=eclair
-Declair.chain=regtest
-Declair.bitcoind.host=bitcoin
-Declair.bitcoind.rpcport=${RPC_PORT}
-Declair.bitcoind.rpcuser=${RPC_USER}
-Declair.bitcoind.rpcpassword=${RPC_PASS}
-Declair.bitcoind.zmqblock=tcp://bitcoin:${ZMQ_HASHBLOCK_PORT}
-Declair.bitcoind.zmqtx=tcp://bitcoin:${ZMQ_TX_PORT}
-Declair.bitcoind.batch-watcher-requests=false
-Declair.features.option_onion_messages=optional
-Declair.features.option_route_blinding=optional
-Declair.features.keysend=optional
-Declair.channel.accept-incoming-static-remote-key-channels=true
-Declair.tip-jar.description=bolt12
-Declair.tip-jar.default-amount-msat=100000000
-Declair.tip-jar.max-final-expiry-delta=1000
volumes:
- eclair:/data
expose:
- "9735"
labels:
CLI: "eclair-cli"
CLI_USER: "root"
CLI_ARGS: "-p pass"
ofelia.enabled: "true"
ofelia.job-exec.eclair_channel_cron.schedule: "@every 1m"
ofelia.job-exec.eclair_channel_cron.command: >
bash -c "
if [ $$(eclair-cli -p pass channels | jq 'length') -ge 3 ]; then
exit 0
else
eclair-cli -p pass connect --uri=$SN_LND_PUBKEY@sn_lnd:9735
eclair-cli -p pass open --nodeId=$SN_LND_PUBKEY --fundingFeerateSatByte=1 --fundingSatoshis=1000000 --pushMsat=500000000 --announceChannel=true
fi
"
router_lnd:
build:
context: ./docker/lnd
@ -717,3 +813,4 @@ volumes:
nwc_send:
nwc_recv:
tordata:
eclair:

68
docker/eclair/Dockerfile Normal file
View File

@ -0,0 +1,68 @@
# based on https://github.com/LN-Zap/bolt12-playground
FROM acinq/eclair:0.11.0
ENTRYPOINT JAVA_OPTS="${JAVA_OPTS}" eclair-node/bin/eclair-node.sh "-Declair.datadir=${ECLAIR_DATADIR}"
#################
# Builder image #
#################
FROM maven:3.8.6-openjdk-11-slim AS builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# References for eclair
ARG ECLAIR_REF=b73a009a1d7d7ea3a158776cd233512b9a538550
ARG ECLAIR_PLUGINS_REF=cdc26dda96774fdc3b54075df078587574891fb7
WORKDIR /usr/src/eclair
RUN git clone https://github.com/ACINQ/eclair.git . \
&& git reset --hard ${ECLAIR_REF}
RUN mvn install -pl eclair-node -am -DskipTests -Dgit.commit.id=notag -Dgit.commit.id.abbrev=notag
WORKDIR /usr/src/eclair-plugins
RUN git clone https://github.com/ACINQ/eclair-plugins.git . \
&& git reset --hard ${ECLAIR_PLUGINS_REF}
WORKDIR /usr/src/eclair-plugins/bolt12-tip-jar
RUN mvn package -DskipTests
# ###############
# # final image #
# ###############
FROM openjdk:11.0.16-jre-slim-bullseye
WORKDIR /opt
# Add utils
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bash jq curl unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# copy and install eclair-cli executable
COPY --from=builder /usr/src/eclair/eclair-core/eclair-cli .
RUN chmod +x eclair-cli && mv eclair-cli /sbin/eclair-cli
# we only need the eclair-node.zip to run
COPY --from=builder /usr/src/eclair/eclair-node/target/eclair-node-*.zip ./eclair-node.zip
RUN unzip eclair-node.zip && mv eclair-node-* eclair-node && chmod +x eclair-node/bin/eclair-node.sh
# copy and install bolt12-tip-jar plugin
COPY --from=builder /usr/src/eclair-plugins/bolt12-tip-jar/target/bolt12-tip-jar-0.10.1-SNAPSHOT.jar .
ENV ECLAIR_DATADIR=/data
ENV JAVA_OPTS=
RUN mkdir -p "$ECLAIR_DATADIR"
VOLUME [ "/data" ]
ARG LN_NODE_FOR
ENV LN_NODE_FOR=$LN_NODE_FOR
COPY ["./$LN_NODE_FOR/*", "/data"]
# ENTRYPOINT JAVA_OPTS="${JAVA_OPTS}" eclair-node/bin/eclair-node.sh "-Declair.datadir=${ECLAIR_DATADIR}"
ENTRYPOINT JAVA_OPTS="${JAVA_OPTS}" eclair-node/bin/eclair-node.sh bolt12-tip-jar-0.10.1-SNAPSHOT.jar "-Declair.datadir=${ECLAIR_DATADIR}"

View File

@ -0,0 +1 @@
フマthC(涬ト€ロレBワモqFノ<46>`iBチL)L<><4C><EFBFBD>

View File

@ -0,0 +1 @@
6═У1>Т▀ВbgOоЕ╣©░ь}Нk ┴!sb÷²У÷

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
sqlite

Binary file not shown.

17
docker/lndk/Dockerfile Normal file
View File

@ -0,0 +1,17 @@
# This image uses fedora 40 because the official pre-built lndk binaries require
# glibc 2.39 which is not available on debian or ubuntu images.
FROM fedora:40
RUN useradd -u 1000 -m lndk
RUN mkdir -p /home/lndk/.lndk
COPY ["./tls-*", "/home/lndk/.lndk"]
RUN chown 1000:1000 -Rvf /home/lndk/.lndk && \
chmod 644 /home/lndk/.lndk/tls-cert.pem && \
chmod 600 /home/lndk/.lndk/tls-key.pem
USER lndk
RUN curl --proto '=https' --tlsv1.2 -LsSf https://github.com/lndk-org/lndk/releases/download/v0.2.0/lndk-installer.sh | sh
RUN echo 'source /home/lndk/.cargo/env' >> $HOME/.bashrc
WORKDIR /home/lndk
EXPOSE 7000
ENV PATH="/home/lndk/.cargo/bin:${PATH}"

10
docker/lndk/tls-cert.pem Normal file
View File

@ -0,0 +1,10 @@
-----BEGIN CERTIFICATE-----
MIIBaDCCAQ2gAwIBAgIUOms3xZ+pBVUntnFD7J0m7Ll1MZYwCgYIKoZIzj0EAwIw
ITEfMB0GA1UEAwwWcmNnZW4gc2VsZiBzaWduZWQgY2VydDAgFw03NTAxMDEwMDAw
MDBaGA80MDk2MDEwMTAwMDAwMFowITEfMB0GA1UEAwwWcmNnZW4gc2VsZiBzaWdu
ZWQgY2VydDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABGdu9cXUGSPIycSCbmGb
6/4U+txvE0aSvzsMc+pKFiXlB+P/3x/WxYMxlHB0lh9fTQU8tdViJ2AY/QnHVwUk
O4CjITAfMB0GA1UdEQQWMBSCCWxvY2FsaG9zdIIHc25fbG5kazAKBggqhkjOPQQD
AgNJADBGAiEA78UdPHgdaXVyttqt21+uWTlFn4B6queGL/cmYpQbiIsCIQCwxY0n
x2v5zXEwPU/bOnaQNeq9F8AT+/4lKelHfON/Gw==
-----END CERTIFICATE-----

5
docker/lndk/tls-key.pem Normal file
View File

@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgTa/r2pnmB05EwKk6
a4FbigSagGBok+i/ASxkG9iGedWhRANCAARnbvXF1BkjyMnEgm5hm+v+FPrcbxNG
kr87DHPqShYl5Qfj/98f1sWDMZRwdJYfX00FPLXVYidgGP0Jx1cFJDuA
-----END PRIVATE KEY-----