@@ -41,10 +41,11 @@ use crate::ln::chan_utils;
4141#[cfg(splicing)]
4242use crate::ln::chan_utils::FUNDING_TRANSACTION_WITNESS_WEIGHT;
4343use crate::ln::chan_utils::{
44- get_commitment_transaction_number_obscure_factor, htlc_success_tx_weight,
45- htlc_timeout_tx_weight, max_htlcs, ChannelPublicKeys, ChannelTransactionParameters,
46- ClosingTransaction, CommitmentTransaction, CounterpartyChannelTransactionParameters,
47- CounterpartyCommitmentSecrets, HTLCOutputInCommitment, HolderCommitmentTransaction,
44+ commitment_sat_per_1000_weight_for_type, get_commitment_transaction_number_obscure_factor,
45+ htlc_success_tx_weight, htlc_timeout_tx_weight, max_htlcs, ChannelPublicKeys,
46+ ChannelTransactionParameters, ClosingTransaction, CommitmentTransaction,
47+ CounterpartyChannelTransactionParameters, CounterpartyCommitmentSecrets,
48+ HTLCOutputInCommitment, HolderCommitmentTransaction,
4849};
4950use crate::ln::channel_state::{
5051 ChannelShutdownState, CounterpartyForwardingInfo, InboundHTLCDetails, InboundHTLCStateDetails,
@@ -3398,16 +3399,7 @@ where
33983399 debug_assert!(!channel_type.supports_any_optional_bits());
33993400 debug_assert!(!channel_type.requires_unknown_bits_from(&channelmanager::provided_channel_type_features(&config)));
34003401
3401- let commitment_feerate = if channel_type.supports_anchor_zero_fee_commitments() {
3402- 0
3403- } else {
3404- let commitment_conf_target = if channel_type.supports_anchors_zero_fee_htlc_tx() {
3405- ConfirmationTarget::AnchorChannelFee
3406- } else {
3407- ConfirmationTarget::NonAnchorChannelFee
3408- };
3409- fee_estimator.bounded_sat_per_1000_weight(commitment_conf_target)
3410- };
3402+ let commitment_feerate = commitment_sat_per_1000_weight_for_type(&fee_estimator, &channel_type);
34113403
34123404 let value_to_self_msat = channel_value_satoshis * 1000 - push_msat;
34133405 let commit_tx_fee_sat = SpecTxBuilder {}.commit_tx_fee_sat(commitment_feerate, MIN_AFFORDABLE_HTLC_COUNT, &channel_type);
@@ -5449,20 +5441,7 @@ where
54495441
54505442 let next_channel_type = get_initial_channel_type(user_config, &eligible_features);
54515443
5452- // Note that we can't get `anchor_zero_fee_commitments` type here, which requires zero
5453- // fees, because we downgrade from this channel type first. If there were a superior
5454- // channel type that downgrades to `anchor_zero_fee_commitments`, we'd need to handle
5455- // fee setting differently here. If we proceeded to open a `anchor_zero_fee_commitments`
5456- // channel with non-zero fees, we could produce a non-standard commitment transaction that
5457- // puts us at risk of losing funds. We would expect our peer to reject such a channel
5458- // open, but we don't want to rely on their validation.
5459- assert!(!next_channel_type.supports_anchor_zero_fee_commitments());
5460- let conf_target = if next_channel_type.supports_anchors_zero_fee_htlc_tx() {
5461- ConfirmationTarget::AnchorChannelFee
5462- } else {
5463- ConfirmationTarget::NonAnchorChannelFee
5464- };
5465- self.feerate_per_kw = fee_estimator.bounded_sat_per_1000_weight(conf_target);
5444+ self.feerate_per_kw = commitment_sat_per_1000_weight_for_type(&fee_estimator, &next_channel_type);
54665445 funding.channel_transaction_parameters.channel_type_features = next_channel_type;
54675446
54685447 Ok(())
0 commit comments