@@ -651,6 +651,40 @@ pub enum Balance {
651651 } ,
652652}
653653
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+
654688/// An HTLC which has been irrevocably resolved on-chain, and has reached ANTI_REORG_DELAY.
655689#[ derive( PartialEq , Eq ) ]
656690struct IrrevocablyResolvedHTLC {
0 commit comments