Skip to content

Commit ad1778a

Browse files
committed
Add TxBuilder::build_commitment_stats
1 parent 3ba5c8b commit ad1778a

File tree

4 files changed

+335
-209
lines changed

4 files changed

+335
-209
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,22 @@ pub(crate) fn commit_tx_fee_sat(feerate_per_kw: u32, num_htlcs: usize, channel_t
233233
/ 1000
234234
}
235235

236-
#[rustfmt::skip]
237-
pub(crate) fn commit_and_htlc_tx_fees_sat(feerate_per_kw: u32, num_accepted_htlcs: usize, num_offered_htlcs: usize, channel_type_features: &ChannelTypeFeatures) -> u64 {
238-
let num_htlcs = num_accepted_htlcs + num_offered_htlcs;
239-
let commit_tx_fees_sat = commit_tx_fee_sat(feerate_per_kw, num_htlcs, channel_type_features);
236+
pub(crate) fn htlc_tx_fees_sat(
237+
feerate_per_kw: u32, num_accepted_htlcs: usize, num_offered_htlcs: usize,
238+
channel_type_features: &ChannelTypeFeatures,
239+
) -> u64 {
240240
let htlc_tx_fees_sat = if !channel_type_features.supports_anchors_zero_fee_htlc_tx() {
241-
num_accepted_htlcs as u64 * htlc_success_tx_weight(channel_type_features) * feerate_per_kw as u64 / 1000
242-
+ num_offered_htlcs as u64 * htlc_timeout_tx_weight(channel_type_features) * feerate_per_kw as u64 / 1000
241+
num_accepted_htlcs as u64
242+
* htlc_success_tx_weight(channel_type_features)
243+
* feerate_per_kw as u64
244+
/ 1000 + num_offered_htlcs as u64
245+
* htlc_timeout_tx_weight(channel_type_features)
246+
* feerate_per_kw as u64
247+
/ 1000
243248
} else {
244249
0
245250
};
246-
commit_tx_fees_sat + htlc_tx_fees_sat
251+
htlc_tx_fees_sat
247252
}
248253

249254
// Various functions for key derivation and transaction creation for use within channels. Primarily

0 commit comments

Comments
 (0)