Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
feat: add boltz-client (#5)
Browse files Browse the repository at this point in the history
* feat: add boltz-client
- added `clightning-2` for use with boltz-client
* enable macaroon
* interactive command
  • Loading branch information
dni authored Mar 25, 2024
1 parent 4b32702 commit 0502f2e
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 7 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -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
61 changes: 61 additions & 0 deletions data/boltz-client/boltz.toml
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions data/boltz/boltz.conf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ network = "liquidRegtest"

maxSwapAmount = 40_294_967
minSwapAmount = 10_000
maxZeroConfAmount = 40_294_967

[liquid.chain]
host = "elementsd"
Expand Down
38 changes: 38 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
32 changes: 30 additions & 2 deletions docker-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
}
Expand Down Expand Up @@ -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(){
Expand All @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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

}
Expand Down
8 changes: 4 additions & 4 deletions regtest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 0502f2e

Please sign in to comment.