Skip to content

Commit 2464077

Browse files
committed
Do not round per_outbound_htlc_counterparty_commit_tx_fee_msat
The goal is to align `per_outbound_htlc_counterparty_commit_tx_fee_msat` with the slope `commit_tx_fee_sat` / `num_htlcs`. This is a minor detail - no existing LDK code multiplies the value returned by `per_outbound_htlc_counterparty_commit_tx_fee_msat` with `num_htlcs`.
1 parent a98886c commit 2464077

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ pub(crate) fn commit_tx_fee_sat(feerate_per_kw: u32, num_htlcs: usize, channel_t
197197
}
198198

199199
pub(crate) fn per_outbound_htlc_counterparty_commit_tx_fee_msat(feerate_per_kw: u32, channel_type_features: &ChannelTypeFeatures) -> u64 {
200-
// Note that we need to divide before multiplying to round properly,
201-
// since the lowest denomination of bitcoin on-chain is the satoshi.
202-
let commitment_tx_fee_msat = COMMITMENT_TX_WEIGHT_PER_HTLC * feerate_per_kw as u64 / 1000 * 1000;
200+
// We avoid rounding here to make the returned value consistent with the slope (commit_tx_fee_sat/num_htlcs)
201+
let commitment_tx_fee_msat = COMMITMENT_TX_WEIGHT_PER_HTLC * feerate_per_kw as u64;
203202
if channel_type_features.supports_anchors_zero_fee_htlc_tx() {
204203
commitment_tx_fee_msat
205204
} else {

0 commit comments

Comments
 (0)