Browse Source

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>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
5444084625
  1. 8
      lightningd/peer_control.c
  2. 7
      tests/test_lightningd.py

8
lightningd/peer_control.c

@ -1409,8 +1409,14 @@ static enum watch_result funding_spent(struct peer *peer,
peer->funding_satoshi, peer->funding_satoshi,
&peer->channel_info->old_remote_per_commit, &peer->channel_info->old_remote_per_commit,
&peer->channel_info->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->channel_info->their_config.to_self_delay,
peer->our_config.to_self_delay,
get_feerate(peer->ld->topology, get_feerate(peer->ld->topology,
FEERATE_NORMAL), FEERATE_NORMAL),
peer->our_config.dust_limit_satoshis, peer->our_config.dust_limit_satoshis,

7
tests/test_lightningd.py

@ -791,7 +791,8 @@ class LightningDTests(BaseLightningDTests):
# HTLC 1->2, 1 fails just after funding. # HTLC 1->2, 1 fails just after funding.
disconnects = ['+WIRE_FUNDING_LOCKED', 'permfail'] disconnects = ['+WIRE_FUNDING_LOCKED', 'permfail']
l1 = self.node_factory.get_node(disconnect=disconnects) 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']) 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') l1.daemon.wait_for_log('-> ONCHAIND_OUR_UNILATERAL')
l2.daemon.wait_for_log('-> ONCHAIND_THEIR_UNILATERAL') l2.daemon.wait_for_log('-> ONCHAIND_THEIR_UNILATERAL')
# 6 later, l1 should collect its to-self payment. # 10 later, l1 should collect its to-self payment.
bitcoind.generate_block(6) 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('Broadcasting OUR_DELAYED_RETURN_TO_WALLET .* to resolve OUR_UNILATERAL/DELAYED_OUTPUT_TO_US')
l1.daemon.wait_for_log('sendrawtx exit 0') l1.daemon.wait_for_log('sendrawtx exit 0')

Loading…
Cancel
Save