@@ -1448,12 +1448,6 @@ pub struct ChannelCounterparty {
14481448}
14491449
14501450/// 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
14571451#[derive(Clone, Debug, PartialEq)]
14581452pub struct ChannelDetails {
14591453 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
@@ -1535,11 +1529,24 @@ pub struct ChannelDetails {
15351529 ///
15361530 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
15371531 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,
15381543 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
15391544 /// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
15401545 /// available for inclusion in new outbound HTLCs). This further does not include any pending
15411546 /// outgoing HTLCs which are awaiting some other resolution to be sent.
15421547 ///
1548+ /// See also [`ChannelDetails::balance_msat`]
1549+ ///
15431550 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
15441551 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
15451552 /// should be able to spend nearly this amount.
@@ -1549,8 +1556,8 @@ pub struct ChannelDetails {
15491556 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
15501557 /// to use a limit as close as possible to the HTLC limit we can currently send.
15511558 ///
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`].
15541561 pub next_outbound_htlc_limit_msat: u64,
15551562 /// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
15561563 /// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
@@ -1680,6 +1687,7 @@ impl ChannelDetails {
16801687 channel_value_satoshis: context.get_value_satoshis(),
16811688 feerate_sat_per_1000_weight: Some(context.get_feerate_sat_per_1000_weight()),
16821689 unspendable_punishment_reserve: to_self_reserve_satoshis,
1690+ balance_msat: balance.balance_msat,
16831691 inbound_capacity_msat: balance.inbound_capacity_msat,
16841692 outbound_capacity_msat: balance.outbound_capacity_msat,
16851693 next_outbound_htlc_limit_msat: balance.next_outbound_htlc_limit_msat,
@@ -8419,7 +8427,7 @@ impl Writeable for ChannelDetails {
84198427 (10, self.channel_value_satoshis, required),
84208428 (12, self.unspendable_punishment_reserve, option),
84218429 (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),
84238431 (18, self.outbound_capacity_msat, required),
84248432 (19, self.next_outbound_htlc_limit_msat, required),
84258433 (20, self.inbound_capacity_msat, required),
@@ -8455,7 +8463,7 @@ impl Readable for ChannelDetails {
84558463 (10, channel_value_satoshis, required),
84568464 (12, unspendable_punishment_reserve, option),
84578465 (14, user_channel_id_low, required),
8458- (16, _balance_msat, option), // Backwards compatibility for removed balance_msat field.
8466+ (16, balance_msat, required),
84598467 (18, outbound_capacity_msat, required),
84608468 // Note that by the time we get past the required read above, outbound_capacity_msat will be
84618469 // filled in, so we can safely unwrap it here.
@@ -8481,8 +8489,6 @@ impl Readable for ChannelDetails {
84818489 let user_channel_id = user_channel_id_low as u128 +
84828490 ((user_channel_id_high_opt.unwrap_or(0 as u64) as u128) << 64);
84838491
8484- let _balance_msat: Option<u64> = _balance_msat;
8485-
84868492 Ok(Self {
84878493 inbound_scid_alias,
84888494 channel_id: channel_id.0.unwrap(),
@@ -8495,6 +8501,7 @@ impl Readable for ChannelDetails {
84958501 channel_value_satoshis: channel_value_satoshis.0.unwrap(),
84968502 unspendable_punishment_reserve,
84978503 user_channel_id,
8504+ balance_msat: balance_msat.0.unwrap(),
84988505 outbound_capacity_msat: outbound_capacity_msat.0.unwrap(),
84998506 next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat.0.unwrap(),
85008507 next_outbound_htlc_minimum_msat: next_outbound_htlc_minimum_msat.0.unwrap(),
0 commit comments