onchaind: fix reversed CSV delays.

Our config -> their CSV delay, their config -> our CSV delay.

Fixes: #395
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-12-04 12:39:04 +10:30 committed by Christian Decker
parent af5dbbc9f8
commit 5444084625
2 changed files with 11 additions and 4 deletions

View File

@ -1409,8 +1409,14 @@ static enum watch_result funding_spent(struct peer *peer,
peer->funding_satoshi,
&peer->channel_info->old_remote_per_commit,
&peer->channel_info->remote_per_commit,
peer->our_config.to_self_delay,
/* BOLT #2:
* `to_self_delay` is the number of blocks
* that the other nodes to-self outputs
* must be delayed */
/* So, these are reversed: they specify ours,
* we specify theirs. */
peer->channel_info->their_config.to_self_delay,
peer->our_config.to_self_delay,
get_feerate(peer->ld->topology,
FEERATE_NORMAL),
peer->our_config.dust_limit_satoshis,

View File

@ -791,7 +791,8 @@ class LightningDTests(BaseLightningDTests):
# HTLC 1->2, 1 fails just after funding.
disconnects = ['+WIRE_FUNDING_LOCKED', 'permfail']
l1 = self.node_factory.get_node(disconnect=disconnects)
l2 = self.node_factory.get_node()
# Make locktime different, as we once had them reversed!
l2 = self.node_factory.get_node(options=['--locktime-blocks=10'])
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])
@ -814,8 +815,8 @@ class LightningDTests(BaseLightningDTests):
l1.daemon.wait_for_log('-> ONCHAIND_OUR_UNILATERAL')
l2.daemon.wait_for_log('-> ONCHAIND_THEIR_UNILATERAL')
# 6 later, l1 should collect its to-self payment.
bitcoind.generate_block(6)
# 10 later, l1 should collect its to-self payment.
bitcoind.generate_block(10)
l1.daemon.wait_for_log('Broadcasting OUR_DELAYED_RETURN_TO_WALLET .* to resolve OUR_UNILATERAL/DELAYED_OUTPUT_TO_US')
l1.daemon.wait_for_log('sendrawtx exit 0')