@@ -62,7 +62,7 @@ pub struct ChannelValueStat {
62
62
pub counterparty_dust_limit_msat : u64 ,
63
63
}
64
64
65
- pub struct AvailableBalance {
65
+ pub struct AvailableBalances {
66
66
/// The amount that would go to us if we close the channel, ignoring any on-chain fees.
67
67
pub balance_msat : u64 ,
68
68
/// Total amount available for our counterparty to send to us, ignoring HTLCs.
@@ -2341,26 +2341,27 @@ impl<Signer: Sign> Channel<Signer> {
2341
2341
stats
2342
2342
}
2343
2343
2344
- /// Get the available balances, see [`AvailableBalance `]'s fields for more info.
2344
+ /// Get the available balances, see [`AvailableBalances `]'s fields for more info.
2345
2345
/// Doesn't bother handling the
2346
2346
/// if-we-removed-it-already-but-haven't-fully-resolved-they-can-still-send-an-inbound-HTLC
2347
2347
/// corner case properly.
2348
- pub fn get_available_balance_msat ( & self ) -> AvailableBalance {
2348
+ pub fn get_available_balances ( & self ) -> AvailableBalances {
2349
2349
// Note that we have to handle overflow due to the above case.
2350
2350
let outbound_stats = self . get_outbound_pending_htlc_stats ( None ) ;
2351
2351
2352
- let mut balance_msat = self . value_to_self_msat - outbound_stats . pending_htlcs_value_msat ;
2352
+ let mut balance_msat = self . value_to_self_msat ;
2353
2353
for ref htlc in self . pending_inbound_htlcs . iter ( ) {
2354
2354
if let InboundHTLCState :: LocalRemoved ( InboundHTLCRemovalReason :: Fulfill ( _) ) = htlc. state {
2355
2355
balance_msat += htlc. amount_msat ;
2356
2356
}
2357
2357
}
2358
+ balance_msat -= outbound_stats. pending_htlcs_value_msat ;
2358
2359
2359
2360
let outbound_capacity_msat = cmp:: max ( self . value_to_self_msat as i64
2360
2361
- outbound_stats. pending_htlcs_value_msat as i64
2361
2362
- self . counterparty_selected_channel_reserve_satoshis . unwrap_or ( 0 ) as i64 * 1000 ,
2362
2363
0 ) as u64 ;
2363
- AvailableBalance {
2364
+ AvailableBalances {
2364
2365
inbound_capacity_msat : cmp:: max ( self . channel_value_satoshis as i64 * 1000
2365
2366
- self . value_to_self_msat as i64
2366
2367
- self . get_inbound_pending_htlc_stats ( None ) . pending_htlcs_value_msat as i64
0 commit comments