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.
 
 
 
 
 
 

86 lines
2.8 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
# Simply override default fee (estimatefee fails on regtest anyway)
DEFAULT_FEE_RATE2=50000
# We use 5x fee rate for commits, by defailt.
FEE_RATE2=$(($DEFAULT_FEE_RATE2 * 5))
echo "default-fee-rate=$DEFAULT_FEE_RATE2" >> $DIR2/config
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
# Asymmetry, since fee rates different.
NO_HTLCS_FEE2=$((338 * $FEE_RATE2 / 2000 * 2000))
ONE_HTLCS_FEE2=$(( (338 + 32) * $FEE_RATE2 / 2000 * 2000))
A_AMOUNT1=$(($AMOUNT - $NO_HTLCS_FEE))
A_FEE1=$NO_HTLCS_FEE
A_AMOUNT2=$(($AMOUNT - $NO_HTLCS_FEE2))
A_FEE2=$NO_HTLCS_FEE2
B_AMOUNT=0
B_FEE=0
check_status_single lcli1 $A_AMOUNT1 $A_FEE1 "" $B_AMOUNT $B_FEE ""
check_status_single lcli2 $B_AMOUNT $B_FEE "" $(($A_AMOUNT2)) $(($A_FEE2)) ""
# This is 100,000 satoshi, so covers fees.
HTLC_AMOUNT=100000000
RHASH=`lcli2 invoice $HTLC_AMOUNT RHASH3 | sed 's/.*"\([0-9a-f]*\)".*/\1/'`
ROUTE=`lcli1 getroute $ID2 $HTLC_AMOUNT 1`
ROUTE=`echo $ROUTE | sed 's/^{ "route" : \(.*\) }$/\1/'`
lcli1 sendpay "$ROUTE" $RHASH
# They should not split fees.
check_status_single lcli1 $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) "" $(($HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) ""
check_status_single lcli2 $(($HTLC_AMOUNT - $NO_HTLCS_FEE2 / 2)) $(($NO_HTLCS_FEE2 / 2)) "" $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE2 / 2)) $(($NO_HTLCS_FEE2 / 2)) ""
# FIXME: reactivate feechanges!
# # Change fee rate on node2 to same as node1.
# lcli2 dev-feerate 40000
# $CLI generate 1
# [ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1
# [ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2
# check_status $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) "" $(($HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) ""
# # Change back.
# lcli2 dev-feerate 50000
# $CLI generate 1
# [ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1
# [ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2
# check_status_single lcli1 $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) "" $(($HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) ""
# check_status_single lcli2 $(($HTLC_AMOUNT - $NO_HTLCS_FEE2 / 2)) $(($NO_HTLCS_FEE2 / 2)) "" $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE2 / 2)) $(($NO_HTLCS_FEE2 / 2)) ""
lcli1 close $ID2
check_tx_spend
# Give it 10 blocks ie "forever"
$CLI generate 10
check_no_peers lcli1
check_no_peers lcli2
lcli1 stop
lcli2 stop
all_ok