@@ -3327,16 +3327,19 @@ where
3327
3327
);
3328
3328
3329
3329
let value_to_self_msat = channel_value_satoshis * 1000 - push_msat;
3330
- let commit_tx_fee_sat = SpecTxBuilder {}.commit_tx_fee_sat(commitment_feerate, MIN_AFFORDABLE_HTLC_COUNT, &channel_type);
3331
- // Subtract any non-HTLC outputs from the local balance
3332
- let (local_balance_before_fee_msat, _) = SpecTxBuilder {}.subtract_non_htlc_outputs(
3333
- true,
3334
- value_to_self_msat,
3335
- push_msat,
3336
- &channel_type,
3337
- );
3338
- if local_balance_before_fee_msat / 1000 < commit_tx_fee_sat {
3339
- 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) });
3330
+ let local = true;
3331
+ let is_outbound_from_holder = true;
3332
+ let value_to_holder_msat = channel_value_msat - push_msat;
3333
+ let dust_exposure_limiting_feerate = if channel_type.supports_anchor_zero_fee_commitments() {
3334
+ None
3335
+ } else {
3336
+ Some(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::MaximumFeeEstimate))
3337
+ };
3338
+ let local_stats = SpecTxBuilder {}.get_next_commitment_stats(local, is_outbound_from_holder, channel_value_satoshis, value_to_holder_msat, &[], MIN_AFFORDABLE_HTLC_COUNT,
3339
+ commitment_feerate, dust_exposure_limiting_feerate, MIN_CHAN_DUST_LIMIT_SATOSHIS, &channel_type);
3340
+ 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) })?;
3341
+ if local_balance_before_fee_msat / 1000 < local_stats.commit_tx_fee_sat {
3342
+ 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) });
3340
3343
}
3341
3344
3342
3345
let mut secp_ctx = Secp256k1::new();
@@ -3384,7 +3387,7 @@ where
3384
3387
channel_transaction_parameters: ChannelTransactionParameters {
3385
3388
holder_pubkeys: pubkeys,
3386
3389
holder_selected_contest_delay: config.channel_handshake_config.our_to_self_delay,
3387
- is_outbound_from_holder: true ,
3390
+ is_outbound_from_holder,
3388
3391
counterparty_parameters: None,
3389
3392
funding_outpoint: None,
3390
3393
splice_parent_funding_txid: None,
0 commit comments