Skip to content

Commit caee5e8

Browse files
committed
fixup: Add TxBuilder::get_next_commitment_stats
Cleanup `HTLCAmountDirection::is_dust`
1 parent 0c7ea78 commit caee5e8

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub(crate) fn commit_tx_fee_sat(feerate_per_kw: u32, num_htlcs: usize, channel_t
236236
}
237237

238238
/// Returns the fees for success and timeout second stage HTLC transactions.
239-
pub(super) fn second_stage_tx_fees_sat(
239+
pub(crate) fn second_stage_tx_fees_sat(
240240
channel_type: &ChannelTypeFeatures, feerate_sat_per_1000_weight: u32,
241241
) -> (u64, u64) {
242242
if channel_type.supports_anchors_zero_fee_htlc_tx()

lightning/src/sign/tx_builder.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use bitcoin::secp256k1::{self, PublicKey, Secp256k1};
88

99
use crate::ln::chan_utils::{
1010
commit_tx_fee_sat, htlc_success_tx_weight, htlc_timeout_tx_weight, htlc_tx_fees_sat,
11-
ChannelTransactionParameters, CommitmentTransaction, HTLCOutputInCommitment,
11+
second_stage_tx_fees_sat, ChannelTransactionParameters, CommitmentTransaction,
12+
HTLCOutputInCommitment,
1213
};
1314
use crate::ln::channel::{CommitmentStats, ANCHOR_OUTPUT_VALUE_SATOSHI};
1415
use crate::prelude::*;
@@ -25,17 +26,10 @@ impl HTLCAmountDirection {
2526
&self, local: bool, feerate_per_kw: u32, broadcaster_dust_limit_satoshis: u64,
2627
channel_type: &ChannelTypeFeatures,
2728
) -> bool {
28-
let htlc_tx_fee_sat = if channel_type.supports_anchors_zero_fee_htlc_tx() {
29-
0
30-
} else {
31-
let htlc_tx_weight = if self.outbound == local {
32-
htlc_timeout_tx_weight(channel_type)
33-
} else {
34-
htlc_success_tx_weight(channel_type)
35-
};
36-
// As required by the spec, round down
37-
feerate_per_kw as u64 * htlc_tx_weight / 1000
38-
};
29+
let (success_tx_fee_sat, timeout_tx_fee_sat) =
30+
second_stage_tx_fees_sat(channel_type, feerate_per_kw);
31+
let htlc_tx_fee_sat =
32+
if self.outbound == local { timeout_tx_fee_sat } else { success_tx_fee_sat };
3933
self.amount_msat / 1000 < broadcaster_dust_limit_satoshis + htlc_tx_fee_sat
4034
}
4135
}

0 commit comments

Comments
 (0)