Skip to content

Commit

Permalink
startup_regtest: configure clnrest and generate rune
Browse files Browse the repository at this point in the history
This allows use of clnrest + websocket in the regtest environment.
Also uses the snap installed bitcoind path if appropriate.

Format of the start_ln output is:
Commands:
	l1-cli, l1-log,
	l2-cli, l2-log,
	bt-cli, stop_ln, fund_nodes
Node Info:
	l1 rest: https://127.0.0.1:3110  rune: "lgkWSp0PQK-pkbElLpjcNVQnX7yfEjouJaJHjLuW8w89OA=="
	l2 rest: https://127.0.0.1:3111  rune: "sUqGqkevGYG2r1e_JUiz8Me00GhtTv5-IuGk4o9Beyc9OQ=="

Changelog-None
  • Loading branch information
endothermicdev committed Nov 10, 2023
1 parent 02ca226 commit 0a58aa6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion contrib/startup_regtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ else
fi

if [ -z "$PATH_TO_BITCOIN" ]; then
if [ -d "$HOME/.bitcoin" ]; then
if [ -d "$HOME/snap/bitcoin-core/common/.bitcoin" ]; then
PATH_TO_BITCOIN="$HOME/snap/bitcoin-core/common/.bitcoin"
elif [ -d "$HOME/.bitcoin" ]; then
PATH_TO_BITCOIN="$HOME/.bitcoin"
elif [ -d "$HOME/Library/Application Support/Bitcoin/" ]; then
PATH_TO_BITCOIN="$HOME/Library/Application Support/Bitcoin/"
Expand Down Expand Up @@ -92,6 +94,7 @@ start_nodes() {
log-file=/tmp/l$i-$network/log
addr=localhost:$socket
allow-deprecated-apis=false
rest-port=$((3109+i))
EOF

# If we've configured to use developer, add dev options
Expand Down Expand Up @@ -127,8 +130,10 @@ start_nodes() {
if [ -z "$EATMYDATA" ]; then
echo "WARNING: eatmydata not found: install it for faster testing"
fi
sleep 2
# Give a hint.
echo "Commands: "

for i in $(seq "$node_count"); do
echo " l$i-cli, l$i-log,"
done
Expand Down Expand Up @@ -169,6 +174,7 @@ start_ln() {
fi
start_nodes "$nodes" regtest
echo " bt-cli, stop_ln, fund_nodes"
node_info regtest
}

ensure_bitcoind_funds() {
Expand Down Expand Up @@ -292,6 +298,17 @@ stop_ln() {
unalias bt-cli
}

node_info() {
network=${1:-regtest}
if [ -n "$LN_NODES" ]; then
echo "Node Info:"
for i in $(seq "$LN_NODES"); do
echo " l$i rest: https://127.0.0.1:$((3109 + i))"\
" rune: $($LCLI --lightning-dir=/tmp/l"$i-$network" createrune | jq .rune)"
done
fi
}

destroy_ln() {
network=${1:-regtest}
rm -rf /tmp/l[0-9]*-"$network"
Expand Down

0 comments on commit 0a58aa6

Please sign in to comment.