@@ -672,9 +672,9 @@ impl<Signer: Sign> Channel<Signer> {
672
672
let feerate = fee_estimator. get_est_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
673
673
674
674
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 ) } ) ;
678
678
}
679
679
680
680
let mut secp_ctx = Secp256k1 :: new ( ) ;
@@ -932,7 +932,7 @@ impl<Signer: Sign> Channel<Signer> {
932
932
// for full fee payment. We somewhat arbitrarily pick 4 HTLC outputs here - the funder
933
933
// should be able to afford at least that many.
934
934
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 ;
936
936
if funders_amount_msat / 1000 < commitment_tx_fee {
937
937
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) ) ) ;
938
938
}
0 commit comments