Skip to content

Commit ec13990

Browse files
committed
Relax feerate requirements in TxBuilder::get_next_commitment_stats
We sometimes do not have easy access to the `dust_exposure_limiting_feerate`, yet we are still interested in basic stats on commitments like balances and transaction fees. So we relax the requirement that the `dust_exposure_limiting_feerate` is always set when `feerate_per_kw` is not 0.
1 parent f30fb62 commit ec13990

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

lightning/src/ln/channel.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11979,21 +11979,12 @@ where
1197911979
fn get_holder_counterparty_balances_floor_incl_fee(
1198011980
&self, funding: &FundingScope,
1198111981
) -> Result<(Amount, Amount), String> {
11982-
// We don't care about the exact value of `dust_exposure_limiting_feerate` here as
11983-
// we do not validate dust exposure below, but we want to avoid triggering a debug
11984-
// assert.
11985-
//
11986-
// TODO: clean this up here and elsewhere.
11987-
let dust_exposure_limiting_feerate =
11988-
if funding.get_channel_type().supports_anchor_zero_fee_commitments() {
11989-
None
11990-
} else {
11991-
Some(self.context.feerate_per_kw)
11992-
};
1199311982
let include_counterparty_unknown_htlcs = true;
1199411983
// Make sure that that the funder of the channel can pay the transaction fees for an additional
1199511984
// nondust HTLC on the channel.
1199611985
let addl_nondust_htlc_count = 1;
11986+
// We are not interested in dust exposure
11987+
let dust_exposure_limiting_feerate = None;
1199711988

1199811989
let local_commitment_stats = self
1199911990
.context

lightning/src/sign/tx_builder.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,8 @@ impl TxBuilder for SpecTxBuilder {
206206
channel_type: &ChannelTypeFeatures,
207207
) -> Result<NextCommitmentStats, ()> {
208208
let excess_feerate_opt =
209-
feerate_per_kw.checked_sub(dust_exposure_limiting_feerate.unwrap_or(0));
210-
// Dust exposure is only decoupled from feerate for zero fee commitment channels.
211-
let is_zero_fee_comm = channel_type.supports_anchor_zero_fee_commitments();
212-
debug_assert_eq!(is_zero_fee_comm, dust_exposure_limiting_feerate.is_none());
213-
if is_zero_fee_comm {
209+
feerate_per_kw.checked_sub(dust_exposure_limiting_feerate.unwrap_or(feerate_per_kw));
210+
if channel_type.supports_anchor_zero_fee_commitments() {
214211
debug_assert_eq!(feerate_per_kw, 0);
215212
debug_assert_eq!(excess_feerate_opt, Some(0));
216213
debug_assert_eq!(addl_nondust_htlc_count, 0);

0 commit comments

Comments
 (0)