@@ -990,24 +990,29 @@ impl Balance {
990990 /// [`Balance::MaybePreimageClaimableHTLC`].
991991 ///
992992 /// On-chain fees required to claim the balance are not included in this amount.
993- #[ rustfmt:: skip]
994993 pub fn claimable_amount_satoshis ( & self ) -> u64 {
995994 match self {
996995 Balance :: ClaimableOnChannelClose {
997- balance_candidates, confirmed_balance_candidate_index, ..
996+ balance_candidates,
997+ confirmed_balance_candidate_index,
998+ ..
998999 } => {
9991000 if * confirmed_balance_candidate_index != 0 {
10001001 balance_candidates[ * confirmed_balance_candidate_index] . amount_satoshis
10011002 } else {
10021003 balance_candidates. last ( ) . map ( |balance| balance. amount_satoshis ) . unwrap_or ( 0 )
10031004 }
10041005 } ,
1005- Balance :: ClaimableAwaitingConfirmations { amount_satoshis, .. } |
1006- Balance :: ContentiousClaimable { amount_satoshis, .. } |
1007- Balance :: CounterpartyRevokedOutputClaimable { amount_satoshis, .. }
1008- => * amount_satoshis,
1009- Balance :: MaybeTimeoutClaimableHTLC { amount_satoshis, outbound_payment, .. }
1010- => if * outbound_payment { 0 } else { * amount_satoshis } ,
1006+ Balance :: ClaimableAwaitingConfirmations { amount_satoshis, .. }
1007+ | Balance :: ContentiousClaimable { amount_satoshis, .. }
1008+ | Balance :: CounterpartyRevokedOutputClaimable { amount_satoshis, .. } => * amount_satoshis,
1009+ Balance :: MaybeTimeoutClaimableHTLC { amount_satoshis, outbound_payment, .. } => {
1010+ if * outbound_payment {
1011+ 0
1012+ } else {
1013+ * amount_satoshis
1014+ }
1015+ } ,
10111016 Balance :: MaybePreimageClaimableHTLC { .. } => 0 ,
10121017 }
10131018 }
@@ -1022,25 +1027,35 @@ impl Balance {
10221027 ///
10231028 /// For pending payments, splice behavior, or behavior after a channel has been closed, this
10241029 /// behaves the same as [`Self::claimable_amount_satoshis`].
1025- #[ rustfmt:: skip]
10261030 pub fn offchain_amount_satoshis ( & self ) -> u64 {
10271031 match self {
10281032 Balance :: ClaimableOnChannelClose {
1029- balance_candidates, confirmed_balance_candidate_index, ..
1033+ balance_candidates,
1034+ confirmed_balance_candidate_index,
1035+ ..
10301036 } => {
10311037 if * confirmed_balance_candidate_index != 0 {
10321038 let candidate = & balance_candidates[ * confirmed_balance_candidate_index] ;
10331039 candidate. amount_offchain_satoshis . unwrap_or ( candidate. amount_satoshis )
10341040 } else {
1035- balance_candidates. last ( ) . map ( |balance| balance. amount_offchain_satoshis . unwrap_or ( balance. amount_satoshis ) ) . unwrap_or ( 0 )
1041+ balance_candidates
1042+ . last ( )
1043+ . map ( |balance| {
1044+ balance. amount_offchain_satoshis . unwrap_or ( balance. amount_satoshis )
1045+ } )
1046+ . unwrap_or ( 0 )
1047+ }
1048+ } ,
1049+ Balance :: ClaimableAwaitingConfirmations { amount_satoshis, .. }
1050+ | Balance :: ContentiousClaimable { amount_satoshis, .. }
1051+ | Balance :: CounterpartyRevokedOutputClaimable { amount_satoshis, .. } => * amount_satoshis,
1052+ Balance :: MaybeTimeoutClaimableHTLC { amount_satoshis, outbound_payment, .. } => {
1053+ if * outbound_payment {
1054+ 0
1055+ } else {
1056+ * amount_satoshis
10361057 }
10371058 } ,
1038- Balance :: ClaimableAwaitingConfirmations { amount_satoshis, .. } |
1039- Balance :: ContentiousClaimable { amount_satoshis, .. } |
1040- Balance :: CounterpartyRevokedOutputClaimable { amount_satoshis, .. }
1041- => * amount_satoshis,
1042- Balance :: MaybeTimeoutClaimableHTLC { amount_satoshis, outbound_payment, .. }
1043- => if * outbound_payment { 0 } else { * amount_satoshis } ,
10441059 Balance :: MaybePreimageClaimableHTLC { .. } => 0 ,
10451060 }
10461061 }
0 commit comments