Skip to content

Commit 124d2a9

Browse files
committed
Remove AvailableBalances::balance_msat
1 parent 6f58072 commit 124d2a9

File tree

5 files changed

+7
-35
lines changed

5 files changed

+7
-35
lines changed

fuzz/src/router.rs

-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
232232
force_close_spend_delay: None,
233233
is_outbound: true, is_channel_ready: true,
234234
is_usable: true, is_public: true,
235-
balance_msat: 0,
236235
outbound_capacity_msat: capacity.saturating_mul(1000),
237236
next_outbound_htlc_limit_msat: capacity.saturating_mul(1000),
238237
next_outbound_htlc_minimum_msat: 0,

lightning/src/chain/chainmonitor.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ where C::Target: chain::Filter,
364364
/// claims which are awaiting confirmation.
365365
///
366366
/// Includes the balances from each [`ChannelMonitor`] *except* those included in
367-
/// `ignored_channels`, allowing you to filter out balances from channels which are still open
368-
/// (and whose balance should likely be pulled from the [`ChannelDetails`]).
367+
/// `ignored_channels`.
369368
///
370369
/// See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for
371370
/// inclusion in the return value.

lightning/src/ln/channel.rs

-11
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ pub struct ChannelValueStat {
6565
}
6666

6767
pub struct AvailableBalances {
68-
/// The amount that would go to us if we close the channel, ignoring any on-chain fees.
69-
pub balance_msat: u64,
7068
/// Total amount available for our counterparty to send to us.
7169
pub inbound_capacity_msat: u64,
7270
/// Total amount available for us to send to our counterparty.
@@ -1611,14 +1609,6 @@ impl<Signer: ChannelSigner> ChannelContext<Signer> {
16111609
let inbound_stats = context.get_inbound_pending_htlc_stats(None);
16121610
let outbound_stats = context.get_outbound_pending_htlc_stats(None);
16131611

1614-
let mut balance_msat = context.value_to_self_msat;
1615-
for ref htlc in context.pending_inbound_htlcs.iter() {
1616-
if let InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(_)) = htlc.state {
1617-
balance_msat += htlc.amount_msat;
1618-
}
1619-
}
1620-
balance_msat -= outbound_stats.pending_htlcs_value_msat;
1621-
16221612
let outbound_capacity_msat = context.value_to_self_msat
16231613
.saturating_sub(outbound_stats.pending_htlcs_value_msat)
16241614
.saturating_sub(
@@ -1735,7 +1725,6 @@ impl<Signer: ChannelSigner> ChannelContext<Signer> {
17351725
outbound_capacity_msat,
17361726
next_outbound_htlc_limit_msat: available_capacity_msat,
17371727
next_outbound_htlc_minimum_msat,
1738-
balance_msat,
17391728
}
17401729
}
17411730

lightning/src/ln/channelmanager.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -1407,24 +1407,11 @@ pub struct ChannelDetails {
14071407
///
14081408
/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
14091409
pub feerate_sat_per_1000_weight: Option<u32>,
1410-
/// Our total balance. This is the amount we would get if we close the channel.
1411-
/// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
1412-
/// amount is not likely to be recoverable on close.
1413-
///
1414-
/// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
1415-
/// balance is not available for inclusion in new outbound HTLCs). This further does not include
1416-
/// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
1417-
/// This does not consider any on-chain fees.
1418-
///
1419-
/// See also [`ChannelDetails::outbound_capacity_msat`]
1420-
pub balance_msat: u64,
14211410
/// The available outbound capacity for sending HTLCs to the remote peer. This does not include
14221411
/// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
14231412
/// available for inclusion in new outbound HTLCs). This further does not include any pending
14241413
/// outgoing HTLCs which are awaiting some other resolution to be sent.
14251414
///
1426-
/// See also [`ChannelDetails::balance_msat`]
1427-
///
14281415
/// This value is not exact. Due to various in-flight changes, feerate changes, and our
14291416
/// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
14301417
/// should be able to spend nearly this amount.
@@ -1434,8 +1421,8 @@ pub struct ChannelDetails {
14341421
/// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
14351422
/// to use a limit as close as possible to the HTLC limit we can currently send.
14361423
///
1437-
/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
1438-
/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
1424+
/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`] and
1425+
/// [`ChannelDetails::outbound_capacity_msat`].
14391426
pub next_outbound_htlc_limit_msat: u64,
14401427
/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
14411428
/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
@@ -1563,7 +1550,6 @@ impl ChannelDetails {
15631550
channel_value_satoshis: context.get_value_satoshis(),
15641551
feerate_sat_per_1000_weight: Some(context.get_feerate_sat_per_1000_weight()),
15651552
unspendable_punishment_reserve: to_self_reserve_satoshis,
1566-
balance_msat: balance.balance_msat,
15671553
inbound_capacity_msat: balance.inbound_capacity_msat,
15681554
outbound_capacity_msat: balance.outbound_capacity_msat,
15691555
next_outbound_htlc_limit_msat: balance.next_outbound_htlc_limit_msat,
@@ -7514,7 +7500,7 @@ impl Writeable for ChannelDetails {
75147500
(10, self.channel_value_satoshis, required),
75157501
(12, self.unspendable_punishment_reserve, option),
75167502
(14, user_channel_id_low, required),
7517-
(16, self.balance_msat, required),
7503+
(16, 0 as u64, required), // Forwards compatibility for removed balance_msat field.
75187504
(18, self.outbound_capacity_msat, required),
75197505
(19, self.next_outbound_htlc_limit_msat, required),
75207506
(20, self.inbound_capacity_msat, required),
@@ -7550,7 +7536,7 @@ impl Readable for ChannelDetails {
75507536
(10, channel_value_satoshis, required),
75517537
(12, unspendable_punishment_reserve, option),
75527538
(14, user_channel_id_low, required),
7553-
(16, balance_msat, required),
7539+
(16, _balance_msat, required), // Backwards compatibility for removed balance_msat field.
75547540
(18, outbound_capacity_msat, required),
75557541
// Note that by the time we get past the required read above, outbound_capacity_msat will be
75567542
// filled in, so we can safely unwrap it here.
@@ -7576,6 +7562,8 @@ impl Readable for ChannelDetails {
75767562
let user_channel_id = user_channel_id_low as u128 +
75777563
((user_channel_id_high_opt.unwrap_or(0 as u64) as u128) << 64);
75787564

7565+
let _balance_msat: u64 = _balance_msat.0.unwrap();
7566+
75797567
Ok(Self {
75807568
inbound_scid_alias,
75817569
channel_id: channel_id.0.unwrap(),
@@ -7588,7 +7576,6 @@ impl Readable for ChannelDetails {
75887576
channel_value_satoshis: channel_value_satoshis.0.unwrap(),
75897577
unspendable_punishment_reserve,
75907578
user_channel_id,
7591-
balance_msat: balance_msat.0.unwrap(),
75927579
outbound_capacity_msat: outbound_capacity_msat.0.unwrap(),
75937580
next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat.0.unwrap(),
75947581
next_outbound_htlc_minimum_msat: next_outbound_htlc_minimum_msat.0.unwrap(),

lightning/src/routing/router.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2725,7 +2725,6 @@ mod tests {
27252725
inbound_scid_alias: None,
27262726
channel_value_satoshis: 0,
27272727
user_channel_id: 0,
2728-
balance_msat: 0,
27292728
outbound_capacity_msat,
27302729
next_outbound_htlc_limit_msat: outbound_capacity_msat,
27312730
next_outbound_htlc_minimum_msat: 0,
@@ -6794,7 +6793,6 @@ pub(crate) mod bench_utils {
67946793
outbound_scid_alias: None,
67956794
channel_value_satoshis: 10_000_000_000,
67966795
user_channel_id: 0,
6797-
balance_msat: 10_000_000_000,
67986796
outbound_capacity_msat: 10_000_000_000,
67996797
next_outbound_htlc_minimum_msat: 0,
68006798
next_outbound_htlc_limit_msat: 10_000_000_000,

0 commit comments

Comments
 (0)