diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 59e34dfa8..66db12e5f 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -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, diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 50515648e..75b5e4cd8 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -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')