Skip to content

Commit

Permalink
Bolt12 dev environment (#1702)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: k00b <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent bf541aa commit 5273494
Show file tree
Hide file tree
Showing 13 changed files with 215 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ docker-compose.*.yml
scripts/nwc-keys.json

# lnbits
docker/lnbits/data
docker/lnbits/data

# lndk
!docker/lndk/tls-*.pem
103 changes: 100 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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: >
Expand All @@ -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..."
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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'"]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -717,3 +813,4 @@ volumes:
nwc_send:
nwc_recv:
tordata:
eclair:
68 changes: 68 additions & 0 deletions docker/eclair/Dockerfile
Original file line number Diff line number Diff line change
@@ -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}"
1 change: 1 addition & 0 deletions docker/eclair/stacker/channel_seed.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��thC(��Ā��B��qF���`iB�L)L����
1 change: 1 addition & 0 deletions docker/eclair/stacker/node_seed.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6��1>��bgO�嵿��}�k �!sb����
Binary file added docker/eclair/stacker/regtest/audit.sqlite
Binary file not shown.
Binary file added docker/eclair/stacker/regtest/eclair.sqlite
Binary file not shown.
1 change: 1 addition & 0 deletions docker/eclair/stacker/regtest/last_jdbcurl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqlite
Binary file added docker/eclair/stacker/regtest/network.sqlite
Binary file not shown.
17 changes: 17 additions & 0 deletions docker/lndk/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 changes: 10 additions & 0 deletions docker/lndk/tls-cert.pem
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions docker/lndk/tls-key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgTa/r2pnmB05EwKk6
a4FbigSagGBok+i/ASxkG9iGedWhRANCAARnbvXF1BkjyMnEgm5hm+v+FPrcbxNG
kr87DHPqShYl5Qfj/98f1sWDMZRwdJYfX00FPLXVYidgGP0Jx1cFJDuA
-----END PRIVATE KEY-----

0 comments on commit 5273494

Please sign in to comment.