Skip to content

Commit fccbd47

Browse files
committed
Delete ChannelContext::get_pending_htlc_stats, HTLCStats
1 parent 6b2401f commit fccbd47

File tree

1 file changed

+0
-118
lines changed

1 file changed

+0
-118
lines changed

lightning/src/ln/channel.rs

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,19 +1071,6 @@ enum HTLCInitiator {
10711071
RemoteOffered,
10721072
}
10731073

1074-
/// Current counts of various HTLCs, useful for calculating current balances available exactly.
1075-
struct HTLCStats {
1076-
pending_outbound_htlcs: usize,
1077-
pending_inbound_htlcs_value_msat: u64,
1078-
pending_outbound_htlcs_value_msat: u64,
1079-
on_counterparty_tx_dust_exposure_msat: u64,
1080-
// If the counterparty sets a feerate on the channel in excess of our dust_exposure_limiting_feerate,
1081-
// this will be set to the dust exposure that would result from us adding an additional nondust outbound
1082-
// htlc on the counterparty's commitment transaction.
1083-
extra_nondust_htlc_on_counterparty_tx_dust_exposure_msat: Option<u64>,
1084-
on_holder_tx_dust_exposure_msat: u64,
1085-
}
1086-
10871074
/// A struct gathering data on a commitment, either local or remote.
10881075
struct CommitmentData<'a> {
10891076
tx: CommitmentTransaction,
@@ -5464,111 +5451,6 @@ where
54645451
self.counterparty_forwarding_info.clone()
54655452
}
54665453

