@@ -1107,19 +1107,6 @@ enum HTLCInitiator {
1107
1107
RemoteOffered,
1108
1108
}
1109
1109
1110
- /// Current counts of various HTLCs, useful for calculating current balances available exactly.
1111
- struct HTLCStats {
1112
- pending_outbound_htlcs: usize,
1113
- pending_inbound_htlcs_value_msat: u64,
1114
- pending_outbound_htlcs_value_msat: u64,
1115
- on_counterparty_tx_dust_exposure_msat: u64,
1116
- // If the counterparty sets a feerate on the channel in excess of our dust_exposure_limiting_feerate,
1117
- // this will be set to the dust exposure that would result from us adding an additional nondust outbound
1118
- // htlc on the counterparty's commitment transaction.
1119
- extra_nondust_htlc_on_counterparty_tx_dust_exposure_msat: Option<u64>,
1120
- on_holder_tx_dust_exposure_msat: u64,
1121
- }
1122
-
1123
1110
/// A struct gathering data on a commitment, either local or remote.
1124
1111
struct CommitmentData<'a> {
1125
1112
tx: CommitmentTransaction,
@@ -4865,111 +4852,6 @@ where
4865
4852
self.counterparty_forwarding_info.clone()
4866
4853
}
4867
4854
4868
- /// Returns a HTLCStats about pending htlcs
4869
- #[rustfmt::skip]
4870
- fn get_pending_htlc_stats(
4871
- &self, funding: &FundingScope, outbound_feerate_update: Option<u32>,
4872
- dust_exposure_limiting_feerate: Option<u32>,
4873
- ) -> HTLCStats {
4874
- let context = self;
4875
-
4876
- let dust_buffer_feerate = self.get_dust_buffer_feerate(outbound_feerate_update);
4877
- let (htlc_success_tx_fee_sat, htlc_timeout_tx_fee_sat) = second_stage_tx_fees_sat(
4878
- funding.get_channel_type(), dust_buffer_feerate,
4879
- );
4880
-
4881
- let mut on_holder_tx_dust_exposure_msat = 0;
4882
- let mut on_counterparty_tx_dust_exposure_msat = 0;
4883
-
4884
- let mut on_counterparty_tx_offered_nondust_htlcs = 0;
4885
- let mut on_counterparty_tx_accepted_nondust_htlcs = 0;
4886
-
4887
- let mut pending_inbound_htlcs_value_msat = 0;
4888
-
4889
- {
4890
- let counterparty_dust_limit_timeout_sat = htlc_timeout_tx_fee_sat + context.counterparty_dust_limit_satoshis;
4891
- let holder_dust_limit_success_sat = htlc_success_tx_fee_sat + context.holder_dust_limit_satoshis;
4892
- for htlc in context.pending_inbound_htlcs.iter() {
4893
- pending_inbound_htlcs_value_msat += htlc.amount_msat;
4894
- if htlc.amount_msat / 1000 < counterparty_dust_limit_timeout_sat {
4895
- on_counterparty_tx_dust_exposure_msat += htlc.amount_msat;
4896
- } else {
4897
- on_counterparty_tx_offered_nondust_htlcs += 1;
4898
- }
4899
- if htlc.amount_msat / 1000 < holder_dust_limit_success_sat {
4900
- on_holder_tx_dust_exposure_msat += htlc.amount_msat;
4901
- }
4902
- }
4903
- }
4904
-
4905
- let mut pending_outbound_htlcs_value_msat = 0;
4906
- let mut pending_outbound_htlcs = self.pending_outbound_htlcs.len();
4907
- {
4908
- let counterparty_dust_limit_success_sat = htlc_success_tx_fee_sat + context.counterparty_dust_limit_satoshis;
4909
- let holder_dust_limit_timeout_sat = htlc_timeout_tx_fee_sat + context.holder_dust_limit_satoshis;
4910
- for htlc in context.pending_outbound_htlcs.iter() {
4911
- pending_outbound_htlcs_value_msat += htlc.amount_msat;
4912
- if htlc.amount_msat / 1000 < counterparty_dust_limit_success_sat {
4913
- on_counterparty_tx_dust_exposure_msat += htlc.amount_msat;
4914
- } else {
4915
- on_counterparty_tx_accepted_nondust_htlcs += 1;
4916
- }
4917
- if htlc.amount_msat / 1000 < holder_dust_limit_timeout_sat {
4918
- on_holder_tx_dust_exposure_msat += htlc.amount_msat;
4919
- }
4920
- }
4921
-
4922
- for update in context.holding_cell_htlc_updates.iter() {
4923
- if let &HTLCUpdateAwaitingACK::AddHTLC { ref amount_msat, .. } = update {
4924
- pending_outbound_htlcs += 1;
4925
- pending_outbound_htlcs_value_msat += amount_msat;
4926
- if *amount_msat / 1000 < counterparty_dust_limit_success_sat {
4927
- on_counterparty_tx_dust_exposure_msat += amount_msat;
4928
- } else {
4929
- on_counterparty_tx_accepted_nondust_htlcs += 1;
4930
- }
4931
- if *amount_msat / 1000 < holder_dust_limit_timeout_sat {
4932
- on_holder_tx_dust_exposure_msat += amount_msat;
4933
- }
4934
- }
4935
- }
4936
- }
4937
-
4938
- // Include any mining "excess" fees in the dust calculation
4939
- let excess_feerate_opt = outbound_feerate_update
4940
- .or(self.pending_update_fee.map(|(fee, _)| fee))
4941
- .unwrap_or(self.feerate_per_kw)
4942
- .checked_sub(dust_exposure_limiting_feerate.unwrap_or(0));
4943
-
4944
- // Dust exposure is only decoupled from feerate for zero fee commitment channels.
4945
- let is_zero_fee_comm = funding.get_channel_type().supports_anchor_zero_fee_commitments();
4946
- debug_assert_eq!(is_zero_fee_comm, dust_exposure_limiting_feerate.is_none());
4947
- if is_zero_fee_comm {
4948
- debug_assert_eq!(excess_feerate_opt, Some(0));
4949
- }
4950
-
4951
- let extra_nondust_htlc_on_counterparty_tx_dust_exposure_msat = excess_feerate_opt.map(|excess_feerate| {
4952
- 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());
4953
- 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());
4954
-
4955
- 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());
4956
- 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());
4957
-
4958
- let extra_htlc_dust_exposure = on_counterparty_tx_dust_exposure_msat + (extra_htlc_commit_tx_fee_sat + extra_htlc_htlc_tx_fees_sat) * 1000;
4959
- on_counterparty_tx_dust_exposure_msat += (commit_tx_fee_sat + htlc_tx_fees_sat) * 1000;
4960
- extra_htlc_dust_exposure
4961
- });
4962
-
4963
- HTLCStats {
4964
- pending_outbound_htlcs,
4965
- pending_inbound_htlcs_value_msat,
4966
- pending_outbound_htlcs_value_msat,
4967
- on_counterparty_tx_dust_exposure_msat,
4968
- extra_nondust_htlc_on_counterparty_tx_dust_exposure_msat,
4969
- on_holder_tx_dust_exposure_msat,
4970
- }
4971
- }
4972
-
4973
4855
/// Returns information on all pending inbound HTLCs.
4974
4856
#[rustfmt::skip]
4975
4857
pub fn get_pending_inbound_htlc_details(&self, funding: &FundingScope) -> Vec<InboundHTLCDetails> {
0 commit comments