diff --git a/.env.development b/.env.development index cdd54163..08266352 100644 --- a/.env.development +++ b/.env.development @@ -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 diff --git a/.gitignore b/.gitignore index ceb04b51..3f2c478f 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,7 @@ docker-compose.*.yml scripts/nwc-keys.json # lnbits -docker/lnbits/data \ No newline at end of file +docker/lnbits/data + +# lndk +!docker/lndk/tls-*.pem \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 23f8d3a8..ca015448 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: \ No newline at end of file diff --git a/docker/eclair/Dockerfile b/docker/eclair/Dockerfile new file mode 100644 index 00000000..16316e37 --- /dev/null +++ b/docker/eclair/Dockerfile @@ -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}" \ No newline at end of file diff --git a/docker/eclair/stacker/channel_seed.dat b/docker/eclair/stacker/channel_seed.dat new file mode 100644 index 00000000..7b5b33ce --- /dev/null +++ b/docker/eclair/stacker/channel_seed.dat @@ -0,0 +1 @@ +thC(ĀBqF`iBL)L \ No newline at end of file diff --git a/docker/eclair/stacker/node_seed.dat b/docker/eclair/stacker/node_seed.dat new file mode 100644 index 00000000..5d5afca0 --- /dev/null +++ b/docker/eclair/stacker/node_seed.dat @@ -0,0 +1 @@ +61>bgO嵿}k !sb \ No newline at end of file diff --git a/docker/eclair/stacker/regtest/audit.sqlite b/docker/eclair/stacker/regtest/audit.sqlite new file mode 100644 index 00000000..cc0c2467 Binary files /dev/null and b/docker/eclair/stacker/regtest/audit.sqlite differ diff --git a/docker/eclair/stacker/regtest/eclair.sqlite b/docker/eclair/stacker/regtest/eclair.sqlite new file mode 100644 index 00000000..d306fb0d Binary files /dev/null and b/docker/eclair/stacker/regtest/eclair.sqlite differ diff --git a/docker/eclair/stacker/regtest/last_jdbcurl b/docker/eclair/stacker/regtest/last_jdbcurl new file mode 100644 index 00000000..532c6c60 --- /dev/null +++ b/docker/eclair/stacker/regtest/last_jdbcurl @@ -0,0 +1 @@ +sqlite diff --git a/docker/eclair/stacker/regtest/network.sqlite b/docker/eclair/stacker/regtest/network.sqlite new file mode 100644 index 00000000..cc0c2467 Binary files /dev/null and b/docker/eclair/stacker/regtest/network.sqlite differ diff --git a/docker/lndk/Dockerfile b/docker/lndk/Dockerfile new file mode 100644 index 00000000..a421053a --- /dev/null +++ b/docker/lndk/Dockerfile @@ -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}" \ No newline at end of file diff --git a/docker/lndk/tls-cert.pem b/docker/lndk/tls-cert.pem new file mode 100644 index 00000000..16202cee --- /dev/null +++ b/docker/lndk/tls-cert.pem @@ -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----- diff --git a/docker/lndk/tls-key.pem b/docker/lndk/tls-key.pem new file mode 100644 index 00000000..d31388e7 --- /dev/null +++ b/docker/lndk/tls-key.pem @@ -0,0 +1,5 @@ +-----BEGIN PRIVATE KEY----- +MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgTa/r2pnmB05EwKk6 +a4FbigSagGBok+i/ASxkG9iGedWhRANCAARnbvXF1BkjyMnEgm5hm+v+FPrcbxNG +kr87DHPqShYl5Qfj/98f1sWDMZRwdJYfX00FPLXVYidgGP0Jx1cFJDuA +-----END PRIVATE KEY-----