Skip to content

Commit f11aa2e

Browse files
committed
Correct the units of counterparty htlc tx excess fees calculations
The widely used sats/kWU ratio is equivalent to msats/WU
1 parent 188f299 commit f11aa2e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ pub(crate) fn commit_tx_fee_sat(feerate_per_kw: u32, num_htlcs: usize, channel_t
199199
pub(crate) fn per_outbound_htlc_counterparty_commit_tx_fee_msat(feerate_per_kw: u32, channel_type_features: &ChannelTypeFeatures) -> u64 {
200200
// Note that we need to divide before multiplying to round properly,
201201
// since the lowest denomination of bitcoin on-chain is the satoshi.
202-
let commitment_tx_fee = COMMITMENT_TX_WEIGHT_PER_HTLC * feerate_per_kw as u64 / 1000 * 1000;
202+
let commitment_tx_fee_msat = COMMITMENT_TX_WEIGHT_PER_HTLC * feerate_per_kw as u64 / 1000 * 1000;
203203
if channel_type_features.supports_anchors_zero_fee_htlc_tx() {
204-
commitment_tx_fee
204+
commitment_tx_fee_msat
205205
} else {
206-
commitment_tx_fee + htlc_success_tx_weight(channel_type_features) * feerate_per_kw as u64 / 1000
206+
commitment_tx_fee_msat + htlc_success_tx_weight(channel_type_features) * feerate_per_kw as u64
207207
}
208208
}
209209

lightning/src/ln/channel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3669,10 +3669,10 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
36693669
if !self.channel_type.supports_anchors_zero_fee_htlc_tx() {
36703670
on_counterparty_tx_dust_exposure_msat +=
36713671
on_counterparty_tx_accepted_nondust_htlcs as u64 * htlc_success_tx_weight(&self.channel_type)
3672-
* excess_feerate as u64 / 1000;
3672+
* excess_feerate as u64;
36733673
on_counterparty_tx_dust_exposure_msat +=
36743674
on_counterparty_tx_offered_nondust_htlcs as u64 * htlc_timeout_tx_weight(&self.channel_type)
3675-
* excess_feerate as u64 / 1000;
3675+
* excess_feerate as u64;
36763676
}
36773677
}
36783678

0 commit comments

Comments
 (0)