@@ -3049,14 +3049,21 @@ where
3049
3049
// check if the funder's amount for the initial commitment tx is sufficient
3050
3050
// for full fee payment plus a few HTLCs to ensure the channel will be useful.
3051
3051
let funders_amount_msat = open_channel_fields.funding_satoshis * 1000 - msg_push_msat;
3052
- let commit_tx_fee_sat = SpecTxBuilder {}.commit_tx_fee_sat(open_channel_fields.commitment_feerate_sat_per_1000_weight, MIN_AFFORDABLE_HTLC_COUNT, &channel_type);
3053
- // Subtract any non-HTLC outputs from the remote balance
3054
- let (_, remote_balance_before_fee_msat) = SpecTxBuilder {}.subtract_non_htlc_outputs(false, value_to_self_msat, funders_amount_msat, &channel_type);
3055
- if remote_balance_before_fee_msat / 1000 < commit_tx_fee_sat {
3056
- return Err(ChannelError::close(format!("Funding amount ({} sats) can't even pay fee for initial commitment transaction fee of {} sats.", funders_amount_msat / 1000, commit_tx_fee_sat)));
3052
+ let local = false;
3053
+ let is_outbound_from_holder = false;
3054
+ let dust_exposure_limiting_feerate = if channel_type.supports_anchor_zero_fee_commitments() {
3055
+ None
3056
+ } else {
3057
+ Some(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::MaximumFeeEstimate))
3058
+ };
3059
+ let remote_stats = SpecTxBuilder {}.get_next_commitment_stats(local, is_outbound_from_holder, open_channel_fields.funding_satoshis, msg_push_msat, &[], MIN_AFFORDABLE_HTLC_COUNT,
3060
+ open_channel_fields.commitment_feerate_sat_per_1000_weight, dust_exposure_limiting_feerate, open_channel_fields.dust_limit_satoshis, &channel_type);
3061
+ let remote_balance_before_fee_msat = remote_stats.counterparty_balance_before_fee_msat.ok_or(ChannelError::close(format!("Funding amount ({} sats) can't even pay for non-HTLC outputs ie anchors.", funders_amount_msat / 1000)))?;
3062
+ if remote_balance_before_fee_msat / 1000 < remote_stats.commit_tx_fee_sat {
3063
+ return Err(ChannelError::close(format!("Funding amount ({} sats) can't even pay fee for initial commitment transaction fee of {} sats.", funders_amount_msat / 1000, remote_stats.commit_tx_fee_sat)));
3057
3064
}
3058
3065
3059
- let to_remote_satoshis = remote_balance_before_fee_msat / 1000 - commit_tx_fee_sat;
3066
+ let to_remote_satoshis = remote_balance_before_fee_msat / 1000 - remote_stats. commit_tx_fee_sat;
3060
3067
// While it's reasonable for us to not meet the channel reserve initially (if they don't
3061
3068
// want to push much to us), our counterparty should always have more than our reserve.
3062
3069
if to_remote_satoshis < holder_selected_channel_reserve_satoshis {
@@ -3132,7 +3139,7 @@ where
3132
3139
channel_transaction_parameters: ChannelTransactionParameters {
3133
3140
holder_pubkeys: pubkeys,
3134
3141
holder_selected_contest_delay: config.channel_handshake_config.our_to_self_delay,
3135
- is_outbound_from_holder: false ,
3142
+ is_outbound_from_holder,
3136
3143
counterparty_parameters: Some(CounterpartyChannelTransactionParameters {
3137
3144
selected_contest_delay: open_channel_fields.to_self_delay,
3138
3145
pubkeys: counterparty_pubkeys,
0 commit comments