@@ -583,14 +583,25 @@ pub enum Balance {
583583 /// HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain
584584 /// fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat
585585 /// likely to be claimed by our counterparty before we do.
586- MaybeClaimableHTLCAwaitingTimeout {
587- /// The amount available to claim, in satoshis, excluding the on-chain fees which will be
588- /// required to do so.
586+ MaybeTimeoutClaimableHTLC {
587+ /// The amount potentially available to claim, in satoshis, excluding the on-chain fees
588+ /// which will be required to do so.
589589 claimable_amount_satoshis : u64 ,
590590 /// The height at which we will be able to claim the balance if our counterparty has not
591591 /// done so.
592592 claimable_height : u32 ,
593593 } ,
594+ /// HTLCs which we received from our counterparty which are claimable with a preimage which we
595+ /// do not currently have. This will only be claimable if we receive the preimage from the node
596+ /// to which we forwarded this HTLC before the timeout.
597+ MaybePreimageClaimableHTLC {
598+ /// The amount potentially available to claim, in satoshis, excluding the on-chain fees
599+ /// which will be required to do so.
600+ claimable_amount_satoshis : u64 ,
601+ /// The height at which our counterparty will be able to claim the balance if we have not
602+ /// yet received the preimage and claimed it ourselves.
603+ expiry_height : u32 ,
604+ } ,
594605 /// The channel has been closed, and our counterparty broadcasted a revoked commitment
595606 /// transaction.
596607 ///
@@ -1547,7 +1558,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
15471558 confirmation_height : conf_thresh,
15481559 } ) ;
15491560 } else {
1550- return Some ( Balance :: MaybeClaimableHTLCAwaitingTimeout {
1561+ return Some ( Balance :: MaybeTimeoutClaimableHTLC {
15511562 claimable_amount_satoshis : htlc. amount_msat / 1000 ,
15521563 claimable_height : htlc. cltv_expiry ,
15531564 } ) ;
@@ -1570,6 +1581,11 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
15701581 timeout_height : htlc. cltv_expiry ,
15711582 } ) ;
15721583 }
1584+ } else if htlc_resolved. is_none ( ) {
1585+ return Some ( Balance :: MaybePreimageClaimableHTLC {
1586+ claimable_amount_satoshis : htlc. amount_msat / 1000 ,
1587+ expiry_height : htlc. cltv_expiry ,
1588+ } ) ;
15731589 }
15741590 None
15751591 }
@@ -1727,12 +1743,19 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
17271743 for ( htlc, _, _) in us. current_holder_commitment_tx . htlc_outputs . iter ( ) {
17281744 if htlc. transaction_output_index . is_none ( ) { continue ; }
17291745 if htlc. offered {
1730- res. push ( Balance :: MaybeClaimableHTLCAwaitingTimeout {
1746+ res. push ( Balance :: MaybeTimeoutClaimableHTLC {
17311747 claimable_amount_satoshis : htlc. amount_msat / 1000 ,
17321748 claimable_height : htlc. cltv_expiry ,
17331749 } ) ;
17341750 } else if us. payment_preimages . get ( & htlc. payment_hash ) . is_some ( ) {
17351751 claimable_inbound_htlc_value_sat += htlc. amount_msat / 1000 ;
1752+ } else {
1753+ // As long as the HTLC is still in our latest commitment state, treat
1754+ // it as potentially claimable, even if it has long-since expired.
1755+ res. push ( Balance :: MaybePreimageClaimableHTLC {
1756+ claimable_amount_satoshis : htlc. amount_msat / 1000 ,
1757+ expiry_height : htlc. cltv_expiry ,
1758+ } ) ;
17361759 }
17371760 }
17381761 res. push ( Balance :: ClaimableOnChannelClose {
0 commit comments