@@ -651,6 +651,40 @@ pub enum Balance {
651
651
} ,
652
652
}
653
653
654
+ impl Balance {
655
+ /// The amount claimable, in satoshis. This excludes balances that we are unsure if we are able
656
+ /// to claim, this is because we are waiting for a preimage or for a timeout to expire. For more
657
+ /// information on these balances see [`Balance::MaybeTimeoutClaimableHTLC`] and
658
+ /// [`Balance::MaybePreimageClaimableHTLC`].
659
+ ///
660
+ /// On-chain fees required to claim the balance are not included in this amount.
661
+ pub fn claimable_amount_satoshis ( & self ) -> u64 {
662
+ match self {
663
+ Balance :: ClaimableOnChannelClose {
664
+ claimable_amount_satoshis,
665
+ } => * claimable_amount_satoshis,
666
+ Balance :: ClaimableAwaitingConfirmations {
667
+ claimable_amount_satoshis,
668
+ ..
669
+ } => * claimable_amount_satoshis,
670
+ Balance :: ContentiousClaimable {
671
+ claimable_amount_satoshis,
672
+ ..
673
+ } => * claimable_amount_satoshis,
674
+ Balance :: MaybeTimeoutClaimableHTLC {
675
+ ..
676
+ } => 0 ,
677
+ Balance :: MaybePreimageClaimableHTLC {
678
+ ..
679
+ } => 0 ,
680
+ Balance :: CounterpartyRevokedOutputClaimable {
681
+ claimable_amount_satoshis,
682
+ ..
683
+ } => * claimable_amount_satoshis,
684
+ }
685
+ }
686
+ }
687
+
654
688
/// An HTLC which has been irrevocably resolved on-chain, and has reached ANTI_REORG_DELAY.
655
689
#[ derive( PartialEq , Eq ) ]
656
690
struct IrrevocablyResolvedHTLC {
0 commit comments