@@ -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,
@@ -3416,16 +3417,7 @@ where
34163417 debug_assert!(!channel_type.supports_any_optional_bits());
34173418 debug_assert!(!channel_type.requires_unknown_bits_from(&channelmanager::provided_channel_type_features(&config)));
34183419
3419- let commitment_feerate = if channel_type.supports_anchor_zero_fee_commitments() {
3420- 0
3421- } else {
3422- let commitment_conf_target = if channel_type.supports_anchors_zero_fee_htlc_tx() {
3423- ConfirmationTarget::AnchorChannelFee
3424- } else {
3425- ConfirmationTarget::NonAnchorChannelFee
3426- };
3427- fee_estimator.bounded_sat_per_1000_weight(commitment_conf_target)
3428- };
3420+ let commitment_feerate = commitment_sat_per_1000_weight_for_type(&fee_estimator, &channel_type);
34293421
34303422 let value_to_self_msat = channel_value_satoshis * 1000 - push_msat;
34313423 let commit_tx_fee_sat = SpecTxBuilder {}.commit_tx_fee_sat(commitment_feerate, MIN_AFFORDABLE_HTLC_COUNT, &channel_type);
@@ -5462,20 +5454,7 @@ where
54625454
54635455 let next_channel_type = get_initial_channel_type(user_config, &eligible_features);
54645456
5465- // Note that we can't get `anchor_zero_fee_commitments` type here, which requires zero
5466- // fees, because we downgrade from this channel type first. If there were a superior
5467- // channel type that downgrades to `anchor_zero_fee_commitments`, we'd need to handle
5468- // fee setting differently here. If we proceeded to open a `anchor_zero_fee_commitments`
5469- // channel with non-zero fees, we could produce a non-standard commitment transaction that
5470- // puts us at risk of losing funds. We would expect our peer to reject such a channel
5471- // open, but we don't want to rely on their validation.
5472- assert!(!next_channel_type.supports_anchor_zero_fee_commitments());
5473- let conf_target = if next_channel_type.supports_anchors_zero_fee_htlc_tx() {
5474- ConfirmationTarget::AnchorChannelFee
5475- } else {
5476- ConfirmationTarget::NonAnchorChannelFee
5477- };
5478- self.feerate_per_kw = fee_estimator.bounded_sat_per_1000_weight(conf_target);
5457+ self.feerate_per_kw = commitment_sat_per_1000_weight_for_type(&fee_estimator, &next_channel_type);
54795458 funding.channel_transaction_parameters.channel_type_features = next_channel_type;
54805459
54815460 Ok(())
0 commit comments