Skip to content

Commit ef585bb

Browse files
committed
f use helper
1 parent 80b18f1 commit ef585bb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lightning/src/ln/channel.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,9 @@ impl<Signer: Sign> Channel<Signer> {
672672
let feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
673673

674674
let value_to_self_msat = channel_value_satoshis * 1000 - push_msat;
675-
let commitment_tx_fee = feerate as u64 * (COMMITMENT_TX_BASE_WEIGHT + 4 * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000;
676-
if value_to_self_msat / 1000 < commitment_tx_fee {
677-
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) });
675+
let commitment_tx_fee = Self::commit_tx_fee_msat(feerate, 4);
676+
if value_to_self_msat < commitment_tx_fee {
677+
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) });
678678
}
679679

680680
let mut secp_ctx = Secp256k1::new();
@@ -932,7 +932,7 @@ impl<Signer: Sign> Channel<Signer> {
932932
// for full fee payment. We somewhat arbitrarily pick 4 HTLC outputs here - the funder
933933
// should be able to afford at least that many.
934934
let funders_amount_msat = msg.funding_satoshis * 1000 - msg.push_msat;
935-
let commitment_tx_fee = msg.feerate_per_kw as u64 * (COMMITMENT_TX_BASE_WEIGHT + 4 * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000;
935+
let commitment_tx_fee = Self::commit_tx_fee_msat(msg.feerate_per_kw, 4) / 1000;
936936
if funders_amount_msat / 1000 < commitment_tx_fee {
937937
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)));
938938
}

0 commit comments

Comments
 (0)