@@ -3322,16 +3322,19 @@ where
3322
3322
);
3323
3323
3324
3324
let value_to_self_msat = channel_value_satoshis * 1000 - push_msat;
3325
- let commit_tx_fee_sat = SpecTxBuilder {}.commit_tx_fee_sat(commitment_feerate, MIN_AFFORDABLE_HTLC_COUNT, &channel_type);
3326
- // Subtract any non-HTLC outputs from the local balance
3327
- let (local_balance_before_fee_msat, _) = SpecTxBuilder {}.subtract_non_htlc_outputs(
3328
- true,
3329
- value_to_self_msat,
3330
- push_msat,
3331
- &channel_type,
3332
- );
3333
- if local_balance_before_fee_msat / 1000 < commit_tx_fee_sat {
3334
- return Err(APIError::APIMisuseError{ err: format!("Funding amount ({}) can't even pay fee for initial commitment transaction fee of {}.", value_to_self_msat / 1000, commit_tx_fee_sat) });
3325
+ let local = true;
3326
+ let is_outbound_from_holder = true;
3327
+ let value_to_holder_msat = channel_value_msat - push_msat;
3328
+ let dust_exposure_limiting_feerate = if channel_type.supports_anchor_zero_fee_commitments() {
3329
+ None
3330
+ } else {
3331
+ Some(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::MaximumFeeEstimate))
3332
+ };
3333
+ let local_stats = SpecTxBuilder {}.get_next_commitment_stats(local, is_outbound_from_holder, channel_value_satoshis, value_to_holder_msat, &[], MIN_AFFORDABLE_HTLC_COUNT,
3334
+ commitment_feerate, dust_exposure_limiting_feerate, MIN_CHAN_DUST_LIMIT_SATOSHIS, &channel_type);
3335
+ let local_balance_before_fee_msat = local_stats.holder_balance_before_fee_msat.ok_or(APIError::APIMisuseError { err: format!("Funding amount ({} sats) can't even pay for non-HTLC outputs ie anchors.", value_to_self_msat / 1000) })?;
3336
+ if local_balance_before_fee_msat / 1000 < local_stats.commit_tx_fee_sat {
3337
+ return Err(APIError::APIMisuseError{ err: format!("Funding amount ({}) can't even pay fee for initial commitment transaction fee of {}.", value_to_self_msat / 1000, local_stats.commit_tx_fee_sat) });
3335
3338
}
3336
3339
3337
3340
let mut secp_ctx = Secp256k1::new();
@@ -3379,7 +3382,7 @@ where
3379
3382
channel_transaction_parameters: ChannelTransactionParameters {
3380
3383
holder_pubkeys: pubkeys,
3381
3384
holder_selected_contest_delay: config.channel_handshake_config.our_to_self_delay,
3382
- is_outbound_from_holder: true ,
3385
+ is_outbound_from_holder,
3383
3386
counterparty_parameters: None,
3384
3387
funding_outpoint: None,
3385
3388
splice_parent_funding_txid: None,
0 commit comments