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..feb62bc --- /dev/null +++ b/data/boltz-client/boltz.toml @@ -0,0 +1,61 @@ +# Path the the log file +logfile = "" + +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 = "http://boltz:9001" + +[DATABASE] +# Path to the SQLite database file +# path = "/home/michael/test.db" + +[CLN] +host = "clightning-2" +port = 9736 + +rootcert = "/root/.lightning/regtest/ca.pem" +privatekey = "/root/.lightning/regtest/client-key.pem" +certchain = "/root/.lightning/regtest/client.pem" + + +[RPC] +# Host of +host = "boltz-client" + +# 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 = "boltz-client" + +# 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 = "" +noTls = true + +# 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/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 d4e404e..c950780 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 + - boltz + restart: always + image: boltz/boltz-client:latest + ports: + - 9002:9002 + - 9003:9003 + volumes: + - ./data/clightning-2:/root/.lightning/ + - ./data/boltz-client/:/root/.boltz/ + - ./data/elements/:/root/.elements/ + anvil: hostname: anvil image: ghcr.io/foundry-rs/foundry:latest @@ -84,6 +99,29 @@ 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:9735 + - --bitcoin-rpcconnect=bitcoind + - --bitcoin-rpcport=18443 + - --bitcoin-rpcuser=regtest + - --bitcoin-rpcpassword=regtest + - --grpc-port=9736 + - --dev-bitcoind-poll=3 + expose: + - 9735 + - 9736 + 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..1620de5 100755 --- a/docker-scripts.sh +++ b/docker-scripts.sh @@ -9,6 +9,10 @@ elements-cli-sim() { docker exec regtest-elementsd-1 elements-cli "$@" } +boltzcli-sim() { + docker exec -it regtest-boltz-client-1 boltzcli "$@" +} + bitcoin-address() { curl localhost:3002/address/"$1" | jq . } @@ -92,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(){ @@ -116,15 +120,22 @@ 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(){ wait-for-clightning-sync 1 + wait-for-clightning-sync 2 wait-for-lnd-sync 1 wait-for-lnd-sync 2 } @@ -133,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 @@ -169,6 +181,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..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 @@ -42,10 +42,10 @@ 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") + 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")