Skip to content

Commit

Permalink
startup_regtest: test for clnrest dependencies before writing config
Browse files Browse the repository at this point in the history
  • Loading branch information
endothermicdev committed Nov 15, 2023
1 parent 1dfccbb commit e1ee2bd
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions contrib/startup_regtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ if [ -z "$PATH_TO_BITCOIN" ]; then
fi

wait_for_lightningd() {
if [ -z "$1" ]; then
node_count=2
else
node_count=$1
fi
for i in $(seq "5"); do
if $LCLI --lightning-dir=/tmp/l1-"$network" getinfo > /dev/null 2>&1; then
if $LCLI --lightning-dir=/tmp/l"$node_count"-"$network" getinfo > /dev/null 2>&1; then
break
else
sleep 1
Expand Down Expand Up @@ -118,7 +123,6 @@ start_nodes() {
log-file=/tmp/l$i-$network/log
addr=localhost:$socket
allow-deprecated-apis=false
clnrest-port=$((3109+i))
EOF

# If we've configured to use developer, add dev options
Expand All @@ -141,6 +145,10 @@ start_nodes() {
EOF
fi

# If clnrest loads, add the port so it will run
if [ -n "$ACTIVATE_CLNREST" ]; then
echo "clnrest-port=$((3109+i))" >> "/tmp/l$i-$network/config"
fi

# Start the lightning nodes
test -f "/tmp/l$i-$network/lightningd-$network.pid" || \
Expand Down Expand Up @@ -195,17 +203,19 @@ start_ln() {
else
nodes="$1"
fi
# Are the clnrest dependencies installed?
if timeout 2 python3 plugins/clnrest/clnrest.py > /dev/null 2>&1; then
ACTIVATE_CLNREST=1
fi
start_nodes "$nodes" regtest
echo " bt-cli, stop_ln, fund_nodes"
wait_for_lightningd
wait_for_lightningd "$nodes"
active_status=$(clnrest_status "/tmp/l$i-$network/log")
if [ "$active_status" = "active" ] ; then
if [ -n "$ACTIVATE_CLNREST" ] && [ "$active_status" = "active" ] ; then
node_info regtest
elif [ "$active_status" = "disabled" ]; then
echo "clnrest is disabled. Try installing python developer dependencies"
echo "with 'poetry install'"
else
echo "timed out parsing log /tmp/l$i-$network/log"
fi
}

Expand Down

0 comments on commit e1ee2bd

Please sign in to comment.