Skip to content

Commit

Permalink
fix: channels not being created
Browse files Browse the repository at this point in the history
* fix: channels not being created

* fixup! fix: channels not being created
  • Loading branch information
maybeast authored Jul 28, 2024
1 parent 3b01546 commit 1572ad1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 29 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ Data dirs for the services are stored in `./data` folder.
docker exec -it boltz-scripts bash
```

- bitcoin-cli-sim
- elements-cli-sim
- bitcoin-cli-sim-client
- bitcoin-cli-sim-server
- elements-cli-sim-client
- elements-cli-sim-server
- boltzcli-sim
- lightning-cli-sim
- lncli-sim
Expand Down
6 changes: 4 additions & 2 deletions aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ run_in_container() {
docker exec -it boltz-scripts bash -c "source /etc/profile.d/utils.sh && $(printf '%q ' "$@")"
}

alias bitcoin-cli-sim='run_in_container bitcoin-cli-sim -rpcwallet=client'
alias elements-cli-sim='run_in_container elements-cli-sim -rpcwallet=client'
alias bitcoin-cli-sim-client='run_in_container bitcoin-cli-sim-client'
alias bitcoin-cli-sim-server='run_in_container bitcoin-cli-sim-server'
alias elements-cli-sim-client='run_in_container elements-cli-sim-client'
alias elements-cli-sim-server='run_in_container elements-cli-sim-server'
alias boltzcli-sim='run_in_container boltzcli-sim'

lightning-cli-sim() {
Expand Down
63 changes: 38 additions & 25 deletions images/scripts/utils.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
#!/bin/bash
BITCOIN_CLI_PARAMS="-rpcconnect=bitcoind -regtest -rpccookiefile=/root/.bitcoin/regtest/.cookie"

function bitcoin-cli-sim() {
bitcoin-cli -rpcconnect=bitcoind -regtest -rpccookiefile=/root/.bitcoin/regtest/.cookie "$@"
bitcoin-cli $BITCOIN_CLI_PARAMS "$@"
}

function bitcoin-cli-sim-server() {
bitcoin-cli $BITCOIN_CLI_PARAMS -rpcwallet="regtest" "$@"
}

function bitcoin-cli-sim-client() {
bitcoin-cli $BITCOIN_CLI_PARAMS -rpcwallet="client" "$@"
}

ELEMENTS_CLI_PARAMS="-rpcconnect=elementsd"
function elements-cli-sim() {
elements-cli -rpcconnect=elementsd "$@"
elements-cli $ELEMENTS_CLI_PARAMS "$@"
}

function elements-cli-sim-server() {
elements-cli $ELEMENTS_CLI_PARAMS -rpcwallet="regtest" "$@"
}

function elements-cli-sim-client() {
elements-cli $ELEMENTS_CLI_PARAMS -rpcwallet="client" "$@"
}

boltzcli-sim() {
Expand All @@ -29,14 +48,14 @@ lncli-sim() {
fund_cln_node() {
address=$(lightning-cli-sim $1 newaddr | jq -r .bech32)
echo "funding: $address on cln-node: $1"
bitcoin-cli-sim -named sendtoaddress address=$address amount=30 fee_rate=100 > /dev/null
bitcoin-cli-sim-server -named sendtoaddress address=$address amount=30 fee_rate=1 > /dev/null
}

# args(i)
fund_lnd_node() {
address=$(lncli-sim $1 newaddress p2wkh | jq -r .address)
echo "funding: $address on lnd-node: $1"
bitcoin-cli-sim -named sendtoaddress address=$address amount=30 fee_rate=100 > /dev/null
bitcoin-cli-sim-server -named sendtoaddress address=$address amount=30 fee_rate=1 > /dev/null
}

# args(i, j)
Expand All @@ -49,7 +68,7 @@ bitcoind-init() {
# Wait until bitcoind is ready
while true; do
sleep 1
if bitcoin-cli-sim getblockchaininfo &> /dev/null; then
if bitcoin-cli-sim-server getblockchaininfo &> /dev/null; then
echo "bitcoind is ready"
break
else
Expand All @@ -59,7 +78,7 @@ bitcoind-init() {

bitcoin-cli-sim createwallet regtest || bitcoin-cli-sim loadwallet regtest
# Generate 150 blocks
bitcoin-cli-sim -generate 150
bitcoin-cli-sim-server -generate 150

if [ $? -eq 0 ]; then
echo "Successfully generated blocks"
Expand All @@ -69,9 +88,9 @@ bitcoind-init() {

bitcoin-cli-sim createwallet client || bitcoin-cli-sim loadwallet client

CLIENT_ADDRESS=$(bitcoin-cli-sim -rpcwallet=client getnewaddress "" bech32m)
bitcoin-cli-sim -rpcwallet=regtest sendtoaddress $CLIENT_ADDRESS 10
bitcoin-cli-sim -rpcwallet=regtest -generate 1
CLIENT_ADDRESS=$(bitcoin-cli-sim-client getnewaddress "" bech32m)
bitcoin-cli-sim-server -rpcwallet=regtest sendtoaddress $CLIENT_ADDRESS 10
bitcoin-cli-sim-server -rpcwallet=regtest -generate 1
}

regtest-start(){
Expand All @@ -82,20 +101,14 @@ regtest-start(){
elements-init(){
elements-cli-sim createwallet regtest || elements-cli-sim loadwallet regtest true
echo "mining 150 liquid blocks..."
elements-cli-sim -generate 150 > /dev/null
elements-cli-sim rescanblockchain 0 > /dev/null
elements-cli-sim-server -generate 150 > /dev/null
elements-cli-sim-server rescanblockchain 0 > /dev/null

elements-cli-sim createwallet client || elements-cli-sim loadwallet client true

CLIENT_ADDRESS=$(elements-cli-sim -rpcwallet=client getnewaddress)
elements-cli-sim -rpcwallet=regtest sendtoaddress $CLIENT_ADDRESS 10
elements-cli-sim -rpcwallet=regtest -generate 1
}

# TODO: currently not being used
boltz-client-init(){
boltzcli-sim wallet create lnbits LBTC
boltzcli-sim formatmacaroon
elements-cli-sim-server -rpcwallet=regtest sendtoaddress $CLIENT_ADDRESS 10
elements-cli-sim-server -rpcwallet=regtest -generate 1
}

regtest-init(){
Expand All @@ -121,7 +134,7 @@ lightning-init(){
done

echo "mining 3 blocks..."
bitcoin-cli-sim -generate 3 > /dev/null
bitcoin-cli-sim-server -generate 3 > /dev/null

lightning-sync

Expand All @@ -134,37 +147,37 @@ lightning-init(){
lncli-sim 1 connect $(lncli-sim 2 getinfo | jq -r '.identity_pubkey')@lnd-2 > /dev/null
echo "open channel from lnd-1 to lnd-2"
lncli-sim 1 openchannel $(lncli-sim 2 getinfo | jq -r '.identity_pubkey') $channel_size $balance_size > /dev/null
bitcoin-cli-sim -generate $channel_confirms > /dev/null
bitcoin-cli-sim-server -generate $channel_confirms > /dev/null
wait-for-lnd-channel 1

# lnd-1 -> cln-1
lncli-sim 1 connect $(lightning-cli-sim 1 getinfo | jq -r '.id')@cln-1 > /dev/null
echo "open channel from lnd-1 to cln-1"
lncli-sim 1 openchannel $(lightning-cli-sim 1 getinfo | jq -r '.id') $channel_size $balance_size > /dev/null
bitcoin-cli-sim -generate $channel_confirms > /dev/null
bitcoin-cli-sim-server -generate $channel_confirms > /dev/null
wait-for-lnd-channel 1

# lnd-2 -> cln-1
lncli-sim 2 connect $(lightning-cli-sim 1 getinfo | jq -r '.id')@cln-1 > /dev/null
echo "open channel from lnd-2 to cln-1"
lncli-sim 2 openchannel $(lightning-cli-sim 1 getinfo | jq -r '.id') $channel_size $balance_size > /dev/null
bitcoin-cli-sim -generate $channel_confirms > /dev/null
bitcoin-cli-sim-server -generate $channel_confirms > /dev/null
wait-for-lnd-channel 2
wait-for-cln-channel 1

# lnd-1 -> cln-2
lncli-sim 1 connect $(lightning-cli-sim 2 getinfo | jq -r '.id')@cln-2 > /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
bitcoin-cli-sim-server -generate $channel_confirms > /dev/null
wait-for-lnd-channel 1
wait-for-cln-channel 2

# lnd-2 -> cln-2
lncli-sim 2 connect $(lightning-cli-sim 2 getinfo | jq -r '.id')@cln-2 > /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
bitcoin-cli-sim-server -generate $channel_confirms > /dev/null
wait-for-lnd-channel 2
wait-for-cln-channel 2

Expand Down

0 comments on commit 1572ad1

Please sign in to comment.