Skip to content

Commit

Permalink
temp: debug
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Dec 18, 2023
1 parent 40f60ef commit 657c9a6
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions dev/bin/init-lightning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ retry() {
false
}

run_with_lnd() {
local func_name="$1"
shift # This will shift away the function name, so $1 becomes the next argument

if [[ "$func_name" == "lnd_cli" ]]; then
lnd_cli "$@"
elif [[ "$func_name" == "lnd_outside_cli" ]]; then
lnd_outside_cli "$@"
else
echo "Invalid function name passed!" && return 1
fi
}

lnd_is_ready() {
run_with_lnd "$1" getinfo
return "$?"
}


mempool_not_empty() {
echo "Waiting for txn to show up in mempool..."
local txid="$(bitcoin_cli getrawmempool | jq -r ".[0]")"
Expand Down Expand Up @@ -66,9 +85,11 @@ echo "Funded with txid: ${funded_txid}"

# Open channel from lndoutside1 -> lnd1
echo "Opening channel: lndoutside1 -> lnd1..."
retry 30 1 lnd_is_ready lnd_cli
pubkey_lnd1="$(lnd_cli getinfo | jq -r '.identity_pubkey')"
endpoint_lnd1="${COMPOSE_PROJECT_NAME}-lnd1-1:9735"
lnd_outside_cli connect "${pubkey_lnd1}@${endpoint_lnd1}" > /dev/null 2>&1 || true
echo "CONNECTING 1..."
lnd_outside_cli connect "${pubkey_lnd1}@${endpoint_lnd1}" || true
retry 30 1 synced_to_graph
funding_txid=$(lnd_outside_cli openchannel \
--node_key "$pubkey_lnd1" \
Expand All @@ -89,7 +110,8 @@ echo "Channel ${funding_txid} confirmed"
echo "Opening balanced channel: lndoutside1 -> lndoutside2..."
pubkey_lnd_outside_2="$(lnd_outside_2_cli getinfo | jq -r '.identity_pubkey')"
endpoint_lnd_outside_2="${COMPOSE_PROJECT_NAME}-lnd-outside-2-1:9735"
lnd_outside_cli connect "${pubkey_lnd_outside_2}@${endpoint_lnd_outside_2}" > /dev/null 2>&1 || true
echo "CONNECTING 2..."
lnd_outside_cli connect "${pubkey_lnd_outside_2}@${endpoint_lnd_outside_2}" || true
retry 30 1 synced_to_graph
funding_txid=$(lnd_outside_cli openchannel \
--node_key "$pubkey_lnd_outside_2" \
Expand Down

0 comments on commit 657c9a6

Please sign in to comment.