forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devtools: Add fund_ln command to startup_regtest.sh
fund_ln connects the two peers and funds a channel between them.
- Loading branch information
Showing
1 changed file
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,8 +134,11 @@ start_ln() { | |
# Kick it out of initialblockdownload if necessary | ||
if bitcoin-cli -regtest getblockchaininfo | grep -q 'initialblockdownload.*true'; then | ||
# Modern bitcoind needs createwallet | ||
echo "Making \"default\" bitcoind wallet." | ||
This comment has been minimized.
Sorry, something went wrong. |
||
bitcoin-cli -regtest createwallet default >/dev/null 2>&1 | ||
bitcoin-cli -regtest generatetoaddress 1 "$(bitcoin-cli -regtest getnewaddress)" > /dev/null | ||
else | ||
bitcoin-cli -regtest loadwallet default | ||
fi | ||
alias bt-cli='bitcoin-cli -regtest' | ||
|
||
|
@@ -145,7 +148,44 @@ start_ln() { | |
nodes="$1" | ||
fi | ||
start_nodes "$nodes" regtest | ||
echo " bt-cli, stop_ln" | ||
echo " bt-cli, stop_ln, fund_ln" | ||
} | ||
|
||
fund_ln() { | ||
This comment has been minimized.
Sorry, something went wrong.
niftynei
|
||
|
||
ADDRESS=`bitcoin-cli -regtest getnewaddress` | ||
bitcoin-cli -regtest generatetoaddress 50 $ADDRESS | ||
|
||
echo $ADDRESS | ||
bitcoin-cli -regtest getbalance | ||
|
||
L2_NODE_ID=`$LCLI --lightning-dir=/tmp/l2-regtest getinfo | jq -r .id` | ||
L2_NODE_PORT=`$LCLI --lightning-dir=/tmp/l2-regtest getinfo | jq .binding[0].port` | ||
|
||
echo "Node 2 id/port is : $L2_NODE_ID:$L2_NODE_PORT" | ||
|
||
$LCLI --lightning-dir=/tmp/l1-regtest connect $L2_NODE_ID@localhost:$L2_NODE_PORT | ||
|
||
$LCLI --lightning-dir=/tmp/l1-regtest listpeers | ||
|
||
L1_WALLET_ADDR=`$LCLI --lightning-dir=/tmp/l1-regtest newaddr | jq -r .bech32` | ||
|
||
echo bitcoin-cli -regtest sendtoaddress $L1_WALLET_ADDR 1000 | ||
|
||
bitcoin-cli -regtest sendtoaddress $L1_WALLET_ADDR 1000 | ||
|
||
bitcoin-cli -regtest generatetoaddress 6 $ADDRESS | ||
|
||
$LCLI --lightning-dir=/tmp/l1-regtest listfunds | ||
|
||
L_CHANNEL_ID=`$LCLI --lightning-dir=/tmp/l1-regtest fundchannel $L2_NODE_ID 1000000 | jq -r .channel_id` | ||
|
||
echo channel id is: $L_CHANNEL_ID | ||
|
||
bitcoin-cli -regtest generatetoaddress 12 $ADDRESS | ||
|
||
$LCLI --lightning-dir=/tmp/l1-regtest listchannels | ||
$LCLI --lightning-dir=/tmp/l2-regtest listchannels | ||
} | ||
|
||
stop_nodes() { | ||
|
👍