You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.1 KiB
87 lines
2.1 KiB
#! /bin/sh -e
|
|
|
|
# Wherever we are, we want to be in daemon/test dir.
|
|
cd `git rev-parse --show-toplevel`/daemon/test
|
|
|
|
. scripts/vars.sh
|
|
. scripts/helpers.sh
|
|
|
|
parse_cmdline 2 "$@"
|
|
setup_lightning 2
|
|
start_lightningd 2
|
|
fund_lightningd
|
|
|
|
lcli1 connect localhost $PORT2 $FUND_INPUT_TX &
|
|
|
|
# Now make it pass anchor (should be in mempool: one block to bury it)
|
|
check_tx_spend
|
|
$CLI generate 1
|
|
|
|
DO_RECONNECT=$RECONNECT
|
|
|
|
check_peerstate lcli1 STATE_NORMAL
|
|
check_peerstate lcli2 STATE_NORMAL
|
|
|
|
# Make sure node2 doesn't fail
|
|
lcli2 dev-routefail false
|
|
|
|
A_AMOUNT=$(($AMOUNT - $NO_HTLCS_FEE))
|
|
A_FEE=$NO_HTLCS_FEE
|
|
B_AMOUNT=0
|
|
B_FEE=0
|
|
|
|
# This is 10,000 satoshi, so not dust!
|
|
HTLC_AMOUNT=10000000
|
|
|
|
EXPIRY=$(( $(blockheight) + 10))
|
|
SECRET=1de08917a61cb2b62ed5937d38577f6a7bfe59c176781c6d8128018e8b5ccdfd
|
|
RHASH=`lcli1 dev-rhash $SECRET | sed 's/.*"\([0-9a-f]*\)".*/\1/'`
|
|
|
|
HTLCID=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id`
|
|
|
|
A_AMOUNT=$(($A_AMOUNT - $EXTRA_FEE - $HTLC_AMOUNT))
|
|
A_FEE=$(($A_FEE + $EXTRA_FEE))
|
|
B_AMOUNT=0
|
|
B_FEE=0
|
|
|
|
# Wait for both to committed.
|
|
check_status $A_AMOUNT $A_FEE "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : SENT_ADD_ACK_REVOCATION } " $B_AMOUNT $B_FEE ""
|
|
|
|
# make node1 disconnect with node2.
|
|
lcli1 dev-disconnect $ID2
|
|
check_peerconnected lcli1 false
|
|
|
|
# lcli1 should have sent out commitment tx
|
|
check_peerstate lcli1 STATE_ERR_BREAKDOWN
|
|
check_tx_spend
|
|
|
|
# Mine it.
|
|
$CLI generate 1
|
|
check_peerstate lcli1 STATE_CLOSE_ONCHAIN_OUR_UNILATERAL
|
|
check_peerstate lcli2 STATE_CLOSE_ONCHAIN_THEIR_UNILATERAL
|
|
|
|
# both still know about htlc
|
|
check_status $A_AMOUNT $A_FEE "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : SENT_ADD_ACK_REVOCATION } " $B_AMOUNT $B_FEE ""
|
|
|
|
# Generate 6 blocks so CSV timeout has expired.
|
|
$CLI generate 6
|
|
|
|
# Now, lcli1 should spend its own output.
|
|
check_tx_spend
|
|
check_peerstate lcli1 STATE_CLOSE_ONCHAIN_OUR_UNILATERAL
|
|
|
|
while [ $(blockheight) != $EXPIRY ]; do
|
|
$CLI generate 1
|
|
done
|
|
|
|
# lcli1 should have gotten HTLC back.
|
|
check_tx_spend
|
|
|
|
# Now, after "forever" blocks, should all be concluded.
|
|
$CLI generate 10
|
|
|
|
# Both consider it all done now.
|
|
check_no_peers lcli1
|
|
|
|
lcli1 stop
|
|
all_ok
|
|
|