Skip to content

Commit accbb97

Browse files
joostjagerclaude
andcommitted
chanmon_consistency: handle claimed payments that lose timeout race
When an HTLC timeout on-chain beats the receiver's claim, the sender gets ProbeFailed/PaymentFailed instead of PaymentSent. The receiver still saw PaymentClaimable and called claim_funds, so the payment hash was added to claimed_payment_hashes. The end-of-run assertion then fails because it expects every claimed payment to have a corresponding PaymentSent at the sender. Fix this by removing the payment hash from claimed_payment_hashes when we see HTLCHandlingFailed with a Receive failure type, which indicates the claim did not succeed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 593ca88 commit accbb97

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

fuzz/src/chanmon_consistency.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use bitcoin::opcodes;
2626
use bitcoin::script::{Builder, ScriptBuf};
2727
use bitcoin::transaction::Version;
2828
use bitcoin::transaction::{Transaction, TxOut};
29-
use bitcoin::OutPoint as BitcoinOutPoint;
3029
use bitcoin::FeeRate;
30+
use bitcoin::OutPoint as BitcoinOutPoint;
3131

3232
use bitcoin::block::Header;
3333
use bitcoin::hash_types::{BlockHash, Txid};
@@ -2007,6 +2007,16 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(
20072007
events::Event::PaymentPathFailed { .. } => {},
20082008
events::Event::PaymentForwarded { .. } if $node == 1 => {},
20092009
events::Event::ChannelReady { .. } => {},
2010+
events::Event::HTLCHandlingFailed {
2011+
failure_type: events::HTLCHandlingFailureType::Receive { payment_hash },
2012+
..
2013+
} => {
2014+
// The receiver failed to handle this HTLC (e.g., HTLC
2015+
// timeout won the race against the claim). Remove it from
2016+
// claimed hashes so we don't assert that the sender must
2017+
// have received PaymentSent.
2018+
claimed_payment_hashes.borrow_mut().remove(&payment_hash);
2019+
},
20102020
events::Event::HTLCHandlingFailed { .. } => {},
20112021

20122022
events::Event::FundingTransactionReadyForSigning {

0 commit comments

Comments
 (0)