@@ -1448,12 +1448,6 @@ pub struct ChannelCounterparty {
1448
1448
}
1449
1449
1450
1450
/// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`]
1451
- ///
1452
- /// Balances of a channel are available through [`ChainMonitor::get_claimable_balances`] and
1453
- /// [`ChannelMonitor::get_claimable_balances`], calculated with respect to the corresponding on-chain
1454
- /// transactions.
1455
- ///
1456
- /// [`ChainMonitor::get_claimable_balances`]: crate::chain::chainmonitor::ChainMonitor::get_claimable_balances
1457
1451
#[derive(Clone, Debug, PartialEq)]
1458
1452
pub struct ChannelDetails {
1459
1453
/// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
@@ -1535,11 +1529,24 @@ pub struct ChannelDetails {
1535
1529
///
1536
1530
/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
1537
1531
pub feerate_sat_per_1000_weight: Option<u32>,
1532
+ /// Our total balance. This is the amount we would get if we close the channel.
1533
+ /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
1534
+ /// amount is not likely to be recoverable on close.
1535
+ ///
1536
+ /// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
1537
+ /// balance is not available for inclusion in new outbound HTLCs). This further does not include
1538
+ /// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
1539
+ /// This does not consider any on-chain fees.
1540
+ ///
1541
+ /// See also [`ChannelDetails::outbound_capacity_msat`]
1542
+ pub balance_msat: u64,
1538
1543
/// The available outbound capacity for sending HTLCs to the remote peer. This does not include
1539
1544
/// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1540
1545
/// available for inclusion in new outbound HTLCs). This further does not include any pending
1541
1546
/// outgoing HTLCs which are awaiting some other resolution to be sent.
1542
1547
///
1548
+ /// See also [`ChannelDetails::balance_msat`]
1549
+ ///
1543
1550
/// This value is not exact. Due to various in-flight changes, feerate changes, and our
1544
1551
/// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
1545
1552
/// should be able to spend nearly this amount.
@@ -1549,8 +1556,8 @@ pub struct ChannelDetails {
1549
1556
/// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
1550
1557
/// to use a limit as close as possible to the HTLC limit we can currently send.
1551
1558
///
1552
- /// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`] and
1553
- /// [`ChannelDetails::outbound_capacity_msat`].
1559
+ /// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
1560
+ /// [`ChannelDetails::balance_msat`], and [`ChannelDetails:: outbound_capacity_msat`].
1554
1561
pub next_outbound_htlc_limit_msat: u64,
1555
1562
/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
1556
1563
/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
@@ -1680,6 +1687,7 @@ impl ChannelDetails {
1680
1687
channel_value_satoshis: context.get_value_satoshis(),
1681
1688
feerate_sat_per_1000_weight: Some(context.get_feerate_sat_per_1000_weight()),
1682
1689
unspendable_punishment_reserve: to_self_reserve_satoshis,
1690
+ balance_msat: balance.balance_msat,
1683
1691
inbound_capacity_msat: balance.inbound_capacity_msat,
1684
1692
outbound_capacity_msat: balance.outbound_capacity_msat,
1685
1693
next_outbound_htlc_limit_msat: balance.next_outbound_htlc_limit_msat,
@@ -8419,7 +8427,7 @@ impl Writeable for ChannelDetails {
8419
8427
(10, self.channel_value_satoshis, required),
8420
8428
(12, self.unspendable_punishment_reserve, option),
8421
8429
(14, user_channel_id_low, required),
8422
- (16, self.next_outbound_htlc_limit_msat , required), // Forwards compatibility for removed balance_msat field.
8430
+ (16, self.balance_msat , required),
8423
8431
(18, self.outbound_capacity_msat, required),
8424
8432
(19, self.next_outbound_htlc_limit_msat, required),
8425
8433
(20, self.inbound_capacity_msat, required),
@@ -8455,7 +8463,7 @@ impl Readable for ChannelDetails {
8455
8463
(10, channel_value_satoshis, required),
8456
8464
(12, unspendable_punishment_reserve, option),
8457
8465
(14, user_channel_id_low, required),
8458
- (16, _balance_msat, option), // Backwards compatibility for removed balance_msat field.
8466
+ (16, balance_msat, required),
8459
8467
(18, outbound_capacity_msat, required),
8460
8468
// Note that by the time we get past the required read above, outbound_capacity_msat will be
8461
8469
// filled in, so we can safely unwrap it here.
@@ -8481,8 +8489,6 @@ impl Readable for ChannelDetails {
8481
8489
let user_channel_id = user_channel_id_low as u128 +
8482
8490
((user_channel_id_high_opt.unwrap_or(0 as u64) as u128) << 64);
8483
8491
8484
- let _balance_msat: Option<u64> = _balance_msat;
8485
-
8486
8492
Ok(Self {
8487
8493
inbound_scid_alias,
8488
8494
channel_id: channel_id.0.unwrap(),
@@ -8495,6 +8501,7 @@ impl Readable for ChannelDetails {
8495
8501
channel_value_satoshis: channel_value_satoshis.0.unwrap(),
8496
8502
unspendable_punishment_reserve,
8497
8503
user_channel_id,
8504
+ balance_msat: balance_msat.0.unwrap(),
8498
8505
outbound_capacity_msat: outbound_capacity_msat.0.unwrap(),
8499
8506
next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat.0.unwrap(),
8500
8507
next_outbound_htlc_minimum_msat: next_outbound_htlc_minimum_msat.0.unwrap(),
0 commit comments