Skip to content

Commit c3fb593

Browse files
committed
Remove broadcaster_dust_limit_sat, feerate_per_kw from CommitmentStats
1 parent 5316257 commit c3fb593

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

lightning/src/ln/channel.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -986,10 +986,8 @@ struct CommitmentData<'a> {
986986

987987
/// A struct gathering stats on a commitment transaction, either local or remote.
988988
struct CommitmentStats {
989-
feerate_per_kw: u32, // the feerate of the commitment transaction
990989
total_fee_sat: u64, // the total fee included in the transaction
991990
total_anchors_sat: u64, // the sum of the anchors' amounts
992-
broadcaster_dust_limit_sat: u64, // the broadcaster's dust limit
993991
local_balance_before_fee_anchors_msat: u64, // local balance before fees and anchors *not* considering dust limits
994992
remote_balance_before_fee_anchors_msat: u64, // remote balance before fees and anchors *not* considering dust limits
995993
}
@@ -3850,16 +3848,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
38503848
})
38513849
}
38523850

3853-
/// Builds stats on a potential commitment transaction build, without actually building the
3854-
/// commitment transaction. See `build_commitment_transaction` for further docs.
3855-
#[inline]
3856-
fn build_commitment_stats(&self, funding: &FundingScope, local: bool, generated_by_local: bool) -> CommitmentStats {
3857-
let broadcaster_dust_limit_sat = if local { self.holder_dust_limit_satoshis } else { self.counterparty_dust_limit_satoshis };
3858-
let mut non_dust_htlc_count = 0;
3859-
let mut remote_htlc_total_msat = 0;
3860-
let mut local_htlc_total_msat = 0;
3861-
let mut value_to_self_msat_offset = 0;
3862-
3851+
fn get_commitment_feerate(&self, funding: &FundingScope, generated_by_local: bool) -> u32 {
38633852
let mut feerate_per_kw = self.feerate_per_kw;
38643853
if let Some((feerate, update_state)) = self.pending_update_fee {
38653854
if match update_state {
@@ -3873,6 +3862,21 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
38733862
}
38743863
}
38753864

3865+
feerate_per_kw
3866+
}
3867+
3868+
/// Builds stats on a potential commitment transaction build, without actually building the
3869+
/// commitment transaction. See `build_commitment_transaction` for further docs.
3870+
#[inline]
3871+
fn build_commitment_stats(&self, funding: &FundingScope, local: bool, generated_by_local: bool) -> CommitmentStats {
3872+
let broadcaster_dust_limit_sat = if local { self.holder_dust_limit_satoshis } else { self.counterparty_dust_limit_satoshis };
3873+
let mut non_dust_htlc_count = 0;
3874+
let mut remote_htlc_total_msat = 0;
3875+
let mut local_htlc_total_msat = 0;
3876+
let mut value_to_self_msat_offset = 0;
3877+
3878+
let feerate_per_kw = self.get_commitment_feerate(funding, generated_by_local);
3879+
38763880
for htlc in self.pending_inbound_htlcs.iter() {
38773881
if htlc.state.included_in_commitment(generated_by_local) {
38783882
if !htlc.is_dust(local, feerate_per_kw, broadcaster_dust_limit_sat, funding.get_channel_type()) {
@@ -3930,10 +3934,8 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
39303934
let total_anchors_sat = if funding.channel_transaction_parameters.channel_type_features.supports_anchors_zero_fee_htlc_tx() { ANCHOR_OUTPUT_VALUE_SATOSHI * 2 } else { 0 };
39313935

39323936
CommitmentStats {
3933-
feerate_per_kw,
39343937
total_fee_sat,
39353938
total_anchors_sat,
3936-
broadcaster_dust_limit_sat,
39373939
local_balance_before_fee_anchors_msat: value_to_self_msat,
39383940
remote_balance_before_fee_anchors_msat: value_to_remote_msat,
39393941
}
@@ -3956,12 +3958,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
39563958
fn build_commitment_transaction<L: Deref>(&self, funding: &FundingScope, commitment_number: u64, per_commitment_point: &PublicKey, local: bool, generated_by_local: bool, logger: &L) -> CommitmentData
39573959
where L::Target: Logger
39583960
{
3961+
let broadcaster_dust_limit_sat = if local { self.holder_dust_limit_satoshis } else { self.counterparty_dust_limit_satoshis };
3962+
let feerate_per_kw = self.get_commitment_feerate(funding, generated_by_local);
3963+
39593964
let stats = self.build_commitment_stats(funding, local, generated_by_local);
39603965
let CommitmentStats {
3961-
feerate_per_kw,
39623966
total_fee_sat,
39633967
total_anchors_sat,
3964-
broadcaster_dust_limit_sat,
39653968
local_balance_before_fee_anchors_msat,
39663969
remote_balance_before_fee_anchors_msat
39673970
} = stats;

0 commit comments

Comments
 (0)