@@ -685,9 +685,9 @@ impl<Signer: Sign> Channel<Signer> {
685
685
let feerate = fee_estimator. get_est_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
686
686
687
687
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 ) } ) ;
691
691
}
692
692
693
693
let mut secp_ctx = Secp256k1 :: new ( ) ;
@@ -949,7 +949,7 @@ impl<Signer: Sign> Channel<Signer> {
949
949
// for full fee payment. We somewhat arbitrarily pick 4 HTLC outputs here - the funder
950
950
// should be able to afford at least that many.
951
951
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 ;
953
953
if funders_amount_msat / 1000 < commitment_tx_fee {
954
954
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) ) ) ;
955
955
}
0 commit comments