@@ -288,24 +288,6 @@ struct InboundHTLCOutput {
288288 state: InboundHTLCState,
289289}
290290
291- impl InboundHTLCOutput {
292- fn is_dust(
293- &self, local: bool, feerate_per_kw: u32, broadcaster_dust_limit_sat: u64,
294- features: &ChannelTypeFeatures,
295- ) -> bool {
296- let (htlc_success_tx_fee_sat, htlc_timeout_tx_fee_sat) =
297- second_stage_tx_fees_sat(features, feerate_per_kw);
298-
299- let htlc_tx_fee_sat = if !local {
300- // This is an offered HTLC.
301- htlc_timeout_tx_fee_sat
302- } else {
303- htlc_success_tx_fee_sat
304- };
305- self.amount_msat / 1000 < broadcaster_dust_limit_sat + htlc_tx_fee_sat
306- }
307- }
308-
309291#[cfg_attr(test, derive(Clone, Debug, PartialEq))]
310292enum OutboundHTLCState {
311293 /// Added by us and included in a commitment_signed (if we were AwaitingRemoteRevoke when we
@@ -431,24 +413,6 @@ struct OutboundHTLCOutput {
431413 send_timestamp: Option<Duration>,
432414}
433415
434- impl OutboundHTLCOutput {
435- fn is_dust(
436- &self, local: bool, feerate_per_kw: u32, broadcaster_dust_limit_sat: u64,
437- features: &ChannelTypeFeatures,
438- ) -> bool {
439- let (htlc_success_tx_fee_sat, htlc_timeout_tx_fee_sat) =
440- second_stage_tx_fees_sat(features, feerate_per_kw);
441-
442- let htlc_tx_fee_sat = if local {
443- // This is an offered HTLC.
444- htlc_timeout_tx_fee_sat
445- } else {
446- htlc_success_tx_fee_sat
447- };
448- self.amount_msat / 1000 < broadcaster_dust_limit_sat + htlc_tx_fee_sat
449- }
450- }
451-
452416/// See AwaitingRemoteRevoke ChannelState for more info
453417#[cfg_attr(test, derive(Clone, Debug, PartialEq))]
454418enum HTLCUpdateAwaitingACK {
@@ -4581,68 +4545,6 @@ where
45814545 feerate_per_kw
45824546 }
45834547
4584- /// Builds stats on a potential commitment transaction build, without actually building the
4585- /// commitment transaction. See `build_commitment_transaction` for further docs.
4586- #[inline]
4587- #[rustfmt::skip]
4588- fn build_commitment_stats(&self, funding: &FundingScope, local: bool, generated_by_local: bool, feerate_per_kw: Option<u32>, fee_buffer_nondust_htlcs: Option<usize>) -> CommitmentStats {
4589- let broadcaster_dust_limit_sat = if local { self.holder_dust_limit_satoshis } else { self.counterparty_dust_limit_satoshis };
4590- let mut nondust_htlc_count = 0;
4591- let mut remote_htlc_total_msat = 0;
4592- let mut local_htlc_total_msat = 0;
4593- let mut value_to_self_claimed_msat = 0;
4594- let mut value_to_remote_claimed_msat = 0;
4595-
4596- let feerate_per_kw = feerate_per_kw.unwrap_or_else(|| self.get_commitment_feerate(funding, generated_by_local));
4597-
4598- for htlc in self.pending_inbound_htlcs.iter() {
4599- if htlc.state.included_in_commitment(generated_by_local) {
4600- if !htlc.is_dust(local, feerate_per_kw, broadcaster_dust_limit_sat, funding.get_channel_type()) {
4601- nondust_htlc_count += 1;
4602- }
4603- remote_htlc_total_msat += htlc.amount_msat;
4604- } else {
4605- if htlc.state.preimage().is_some() {
4606- value_to_self_claimed_msat += htlc.amount_msat;
4607- }
4608- }
4609- };
4610-
4611- for htlc in self.pending_outbound_htlcs.iter() {
4612- if htlc.state.included_in_commitment(generated_by_local) {
4613- if !htlc.is_dust(local, feerate_per_kw, broadcaster_dust_limit_sat, funding.get_channel_type()) {
4614- nondust_htlc_count += 1;
4615- }
4616- local_htlc_total_msat += htlc.amount_msat;
4617- } else {
4618- if htlc.state.preimage().is_some() {
4619- value_to_remote_claimed_msat += htlc.amount_msat;
4620- }
4621- }
4622- };
4623-
4624- // # Panics
4625- //
4626- // After all HTLC claims have been accounted for, the local balance MUST remain greater than or equal to 0.
4627-
4628- let mut value_to_self_msat = (funding.value_to_self_msat + value_to_self_claimed_msat).checked_sub(value_to_remote_claimed_msat).unwrap();
4629-
4630- let mut value_to_remote_msat = (funding.get_value_satoshis() * 1000).checked_sub(value_to_self_msat).unwrap();
4631- value_to_self_msat = value_to_self_msat.checked_sub(local_htlc_total_msat).unwrap();
4632- value_to_remote_msat = value_to_remote_msat.checked_sub(remote_htlc_total_msat).unwrap();
4633-
4634- let commit_tx_fee_sat = SpecTxBuilder {}.commit_tx_fee_sat(feerate_per_kw, nondust_htlc_count + fee_buffer_nondust_htlcs.unwrap_or(0), funding.get_channel_type());
4635- // Subtract any non-HTLC outputs from the local and remote balances
4636- let (local_balance_before_fee_msat, remote_balance_before_fee_msat) = SpecTxBuilder {}.subtract_non_htlc_outputs(
4637- funding.is_outbound(),
4638- value_to_self_msat,
4639- value_to_remote_msat,
4640- funding.get_channel_type(),
4641- );
4642-
4643- CommitmentStats { commit_tx_fee_sat, local_balance_before_fee_msat, remote_balance_before_fee_msat }
4644- }
4645-
46464548 /// Transaction nomenclature is somewhat confusing here as there are many different cases - a
46474549 /// transaction is referred to as "a's transaction" implying that a will be able to broadcast
46484550 /// the transaction. Thus, b will generally be sending a signature over such a transaction to
0 commit comments