5467-
/// Returns a HTLCStats about pending htlcs
5468-
#[rustfmt::skip]
5469-
fn get_pending_htlc_stats(
5470-
&self, funding: &FundingScope, outbound_feerate_update: Option<u32>,
5471-
dust_exposure_limiting_feerate: Option<u32>,
5472-
) -> HTLCStats {
5473-
let context = self;
5474-
5475-
let dust_buffer_feerate = self.get_dust_buffer_feerate(outbound_feerate_update);
5476-
let (htlc_success_tx_fee_sat, htlc_timeout_tx_fee_sat) = second_stage_tx_fees_sat(
5477-
funding.get_channel_type(), dust_buffer_feerate,
5478-
);
5479-
5480-
let mut on_holder_tx_dust_exposure_msat = 0;
5481-
let mut on_counterparty_tx_dust_exposure_msat = 0;
5482-
5483-
let mut on_counterparty_tx_offered_nondust_htlcs = 0;
5484-
let mut on_counterparty_tx_accepted_nondust_htlcs = 0;
5485-
5486-
let mut pending_inbound_htlcs_value_msat = 0;
5487-
5488-
{
5489-
let counterparty_dust_limit_timeout_sat = htlc_timeout_tx_fee_sat + context.counterparty_dust_limit_satoshis;
5490-
let holder_dust_limit_success_sat = htlc_success_tx_fee_sat + context.holder_dust_limit_satoshis;
5491-
for htlc in context.pending_inbound_htlcs.iter() {
5492-
pending_inbound_htlcs_value_msat += htlc.amount_msat;
5493-
if htlc.amount_msat / 1000 < counterparty_dust_limit_timeout_sat {
5494-
on_counterparty_tx_dust_exposure_msat += htlc.amount_msat;
5495-
} else {
5496-
on_counterparty_tx_offered_nondust_htlcs += 1;
5497-
}
5498-
if htlc.amount_msat / 1000 < holder_dust_limit_success_sat {
5499-
on_holder_tx_dust_exposure_msat += htlc.amount_msat;
5500-
}
5501-
}
5502-
}
5503-
5504-
let mut pending_outbound_htlcs_value_msat = 0;
5505-
let mut pending_outbound_htlcs = self.pending_outbound_htlcs.len();
5506-
{
5507-
let counterparty_dust_limit_success_sat = htlc_success_tx_fee_sat + context.counterparty_dust_limit_satoshis;
5508-
let holder_dust_limit_timeout_sat = htlc_timeout_tx_fee_sat + context.holder_dust_limit_satoshis;
5509-
for htlc in context.pending_outbound_htlcs.iter() {
5510-
pending_outbound_htlcs_value_msat += htlc.amount_msat;
5511-
if htlc.amount_msat / 1000 < counterparty_dust_limit_success_sat {
5512-
on_counterparty_tx_dust_exposure_msat += htlc.amount_msat;
5513-
} else {
5514-
on_counterparty_tx_accepted_nondust_htlcs += 1;
5515-
}
5516-
if htlc.amount_msat / 1000 < holder_dust_limit_timeout_sat {
5517-
on_holder_tx_dust_exposure_msat += htlc.amount_msat;
5518-
}
5519-
}
5520-
5521-
for update in context.holding_cell_htlc_updates.iter() {
5522-
if let &HTLCUpdateAwaitingACK::AddHTLC { ref amount_msat, .. } = update {
5523-
pending_outbound_htlcs += 1;
5524-
pending_outbound_htlcs_value_msat += amount_msat;
5525-
if *amount_msat / 1000 < counterparty_dust_limit_success_sat {
5526-
on_counterparty_tx_dust_exposure_msat += amount_msat;
5527-
} else {
5528-
on_counterparty_tx_accepted_nondust_htlcs += 1;
5529-
}
5530-
if *amount_msat / 1000 < holder_dust_limit_timeout_sat {
5531-
on_holder_tx_dust_exposure_msat += amount_msat;
5532-
}
5533-
}
5534-
}
5535-
}
5536-
5537-
// Include any mining "excess" fees in the dust calculation
5538-
let excess_feerate_opt = outbound_feerate_update
5539-
.or(self.pending_update_fee.map(|(fee, _)| fee))
5540-
.unwrap_or(self.feerate_per_kw)
5541-
.checked_sub(dust_exposure_limiting_feerate.unwrap_or(0));
5542-
5543-
// Dust exposure is only decoupled from feerate for zero fee commitment channels.
5544-
let is_zero_fee_comm = funding.get_channel_type().supports_anchor_zero_fee_commitments();
5545-
debug_assert_eq!(is_zero_fee_comm, dust_exposure_limiting_feerate.is_none());
5546-
if is_zero_fee_comm {
5547-
debug_assert_eq!(excess_feerate_opt, Some(0));
5548-
}
5549-
5550-
let extra_nondust_htlc_on_counterparty_tx_dust_exposure_msat = excess_feerate_opt.map(|excess_feerate| {
5551-
let extra_htlc_commit_tx_fee_sat = SpecTxBuilder {}.commit_tx_fee_sat(excess_feerate, on_counterparty_tx_accepted_nondust_htlcs + 1 + on_counterparty_tx_offered_nondust_htlcs, funding.get_channel_type());
5552-
let extra_htlc_htlc_tx_fees_sat = chan_utils::htlc_tx_fees_sat(excess_feerate, on_counterparty_tx_accepted_nondust_htlcs + 1, on_counterparty_tx_offered_nondust_htlcs, funding.get_channel_type());
5553-
5554-
let commit_tx_fee_sat = SpecTxBuilder {}.commit_tx_fee_sat(excess_feerate, on_counterparty_tx_accepted_nondust_htlcs + on_counterparty_tx_offered_nondust_htlcs, funding.get_channel_type());
5555-
let htlc_tx_fees_sat = chan_utils::htlc_tx_fees_sat(excess_feerate, on_counterparty_tx_accepted_nondust_htlcs, on_counterparty_tx_offered_nondust_htlcs, funding.get_channel_type());
5556-
5557-
let extra_htlc_dust_exposure = on_counterparty_tx_dust_exposure_msat + (extra_htlc_commit_tx_fee_sat + extra_htlc_htlc_tx_fees_sat) * 1000;
5558-
on_counterparty_tx_dust_exposure_msat += (commit_tx_fee_sat + htlc_tx_fees_sat) * 1000;
5559-
extra_htlc_dust_exposure
5560-
});
5561-
5562-
HTLCStats {
5563-
pending_outbound_htlcs,
5564-
pending_inbound_htlcs_value_msat,
5565-
pending_outbound_htlcs_value_msat,
5566-
on_counterparty_tx_dust_exposure_msat,
5567-
extra_nondust_htlc_on_counterparty_tx_dust_exposure_msat,
5568-
on_holder_tx_dust_exposure_msat,
5569-
}
5570-
}
5571-
55725454
/// Returns information on all pending inbound HTLCs.
55735455
#[rustfmt::skip]
55745456
pub fn get_pending_inbound_htlc_details(&self, funding: &FundingScope) -> Vec<InboundHTLCDetails> {

0 commit comments

Comments
 (0)