Skip to content

Commit 19313c4

Browse files
committed
Delete ChannelContext::get_pending_htlc_stats, HTLCStats
1 parent b9be982 commit 19313c4

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
@@ -1105,19 +1105,6 @@ enum HTLCInitiator {
11051105
RemoteOffered,
11061106
}
11071107

1108-
/// Current counts of various HTLCs, useful for calculating current balances available exactly.
1109-
struct HTLCStats {
1110-
pending_outbound_htlcs: usize,
1111-
pending_inbound_htlcs_value_msat: u64,
1112-
pending_outbound_htlcs_value_msat: u64,
1113-
on_counterparty_tx_dust_exposure_msat: u64,
1114-
// If the counterparty sets a feerate on the channel in excess of our dust_exposure_limiting_feerate,
1115-
// this will be set to the dust exposure that would result from us adding an additional nondust outbound
1116-
// htlc on the counterparty's commitment transaction.
1117-
extra_nondust_htlc_on_counterparty_tx_dust_exposure_msat: Option<u64>,
1118-
on_holder_tx_dust_exposure_msat: u64,
1119-
}
1120-
11211108
/// A struct gathering data on a commitment, either local or remote.
11221109
struct CommitmentData<'a> {
11231110
tx: CommitmentTransaction,
@@ -4860,111 +4847,6 @@ where
48604847
self.counterparty_forwarding_info.clone()
48614848
}
48624849

4863-
/// Returns a HTLCStats about pending htlcs
4864-
#[rustfmt::skip]
4865-
fn get_pending_htlc_stats(
4866-
&self, funding: &FundingScope, outbound_feerate_update: Option<u32>,
4867-
dust_exposure_limiting_feerate: Option<u32>,
4868-
) -> HTLCStats {
4869-
let context = self;
4870-
4871-
let dust_buffer_feerate = self.get_dust_buffer_feerate(outbound_feerate_update);
4872-
let (htlc_success_tx_fee_sat, htlc_timeout_tx_fee_sat) = second_stage_tx_fees_sat(
4873-
funding.get_channel_type(), dust_buffer_feerate,
4874-
);
4875-
4876-
let mut on_holder_tx_dust_exposure_msat = 0;
4877-
let mut on_counterparty_tx_dust_exposure_msat = 0;
4878-
4879-
let mut on_counterparty_tx_offered_nondust_htlcs = 0;
4880-
let mut on_counterparty_tx_accepted_nondust_htlcs = 0;
4881-
4882-
let mut pending_inbound_htlcs_value_msat = 0;
4883-
4884-
{
4885-
let counterparty_dust_limit_timeout_sat = htlc_timeout_tx_fee_sat + context.counterparty_dust_limit_satoshis;
4886-
let holder_dust_limit_success_sat = htlc_success_tx_fee_sat + context.holder_dust_limit_satoshis;
4887-
for htlc in context.pending_inbound_htlcs.iter() {
4888-
pending_inbound_htlcs_value_msat += htlc.amount_msat;
4889-
if htlc.amount_msat / 1000 < counterparty_dust_limit_timeout_sat {
4890-
on_counterparty_tx_dust_exposure_msat += htlc.amount_msat;
4891-
} else {
4892-
on_counterparty_tx_offered_nondust_htlcs += 1;
4893-
}
4894-
if htlc.amount_msat / 1000 < holder_dust_limit_success_sat {
4895-
on_holder_tx_dust_exposure_msat += htlc.amount_msat;
4896-
}
4897-
}
4898-
}
4899-
4900-
let mut pending_outbound_htlcs_value_msat = 0;
4901-
let mut pending_outbound_htlcs = self.pending_outbound_htlcs.len();
4902-
{
4903-
let counterparty_dust_limit_success_sat = htlc_success_tx_fee_sat + context.counterparty_dust_limit_satoshis;
4904-
let holder_dust_limit_timeout_sat = htlc_timeout_tx_fee_sat + context.holder_dust_limit_satoshis;
4905-
for htlc in context.pending_outbound_htlcs.iter() {
4906-
pending_outbound_htlcs_value_msat += htlc.amount_msat;
4907-
if htlc.amount_msat / 1000 < counterparty_dust_limit_success_sat {
4908-
on_counterparty_tx_dust_exposure_msat += htlc.amount_msat;
4909-
} else {
4910-
on_counterparty_tx_accepted_nondust_htlcs += 1;
4911-
}
4912-
if htlc.amount_msat / 1000 < holder_dust_limit_timeout_sat {
4913-
on_holder_tx_dust_exposure_msat += htlc.amount_msat;
4914-
}
4915-
}
4916-
4917-
for update in context.holding_cell_htlc_updates.iter() {
4918-
if let &HTLCUpdateAwaitingACK::AddHTLC { ref amount_msat, .. } = update {
4919-
pending_outbound_htlcs += 1;
4920-
pending_outbound_htlcs_value_msat += amount_msat;
4921-
if *amount_msat / 1000 < counterparty_dust_limit_success_sat {
4922-
on_counterparty_tx_dust_exposure_msat += amount_msat;
4923-
} else {
4924-
on_counterparty_tx_accepted_nondust_htlcs += 1;
4925-
}
4926-
if *amount_msat / 1000 < holder_dust_limit_timeout_sat {
4927-
on_holder_tx_dust_exposure_msat += amount_msat;
4928-
}
4929-
}
4930-
}
4931-
}
4932-
4933-
// Include any mining "excess" fees in the dust calculation
4934-
let excess_feerate_opt = outbound_feerate_update
4935-
.or(self.pending_update_fee.map(|(fee, _)| fee))
4936-
.unwrap_or(self.feerate_per_kw)
4937-
.checked_sub(dust_exposure_limiting_feerate.unwrap_or(0));
4938-
4939-
// Dust exposure is only decoupled from feerate for zero fee commitment channels.
4940-
let is_zero_fee_comm = funding.get_channel_type().supports_anchor_zero_fee_commitments();
4941-
debug_assert_eq!(is_zero_fee_comm, dust_exposure_limiting_feerate.is_none());
4942-
if is_zero_fee_comm {
4943-
debug_assert_eq!(excess_feerate_opt, Some(0));
4944-
}
4945-
4946-
let extra_nondust_htlc_on_counterparty_tx_dust_exposure_msat = excess_feerate_opt.map(|excess_feerate| {
4947-
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());
4948-
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());
4949-
4950-
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());
4951-
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());
4952-
4953-
let extra_htlc_dust_exposure = on_counterparty_tx_dust_exposure_msat + (extra_htlc_commit_tx_fee_sat + extra_htlc_htlc_tx_fees_sat) * 1000;
4954-
on_counterparty_tx_dust_exposure_msat += (commit_tx_fee_sat + htlc_tx_fees_sat) * 1000;
4955-
extra_htlc_dust_exposure
4956-
});
4957-
4958-
HTLCStats {
4959-
pending_outbound_htlcs,
4960-
pending_inbound_htlcs_value_msat,
4961-
pending_outbound_htlcs_value_msat,
4962-
on_counterparty_tx_dust_exposure_msat,
4963-
extra_nondust_htlc_on_counterparty_tx_dust_exposure_msat,
4964-
on_holder_tx_dust_exposure_msat,
4965-
}
4966-
}
4967-
49684850
/// Returns information on all pending inbound HTLCs.
49694851
#[rustfmt::skip]
49704852
pub fn get_pending_inbound_htlc_details(&self, funding: &FundingScope) -> Vec<InboundHTLCDetails> {

0 commit comments

Comments
 (0)