@@ -986,10 +986,8 @@ struct CommitmentData<'a> {
986
986
987
987
/// A struct gathering stats on a commitment transaction, either local or remote.
988
988
struct CommitmentStats {
989
- feerate_per_kw: u32, // the feerate of the commitment transaction
990
989
total_fee_sat: u64, // the total fee included in the transaction
991
990
total_anchors_sat: u64, // the sum of the anchors' amounts
992
- broadcaster_dust_limit_sat: u64, // the broadcaster's dust limit
993
991
local_balance_before_fee_anchors_msat: u64, // local balance before fees and anchors *not* considering dust limits
994
992
remote_balance_before_fee_anchors_msat: u64, // remote balance before fees and anchors *not* considering dust limits
995
993
}
@@ -3850,16 +3848,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3850
3848
})
3851
3849
}
3852
3850
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 {
3863
3852
let mut feerate_per_kw = self.feerate_per_kw;
3864
3853
if let Some((feerate, update_state)) = self.pending_update_fee {
3865
3854
if match update_state {
@@ -3873,6 +3862,21 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3873
3862
}
3874
3863
}
3875
3864
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
+
3876
3880
for htlc in self.pending_inbound_htlcs.iter() {
3877
3881
if htlc.state.included_in_commitment(generated_by_local) {
3878
3882
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 {
3930
3934
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 };
3931
3935
3932
3936
CommitmentStats {
3933
- feerate_per_kw,
3934
3937
total_fee_sat,
3935
3938
total_anchors_sat,
3936
- broadcaster_dust_limit_sat,
3937
3939
local_balance_before_fee_anchors_msat: value_to_self_msat,
3938
3940
remote_balance_before_fee_anchors_msat: value_to_remote_msat,
3939
3941
}
@@ -3956,12 +3958,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3956
3958
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
3957
3959
where L::Target: Logger
3958
3960
{
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
+
3959
3964
let stats = self.build_commitment_stats(funding, local, generated_by_local);
3960
3965
let CommitmentStats {
3961
- feerate_per_kw,
3962
3966
total_fee_sat,
3963
3967
total_anchors_sat,
3964
- broadcaster_dust_limit_sat,
3965
3968
local_balance_before_fee_anchors_msat,
3966
3969
remote_balance_before_fee_anchors_msat
3967
3970
} = stats;
0 commit comments