diff --git a/.env.development b/.env.development index b4e4e041..cdd54163 100644 --- a/.env.development +++ b/.env.development @@ -148,6 +148,13 @@ CLN_REST_PORT=9092 CLN_ADDR=bcrt1q02sqd74l4pxedy24fg0qtjz4y2jq7x4lxlgzrx CLN_PUBKEY=03ca7acec181dbf5e427c682c4261a46a0dd9ea5f35d97acb094e399f727835b90 +# router lnd container stuff +ROUTER_LND_REST_PORT=8082 +ROUTER_LND_GRPC_PORT=10011 +# docker exec -u lnd router_lnd lncli newaddress p2wkh --unused +ROUTER_LND_ADDR=bcrt1qfkmwfpwgn6wt0dd36s79x04swz8vleyafsdpdr +ROUTER_LND_PUBKEY=02750991fbf62e57631888bc469fae69c5e658bd1d245d8ab95ed883517caa33c3 + LNCLI_NETWORK=regtest # localstack container stuff diff --git a/docker-compose.yml b/docker-compose.yml index 2dcf891d..23f8d3a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -270,7 +270,7 @@ 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}) + nodes=(${SN_LND_ADDR} ${LND_ADDR} ${CLN_ADDR} ${ROUTER_LND_ADDR}) if (( blockcount <= 0 )); then echo "Creating wallet and address..." bitcoin-cli createwallet "" @@ -358,7 +358,7 @@ services: if [ $$(lncli getinfo | jq '.num_active_channels + .num_pending_channels') -ge 3 ]; then exit 0 else - lncli openchannel --node_key=$LND_PUBKEY --connect lnd:9735 --sat_per_vbyte 1 \\ + lncli openchannel --node_key=$ROUTER_LND_PUBKEY --connect router_lnd:9735 --sat_per_vbyte 1 \\ --min_confs 0 --local_amt=1000000000 --push_amt=500000000 fi " @@ -429,7 +429,7 @@ services: if [ $$(lncli getinfo | jq '.num_active_channels + .num_pending_channels') -ge 3 ]; then exit 0 else - lncli openchannel --node_key=$SN_LND_PUBKEY --connect sn_lnd:9735 --sat_per_vbyte 1 \\ + lncli openchannel --node_key=$ROUTER_LND_PUBKEY --connect router_lnd:9735 --sat_per_vbyte 1 \\ --min_confs 0 --local_amt=1000000000 --push_amt=500000000 fi " @@ -518,12 +518,63 @@ services: if [ $$(lightning-cli --regtest getinfo | jq '.num_active_channels + .num_pending_channels') -ge 3 ]; then exit 0 else - lightning-cli --regtest connect $SN_LND_PUBKEY@sn_lnd:9735 - lightning-cli --regtest fundchannel id=$SN_LND_PUBKEY feerate=1000perkb \\ + lightning-cli --regtest connect $ROUTER_LND_PUBKEY@router_lnd:9735 + lightning-cli --regtest fundchannel id=$ROUTER_LND_PUBKEY feerate=1000perkb \\ amount=1000000000 push_msat=500000000000 minconf=0 fi " cpu_shares: "${CPU_SHARES_MODERATE}" + router_lnd: + build: + context: ./docker/lnd + args: + - LN_NODE_FOR=router + container_name: router_lnd + restart: unless-stopped + profiles: + - payments + healthcheck: + <<: *healthcheck + test: ["CMD-SHELL", "lncli", "getinfo"] + depends_on: *depends_on_bitcoin + env_file: *env_file + command: + - 'lnd' + - '--noseedbackup' + - '--trickledelay=5000' + - '--alias=router_lnd' + - '--externalip=router_lnd' + - '--tlsextradomain=router_lnd' + - '--tlsextradomain=host.docker.internal' + - '--listen=0.0.0.0:9735' + - '--rpclisten=0.0.0.0:10009' + - '--restlisten=0.0.0.0:8080' + - '--bitcoin.active' + - '--bitcoin.regtest' + - '--bitcoin.node=bitcoind' + - '--bitcoind.rpchost=bitcoin' + - '--bitcoind.rpcuser=${RPC_USER}' + - '--bitcoind.rpcpass=${RPC_PASS}' + - '--bitcoind.zmqpubrawblock=tcp://bitcoin:${ZMQ_BLOCK_PORT}' + - '--bitcoind.zmqpubrawtx=tcp://bitcoin:${ZMQ_TX_PORT}' + - '--protocol.wumbo-channels' + - '--bitcoin.basefee=1000' + - '--bitcoin.feerate=0' + - '--maxchansize=1000000000' + - '--allow-circular-route' + - '--bitcoin.defaultchanconfs=1' + - '--maxpendingchannels=10' + expose: + - "9735" + ports: + - "${ROUTER_LND_REST_PORT}:8080" + - "${ROUTER_LND_GRPC_PORT}:10009" + volumes: + - router_lnd:/home/lnd/.lnd + labels: + CLI: "lncli" + CLI_USER: "lnd" + cpu_shares: "${CPU_SHARES_MODERATE}" channdler: image: mcuadros/ofelia:latest container_name: channdler @@ -661,6 +712,7 @@ volumes: sn_lnd: lnd: cln: + router_lnd: s3: nwc_send: nwc_recv: diff --git a/docker/lnd/router/regtest/admin.macaroon b/docker/lnd/router/regtest/admin.macaroon new file mode 100644 index 00000000..3cf21c09 Binary files /dev/null and b/docker/lnd/router/regtest/admin.macaroon differ diff --git a/docker/lnd/router/regtest/macaroons.db b/docker/lnd/router/regtest/macaroons.db new file mode 100644 index 00000000..c0bbb886 Binary files /dev/null and b/docker/lnd/router/regtest/macaroons.db differ diff --git a/docker/lnd/router/regtest/wallet.db b/docker/lnd/router/regtest/wallet.db new file mode 100644 index 00000000..9961a6a3 Binary files /dev/null and b/docker/lnd/router/regtest/wallet.db differ diff --git a/docker/lnd/router/tls.cert b/docker/lnd/router/tls.cert new file mode 100644 index 00000000..a930bf2a --- /dev/null +++ b/docker/lnd/router/tls.cert @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICRzCCAe2gAwIBAgIRALrTKBEy2NhGUue4RgGKhpgwCgYIKoZIzj0EAwIwODEf +MB0GA1UEChMWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEVMBMGA1UEAxMMNWRhMzQx +OTEwZDAyMB4XDTI0MTIwOTA4MzcxOVoXDTI2MDIwMzA4MzcxOVowODEfMB0GA1UE +ChMWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEVMBMGA1UEAxMMNWRhMzQxOTEwZDAy +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFPJk3jfBfWyHM7TB2pCJ45J5VqVI +r9x4nvBIZPQdvizgV4qqiNnnKTohZtH7eJ/T/epN3V9UNH3jW5MTcnIv+qOB1zCB +1DAOBgNVHQ8BAf8EBAMCAqQwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH/ +BAUwAwEB/zAdBgNVHQ4EFgQUN7Er1+iR3NeiwJXqLMD6CXb86qIwfQYDVR0RBHYw +dIIMNWRhMzQxOTEwZDAygglsb2NhbGhvc3SCCnJvdXRlcl9sbmSCFGhvc3QuZG9j +a2VyLmludGVybmFsggR1bml4ggp1bml4cGFja2V0ggdidWZjb25uhwR/AAABhxAA +AAAAAAAAAAAAAAAAAAABhwSsEgAJMAoGCCqGSM49BAMCA0gAMEUCIAucaM+ZivUy +G2PDcCfQZGDa0O8XVGQwofI2ZpMQwVe6AiEA9vYnOSZG1ozi0IKNgqbEs3ObByjE +dM+krTDuPzk8Kd4= +-----END CERTIFICATE----- diff --git a/docker/lnd/router/tls.key b/docker/lnd/router/tls.key new file mode 100644 index 00000000..d79948c4 --- /dev/null +++ b/docker/lnd/router/tls.key @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIBThCj41Abt/iEDYYMXb+mfHJmXN211JGYDjekJOmCbUoAoGCCqGSM49 +AwEHoUQDQgAEFPJk3jfBfWyHM7TB2pCJ45J5VqVIr9x4nvBIZPQdvizgV4qqiNnn +KTohZtH7eJ/T/epN3V9UNH3jW5MTcnIv+g== +-----END EC PRIVATE KEY----- diff --git a/scripts/test-routing.sh b/scripts/test-routing.sh new file mode 100644 index 00000000..7ce7b75b --- /dev/null +++ b/scripts/test-routing.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# test if every node can pay invoices from every other node + +SN_LND_PUBKEY=02cb2e2d5a6c5b17fa67b1a883e2973c82e328fb9bd08b2b156a9e23820c87a490 +LND_PUBKEY=028093ae52e011d45b3e67f2e0f2cb6c3a1d7f88d2920d408f3ac6db3a56dc4b35 +CLN_PUBKEY=03ca7acec181dbf5e427c682c4261a46a0dd9ea5f35d97acb094e399f727835b90 + +# -e: exit on first failure | -x: print commands +set -ex + +sndev cli lnd queryroutes $SN_LND_PUBKEY 1000 +sndev cli lnd queryroutes $CLN_PUBKEY 1000 + +sndev cli sn_lnd queryroutes $LND_PUBKEY 1000 +sndev cli sn_lnd queryroutes $CLN_PUBKEY 1000 + +# https://docs.corelightning.org/reference/lightning-getroute +sndev cli cln getroute $LND_PUBKEY 1000 0 +sndev cli cln getroute $SN_LND_PUBKEY 1000 0