diff --git a/contrib/startup_regtest.sh b/contrib/startup_regtest.sh index ddf6e33fb1b4..9213a2dafe85 100755 --- a/contrib/startup_regtest.sh +++ b/contrib/startup_regtest.sh @@ -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 @@ -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 @@ -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" || \ @@ -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 }