Skip to content

Commit 714c055

Browse files
dunxenwvanlint
andcommitted
Deprecate AvailableBalances::balance_msat
The ChannelMonitor::get_claimable_balances method provides a more straightforward approach to the balance of a channel, which satisfies most use cases. The computation of AvailableBalances::balance_msat is complex and originally had a different purpose that is not applicable anymore. We deprecate AvailableBalances::balance_msat now and will remove it in a following release. Co-authored-by: Willem Van Lint <[email protected]>
1 parent 137cfea commit 714c055

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,7 @@ where C::Target: chain::Filter,
394394
/// claims which are awaiting confirmation.
395395
///
396396
/// Includes the balances from each [`ChannelMonitor`] *except* those included in
397-
/// `ignored_channels`, allowing you to filter out balances from channels which are still open
398-
/// (and whose balance should likely be pulled from the [`ChannelDetails`]).
397+
/// `ignored_channels`.
399398
///
400399
/// See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for
401400
/// inclusion in the return value.

lightning/src/ln/channel.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub struct ChannelValueStat {
8080

8181
pub struct AvailableBalances {
8282
/// The amount that would go to us if we close the channel, ignoring any on-chain fees.
83+
#[deprecated(since = "0.0.124", note = "use [`ChannelMonitor::get_claimable_balances`] instead")]
8384
pub balance_msat: u64,
8485
/// Total amount available for our counterparty to send to us.
8586
pub inbound_capacity_msat: u64,

lightning/src/ln/channel_state.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,14 @@ impl_writeable_tlv_based!(ChannelCounterparty, {
273273

274274
/// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`]
275275
///
276+
/// Balances of a channel are available through [`ChainMonitor::get_claimable_balances`] and
277+
/// [`ChannelMonitor::get_claimable_balances`], calculated with respect to the corresponding on-chain
278+
/// transactions.
279+
///
276280
/// [`ChannelManager::list_channels`]: crate::ln::channelmanager::ChannelManager::list_channels
277281
/// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
282+
/// [`ChainMonitor::get_claimable_balances`]: crate::chain::chainmonitor::ChainMonitor::get_claimable_balances
283+
/// [`ChannelMonitor::get_claimable_balances`]: crate::chain::channelmonitor::ChannelMonitor::get_claimable_balances
278284
#[derive(Clone, Debug, PartialEq)]
279285
pub struct ChannelDetails {
280286
/// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
@@ -363,6 +369,10 @@ pub struct ChannelDetails {
363369
/// This does not consider any on-chain fees.
364370
///
365371
/// See also [`ChannelDetails::outbound_capacity_msat`]
372+
#[deprecated(
373+
since = "0.0.124",
374+
note = "use [`ChannelMonitor::get_claimable_balances`] instead"
375+
)]
366376
pub balance_msat: u64,
367377
/// The available outbound capacity for sending HTLCs to the remote peer. This does not include
368378
/// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* The `AvailableBalances::balance_msat` field has been deprecated in favor of `ChannelMonitor::get_claimable_balances`. `AvailableBalances::balance_msat` will be removed in an upcoming release (#3247).

0 commit comments

Comments
 (0)