Skip to content

Commit 1d98aa5

Browse files
committed
f use helper
1 parent b01a84c commit 1d98aa5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,9 @@ impl<Signer: Sign> Channel<Signer> {
685685
let feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
686686

687687
let value_to_self_msat = channel_value_satoshis * 1000 - push_msat;
688-
let commitment_tx_fee = feerate as u64 * (COMMITMENT_TX_BASE_WEIGHT + 4 * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000;
689-
if value_to_self_msat / 1000 < commitment_tx_fee {
690-
return Err(APIError::APIMisuseError{ err: format!("Funding amount ({}) can't even pay fee for initial commitment transaction fee of {}.", value_to_self_msat / 1000, commitment_tx_fee) });
688+
let commitment_tx_fee = Self::commit_tx_fee_msat(feerate, 4);
689+
if value_to_self_msat < commitment_tx_fee {
690+
return Err(APIError::APIMisuseError{ err: format!("Funding amount ({}) can't even pay fee for initial commitment transaction fee of {}.", value_to_self_msat / 1000, commitment_tx_fee / 1000) });
691691
}
692692

693693
let mut secp_ctx = Secp256k1::new();
@@ -949,7 +949,7 @@ impl<Signer: Sign> Channel<Signer> {
949949
// for full fee payment. We somewhat arbitrarily pick 4 HTLC outputs here - the funder
950950
// should be able to afford at least that many.
951951
let funders_amount_msat = msg.funding_satoshis * 1000 - msg.push_msat;
952-
let commitment_tx_fee = msg.feerate_per_kw as u64 * (COMMITMENT_TX_BASE_WEIGHT + 4 * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000;
952+
let commitment_tx_fee = Self::commit_tx_fee_msat(msg.feerate_per_kw, 4) / 1000;
953953
if funders_amount_msat / 1000 < commitment_tx_fee {
954954
return Err(ChannelError::Close(format!("Funding amount ({} sats) can't even pay fee for initial commitment transaction fee of {} sats.", funders_amount_msat / 1000, commitment_tx_fee)));
955955
}

0 commit comments

Comments
 (0)