From 350f3ce11f20527dbe205b85ffc8c89f4aaeaa5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Mon, 25 Mar 2024 09:38:32 +0100 Subject: [PATCH 1/6] feat: add boltz-client - added `clightning-2` for use with boltz-client --- docker-compose.yml | 39 +++++++++++++++++++++++++++++++++++++++ docker-scripts.sh | 26 ++++++++++++++++++++++++++ regtest | 2 +- 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index d4e404e..9cea30c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,21 @@ services: - ./data/boltz/:/root/.boltz/ - ./data/elements/:/root/.elements/ + boltz-client: + hostname: boltz-client + depends_on: + - clightning-2 + - elementsd + - bitcoind + restart: always + image: boltz/boltz-client:latest + ports: + - 9002:9002 + volumes: + - ./data/clightning-2:/data/clightning/ + - ./data/boltz/:/root/.boltz/ + - ./data/elements/:/root/.elements/ + anvil: hostname: anvil image: ghcr.io/foundry-rs/foundry:latest @@ -84,6 +99,30 @@ services: volumes: - ./data/clightning-1:/root/.lightning/ + clightning-2: + hostname: clightning-2 + restart: always + depends_on: + - bitcoind + image: boltz/c-lightning:23.08.1 + command: + - --large-channels + - --network + - regtest + - --bind-addr=0.0.0.0:9737 + - --bitcoin-rpcconnect=bitcoind + - --bitcoin-rpcport=18443 + - --bitcoin-rpcuser=regtest + - --bitcoin-rpcpassword=regtest + - --grpc-port=9738 + - --dev-bitcoind-poll=3 + expose: + - 9737 + ports: + - 9738:9738 + volumes: + - ./data/clightning-2:/root/.lightning/ + lnd-1: hostname: lnd-1 depends_on: diff --git a/docker-scripts.sh b/docker-scripts.sh index 0a82ed4..f9ff035 100755 --- a/docker-scripts.sh +++ b/docker-scripts.sh @@ -9,6 +9,10 @@ elements-cli-sim() { docker exec regtest-elementsd-1 elements-cli "$@" } +boltz-cli-sim() { + docker exec regtest-boltz-client-1 boltzcli "$@" +} + bitcoin-address() { curl localhost:3002/address/"$1" | jq . } @@ -116,11 +120,17 @@ elements-init(){ elements-cli-sim rescanblockchain 0 > /dev/null } +boltz-client-init(){ + boltzcli-sim wallet create lnbits LBTC + boltzcli-sim formatmacaroon +} + regtest-init(){ bitcoin-init elements-init lightning-sync lightning-init + boltz-client-init } lightning-sync(){ @@ -169,6 +179,22 @@ lightning-init(){ wait-for-lnd-channel 2 wait-for-clightning-channel 1 + # lnd-1 -> cln-2 + lncli-sim 1 connect $(lightning-cli-sim 2 getinfo | jq -r '.id')@regtest-clightning-2-1 > /dev/null + echo "open channel from lnd-1 to cln-2" + lncli-sim 1 openchannel $(lightning-cli-sim 2 getinfo | jq -r '.id') $channel_size $balance_size > /dev/null + bitcoin-cli-sim -generate $channel_confirms > /dev/null + wait-for-lnd-channel 1 + wait-for-clightning-channel 2 + + # lnd-2 -> cln-2 + lncli-sim 2 connect $(lightning-cli-sim 2 getinfo | jq -r '.id')@regtest-clightning-2-1 > /dev/null + echo "open channel from lnd-2 to cln-2" + lncli-sim 2 openchannel $(lightning-cli-sim 2 getinfo | jq -r '.id') $channel_size $balance_size > /dev/null + bitcoin-cli-sim -generate $channel_confirms > /dev/null + wait-for-lnd-channel 2 + wait-for-clightning-channel 2 + lightning-sync } diff --git a/regtest b/regtest index 1e2ac3a..3f130f3 100755 --- a/regtest +++ b/regtest @@ -42,7 +42,7 @@ for i in 1 2; do run "lnd-$i .channels[0].capacity" $channel_size $(lncli-sim $i listchannels | jq -r ".channels[0].capacity") run "lnd-$i .channels[0].push_amount_sat" $balance_size $(lncli-sim $i listchannels | jq -r ".channels[0].push_amount_sat") done -for i in 1; do +for i in 1 2; do # run "cln-$i blockheight" $blockheight $(lightning-cli-sim $i getinfo | jq -r ".blockheight") run "cln-$i utxo count" $utxos $(lightning-cli-sim $i listfunds | jq -r ".outputs | length") run "cln-$i openchannels" $channel_count $(lightning-cli-sim $i getinfo | jq -r ".num_active_channels") From d2b655edcd9769c53d65f614e60d77f2e678b951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Mon, 25 Mar 2024 10:00:37 +0100 Subject: [PATCH 2/6] fixup! --- .gitignore | 9 ++++- data/boltz-client/boltz.toml | 74 ++++++++++++++++++++++++++++++++++++ docker-compose.yml | 11 +++--- docker-scripts.sh | 8 ++-- regtest | 6 +-- 5 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 data/boltz-client/boltz.toml diff --git a/.gitignore b/.gitignore index 6d65454..f5e0709 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,14 @@ -data +data/* !data/elements +data/elements/* +!data/elements/elements.conf +!data/elements/liquid.cookie !data/boltz data/boltz/* !data/boltz/boltz.conf !data/boltz/seed.dat + +!data/boltz-client +data/boltz-client/* +!data/boltz-client/boltz.toml diff --git a/data/boltz-client/boltz.toml b/data/boltz-client/boltz.toml new file mode 100644 index 0000000..03a196b --- /dev/null +++ b/data/boltz-client/boltz.toml @@ -0,0 +1,74 @@ +# Path the the log file +logfile = "" + +electrumUrl = "localhost:19001" +electrumLiquidUrl = "localhost:19002" + +[BOLTZ] +# By default the daemon automatically connects to the official Boltz instance for the network LND is on +# This value is used to override that +url = "" + +[DATABASE] +# Path to the SQLite database file +# path = "/home/michael/test.db" + +[LND] +# Host of the gRPC interface of LND +host = "127.0.0.1" + +# Port of the gRPC interface of LND +port = 10009 + +# Path to a macaroon file of LND +# The daemon needs to have permission to read various endpoints, generate addresses and pay invoices +macaroon = "~/regtest/data/lnd-1/data/chain/bitcoin/regtest/admin.macaroon" + +# Path to the TLS certificate of LND +certificate = "~/regtest/data/lnd-1/tls.cert" + +[CLN] +host = "127.0.0.1" +port = 9736 + +rootcert = "~/regtest/data/clightning-1/regtest/ca.pem" +privatekey = "~/regtest/data/clightning-1/regtest/client-key.pem" +certchain = "~/regtest/data/clightning-1/regtest/client.pem" + + +[RPC] +# Host o.f +host = "127.0.0.1" + +# Port of the gRPC interface +port = 9002 + +# Whether the REST proxy for the gRPC interface should be disabled +restDisabled = false + +# Host of the REST proxy +restHost = "127.0.0.1" + +# Port of the REST proxy +restPort = 9003 + +# Path to the TLS cert for the gRPC and REST interface +tlsCert = "" + +# Path to the TLS private key for the gRPC and REST interface +tlsKey = "" + +# Whether the macaroon authentication for the gRPC and REST interface should be disabled +noMacaroons = true + +# Path to the admin macaroon for the gRPC and REST interface +adminMacaroonPath = "" + +# Path to the read only macaroon for the gRPC and REST interface +readOnlyMacaroonPath = "" + +[SWAP] +#autoSwap = true +#channelImbalanceThreshhold = 1 +#acceptZeroConf = true +#liquidAddress = "el1qq2490pg57wqtnh3ttmp2d9uxs3wg5aa3usjxv2nrvcycz2utscm69e652lwjcrynemeds7v5ltnwgq4hwrv6q65dnqkf9fayn" diff --git a/docker-compose.yml b/docker-compose.yml index 9cea30c..d5e35a1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,7 +28,7 @@ services: - 9002:9002 volumes: - ./data/clightning-2:/data/clightning/ - - ./data/boltz/:/root/.boltz/ + - ./data/boltz-client/:/root/.boltz/ - ./data/elements/:/root/.elements/ anvil: @@ -109,17 +109,16 @@ services: - --large-channels - --network - regtest - - --bind-addr=0.0.0.0:9737 + - --bind-addr=0.0.0.0:9735 - --bitcoin-rpcconnect=bitcoind - --bitcoin-rpcport=18443 - --bitcoin-rpcuser=regtest - --bitcoin-rpcpassword=regtest - - --grpc-port=9738 + - --grpc-port=9736 - --dev-bitcoind-poll=3 expose: - - 9737 - ports: - - 9738:9738 + - 9735 + - 9736 volumes: - ./data/clightning-2:/root/.lightning/ diff --git a/docker-scripts.sh b/docker-scripts.sh index f9ff035..d51f632 100755 --- a/docker-scripts.sh +++ b/docker-scripts.sh @@ -9,7 +9,7 @@ elements-cli-sim() { docker exec regtest-elementsd-1 elements-cli "$@" } -boltz-cli-sim() { +boltzcli-sim() { docker exec regtest-boltz-client-1 boltzcli "$@" } @@ -96,9 +96,9 @@ regtest-start-log(){ regtest-stop(){ docker compose down --volumes # clean up lightning node data - sudo rm -rf ./data/clightning-1 ./data/lnd-1 ./data/lnd-2 ./data/boltz/boltz.db ./data/elements/liquidregtest ./data/bitcoin/regtest + sudo rm -rf ./data/clightning-1 ./data/clightning-2 ./data/lnd-1 ./data/lnd-2 ./data/boltz/boltz.db ./data/elements/liquidregtest ./data/bitcoin/regtest # recreate lightning node data folders preventing permission errors - mkdir ./data/clightning-1 ./data/lnd-1 ./data/lnd-2 + mkdir ./data/clightning-1 ./data/clightning-2 ./data/lnd-1 ./data/lnd-2 } regtest-restart(){ @@ -135,6 +135,7 @@ regtest-init(){ lightning-sync(){ wait-for-clightning-sync 1 + wait-for-clightning-sync 2 wait-for-lnd-sync 1 wait-for-lnd-sync 2 } @@ -143,6 +144,7 @@ lightning-init(){ # create 10 UTXOs for each node for i in 0 1 2 3 4; do fund_clightning_node 1 + fund_clightning_node 2 fund_lnd_node 1 fund_lnd_node 2 done diff --git a/regtest b/regtest index 3f130f3..74e0807 100755 --- a/regtest +++ b/regtest @@ -20,8 +20,8 @@ run(){ } failed="false" -blockheight=171 -channel_count=2 +blockheight=183 +channel_count=3 utxos=5 channel_size=24000000 # 0.024 btc balance_size=12000000 # 0.012 btc @@ -45,7 +45,7 @@ done for i in 1 2; do # run "cln-$i blockheight" $blockheight $(lightning-cli-sim $i getinfo | jq -r ".blockheight") run "cln-$i utxo count" $utxos $(lightning-cli-sim $i listfunds | jq -r ".outputs | length") - run "cln-$i openchannels" $channel_count $(lightning-cli-sim $i getinfo | jq -r ".num_active_channels") + run "cln-$i openchannels" 2 $(lightning-cli-sim $i getinfo | jq -r ".num_active_channels") run "cln-$i channel[0].state" "CHANNELD_NORMAL" $(lightning-cli-sim $i listfunds | jq -r ".channels[0].state") run "cln-$i channel[0].amount_msat" $((channel_size * 1000)) $(lightning-cli-sim $i listfunds | jq -r ".channels[0].amount_msat") run "cln-$i channel[0].our_amount_msat" $((balance_size * 1000)) $(lightning-cli-sim $i listfunds | jq -r ".channels[0].our_amount_msat") From 0e1fc846d4c75fe5c746eb51ee05f997c7e50a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Mon, 25 Mar 2024 10:16:03 +0100 Subject: [PATCH 3/6] fixup! --- data/boltz-client/boltz.toml | 28 +++++++--------------------- docker-compose.yml | 2 +- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/data/boltz-client/boltz.toml b/data/boltz-client/boltz.toml index 03a196b..46bb938 100644 --- a/data/boltz-client/boltz.toml +++ b/data/boltz-client/boltz.toml @@ -1,39 +1,25 @@ # Path the the log file logfile = "" -electrumUrl = "localhost:19001" -electrumLiquidUrl = "localhost:19002" +electrumUrl = "electrs:19001" +electrumLiquidUrl = "electrs-liquid:19002" [BOLTZ] # By default the daemon automatically connects to the official Boltz instance for the network LND is on # This value is used to override that -url = "" +url = "http://boltz:9001" [DATABASE] # Path to the SQLite database file # path = "/home/michael/test.db" -[LND] -# Host of the gRPC interface of LND -host = "127.0.0.1" - -# Port of the gRPC interface of LND -port = 10009 - -# Path to a macaroon file of LND -# The daemon needs to have permission to read various endpoints, generate addresses and pay invoices -macaroon = "~/regtest/data/lnd-1/data/chain/bitcoin/regtest/admin.macaroon" - -# Path to the TLS certificate of LND -certificate = "~/regtest/data/lnd-1/tls.cert" - [CLN] -host = "127.0.0.1" +host = "clightning-2" port = 9736 -rootcert = "~/regtest/data/clightning-1/regtest/ca.pem" -privatekey = "~/regtest/data/clightning-1/regtest/client-key.pem" -certchain = "~/regtest/data/clightning-1/regtest/client.pem" +rootcert = "/root/.lightning/regtest/ca.pem" +privatekey = "/root/.lightning/regtest/client-key.pem" +certchain = "/root/.lightning/regtest/client.pem" [RPC] diff --git a/docker-compose.yml b/docker-compose.yml index d5e35a1..33ea5fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: ports: - 9002:9002 volumes: - - ./data/clightning-2:/data/clightning/ + - ./data/clightning-2:/root/.lightning/ - ./data/boltz-client/:/root/.boltz/ - ./data/elements/:/root/.elements/ From 329ff2ba5b5a45a9148105e37b9e592971f46883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Mon, 25 Mar 2024 10:19:40 +0100 Subject: [PATCH 4/6] enable macaroon --- data/boltz-client/boltz.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/boltz-client/boltz.toml b/data/boltz-client/boltz.toml index 46bb938..4b3759a 100644 --- a/data/boltz-client/boltz.toml +++ b/data/boltz-client/boltz.toml @@ -45,7 +45,7 @@ tlsCert = "" tlsKey = "" # Whether the macaroon authentication for the gRPC and REST interface should be disabled -noMacaroons = true +noMacaroons = false # Path to the admin macaroon for the gRPC and REST interface adminMacaroonPath = "" From fb22c7a9e91b50cb1ffcec0d57e43e0a99cb711d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Mon, 25 Mar 2024 10:27:11 +0100 Subject: [PATCH 5/6] interactive command --- docker-scripts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-scripts.sh b/docker-scripts.sh index d51f632..1620de5 100755 --- a/docker-scripts.sh +++ b/docker-scripts.sh @@ -10,7 +10,7 @@ elements-cli-sim() { } boltzcli-sim() { - docker exec regtest-boltz-client-1 boltzcli "$@" + docker exec -it regtest-boltz-client-1 boltzcli "$@" } bitcoin-address() { From 57c642c1466022a95a137ce6a86e04706d370e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Mon, 25 Mar 2024 12:34:06 +0100 Subject: [PATCH 6/6] fixup! --- data/boltz-client/boltz.toml | 9 +++++---- data/boltz/boltz.conf | 1 + docker-compose.yml | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/data/boltz-client/boltz.toml b/data/boltz-client/boltz.toml index 4b3759a..feb62bc 100644 --- a/data/boltz-client/boltz.toml +++ b/data/boltz-client/boltz.toml @@ -23,8 +23,8 @@ certchain = "/root/.lightning/regtest/client.pem" [RPC] -# Host o.f -host = "127.0.0.1" +# Host of +host = "boltz-client" # Port of the gRPC interface port = 9002 @@ -33,7 +33,7 @@ port = 9002 restDisabled = false # Host of the REST proxy -restHost = "127.0.0.1" +restHost = "boltz-client" # Port of the REST proxy restPort = 9003 @@ -43,9 +43,10 @@ tlsCert = "" # Path to the TLS private key for the gRPC and REST interface tlsKey = "" +noTls = true # Whether the macaroon authentication for the gRPC and REST interface should be disabled -noMacaroons = false +noMacaroons = true # Path to the admin macaroon for the gRPC and REST interface adminMacaroonPath = "" diff --git a/data/boltz/boltz.conf b/data/boltz/boltz.conf index b3e9a67..c1563a8 100755 --- a/data/boltz/boltz.conf +++ b/data/boltz/boltz.conf @@ -75,6 +75,7 @@ network = "liquidRegtest" maxSwapAmount = 40_294_967 minSwapAmount = 10_000 +maxZeroConfAmount = 40_294_967 [liquid.chain] host = "elementsd" diff --git a/docker-compose.yml b/docker-compose.yml index 33ea5fd..c950780 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,12 +20,12 @@ services: hostname: boltz-client depends_on: - clightning-2 - - elementsd - - bitcoind + - boltz restart: always image: boltz/boltz-client:latest ports: - 9002:9002 + - 9003:9003 volumes: - ./data/clightning-2:/root/.lightning/ - ./data/boltz-client/:/root/.boltz/