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