mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
onchaind: fix all_irrevocably_resolved test.
I was examining a test_onchain_timeout failure, and realized that we were forgetting a peer even though we'd just spent the HTLC_TIMEOUT_TX! This reveals that we weren't resolving an output when we stole the preimage from it, like we should. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
05a3db886b
commit
824f8517ac
@@ -496,7 +496,7 @@ static bool all_irrevocably_resolved(struct tracked_output **outs)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < tal_count(outs); i++) {
|
for (i = 0; i < tal_count(outs); i++) {
|
||||||
if (outs[i]->resolved && outs[i]->resolved->depth < 100)
|
if (!outs[i]->resolved || outs[i]->resolved->depth < 100)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -721,6 +721,17 @@ static void output_spent(struct tracked_output ***outs,
|
|||||||
handle_htlc_onchain_fulfill(out, tx);
|
handle_htlc_onchain_fulfill(out, tx);
|
||||||
if (out->tx_type == THEIR_REVOKED_UNILATERAL)
|
if (out->tx_type == THEIR_REVOKED_UNILATERAL)
|
||||||
steal_htlc_tx(out);
|
steal_htlc_tx(out);
|
||||||
|
else {
|
||||||
|
/* BOLT #5:
|
||||||
|
*
|
||||||
|
* If the HTLC output is spent using the
|
||||||
|
* payment preimage, the HTLC output is
|
||||||
|
* considered *irrevocably resolved*, and the
|
||||||
|
* node MUST extract the payment preimage from
|
||||||
|
* the transaction input witness.
|
||||||
|
*/
|
||||||
|
ignore_output(out);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FUNDING_OUTPUT:
|
case FUNDING_OUTPUT:
|
||||||
|
|||||||
@@ -960,12 +960,19 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
|
|
||||||
l1.daemon.wait_for_log('WIRE_PERMANENT_CHANNEL_FAILURE: timed out')
|
l1.daemon.wait_for_log('WIRE_PERMANENT_CHANNEL_FAILURE: timed out')
|
||||||
|
|
||||||
# 91 later, l2 is done.
|
# 2 later, l1 spends HTLC (5 blocks total).
|
||||||
bitcoind.generate_block(91)
|
bitcoind.generate_block(2)
|
||||||
|
l1.daemon.wait_for_log('Broadcasting OUR_DELAYED_RETURN_TO_WALLET .* to resolve OUR_HTLC_TIMEOUT_TX/DELAYED_OUTPUT_TO_US')
|
||||||
|
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
|
|
||||||
|
# 89 later, l2 is done.
|
||||||
|
bitcoind.generate_block(89)
|
||||||
l2.daemon.wait_for_log('onchaind complete, forgetting peer')
|
l2.daemon.wait_for_log('onchaind complete, forgetting peer')
|
||||||
|
|
||||||
# Now, 100 blocks and l1 should be done.
|
# Now, 100 blocks and l1 should be done.
|
||||||
bitcoind.generate_block(6)
|
bitcoind.generate_block(10)
|
||||||
|
assert not l1.daemon.is_in_log('onchaind complete, forgetting peer')
|
||||||
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log('onchaind complete, forgetting peer')
|
l1.daemon.wait_for_log('onchaind complete, forgetting peer')
|
||||||
|
|
||||||
# Payment failed, BTW
|
# Payment failed, BTW
|
||||||
|
|||||||
Reference in New Issue
Block a user