@@ -583,14 +583,25 @@ pub enum Balance {
583
583
/// HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain
584
584
/// fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat
585
585
/// 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.
589
589
claimable_amount_satoshis : u64 ,
590
590
/// The height at which we will be able to claim the balance if our counterparty has not
591
591
/// done so.
592
592
claimable_height : u32 ,
593
593
} ,
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
+ } ,
594
605
/// The channel has been closed, and our counterparty broadcasted a revoked commitment
595
606
/// transaction.
596
607
///
@@ -1547,7 +1558,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1547
1558
confirmation_height : conf_thresh,
1548
1559
} ) ;
1549
1560
} else {
1550
- return Some ( Balance :: MaybeClaimableHTLCAwaitingTimeout {
1561
+ return Some ( Balance :: MaybeTimeoutClaimableHTLC {
1551
1562
claimable_amount_satoshis : htlc. amount_msat / 1000 ,
1552
1563
claimable_height : htlc. cltv_expiry ,
1553
1564
} ) ;
@@ -1570,6 +1581,11 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1570
1581
timeout_height : htlc. cltv_expiry ,
1571
1582
} ) ;
1572
1583
}
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
+ } ) ;
1573
1589
}
1574
1590
None
1575
1591
}
@@ -1727,12 +1743,19 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1727
1743
for ( htlc, _, _) in us. current_holder_commitment_tx . htlc_outputs . iter ( ) {
1728
1744
if htlc. transaction_output_index . is_none ( ) { continue ; }
1729
1745
if htlc. offered {
1730
- res. push ( Balance :: MaybeClaimableHTLCAwaitingTimeout {
1746
+ res. push ( Balance :: MaybeTimeoutClaimableHTLC {
1731
1747
claimable_amount_satoshis : htlc. amount_msat / 1000 ,
1732
1748
claimable_height : htlc. cltv_expiry ,
1733
1749
} ) ;
1734
1750
} else if us. payment_preimages . get ( & htlc. payment_hash ) . is_some ( ) {
1735
1751
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
+ } ) ;
1736
1759
}
1737
1760
}
1738
1761
res. push ( Balance :: ClaimableOnChannelClose {
0 commit comments