Skip to content

Commit

Permalink
Add helper for getting claimable balance
Browse files Browse the repository at this point in the history
It is annoying to have to match across all the enums of `Balance` to
just pull out the `claimable_amount_satoshis` value. This helper makes
it easier if you just want to amount.
  • Loading branch information
benthecarman committed Jun 2, 2023
1 parent fb140b5 commit 5cc662b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,36 @@ pub enum Balance {
},
}

impl Balance {
pub fn claimable_amount_satoshis(&self) -> u64 {
match self {
Balance::ClaimableOnChannelClose {
claimable_amount_satoshis,
} => *claimable_amount_satoshis,
Balance::ClaimableAwaitingConfirmations {
claimable_amount_satoshis,
..
} => *claimable_amount_satoshis,
Balance::ContentiousClaimable {
claimable_amount_satoshis,
..
} => *claimable_amount_satoshis,
Balance::MaybeTimeoutClaimableHTLC {
claimable_amount_satoshis,
..
} => *claimable_amount_satoshis,
Balance::MaybePreimageClaimableHTLC {
claimable_amount_satoshis,
..
} => *claimable_amount_satoshis,
Balance::CounterpartyRevokedOutputClaimable {
claimable_amount_satoshis,
..
} => *claimable_amount_satoshis,
}
}
}

/// An HTLC which has been irrevocably resolved on-chain, and has reached ANTI_REORG_DELAY.
#[derive(PartialEq, Eq)]
struct IrrevocablyResolvedHTLC {
Expand Down

0 comments on commit 5cc662b

Please sign in to comment.