@@ -54,7 +54,9 @@ use crate::chain::chaininterface::{FeeEstimator, ConfirmationTarget, LowerBounde
5454use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateStep, LATENCY_GRACE_PERIOD_BLOCKS};
5555use crate::chain::transaction::{OutPoint, TransactionData};
5656use crate::sign::ecdsa::EcdsaChannelSigner;
57- use crate::sign::{EntropySource, ChannelSigner, SignerProvider, NodeSigner, Recipient, P2WPKH_WITNESS_WEIGHT};
57+ use crate::sign::{EntropySource, ChannelSigner, SignerProvider, NodeSigner, Recipient};
58+ #[cfg(splicing)]
59+ use crate::sign::P2WPKH_WITNESS_WEIGHT;
5860use crate::events::{ClosureReason, Event};
5961use crate::events::bump_transaction::BASE_INPUT_WEIGHT;
6062use crate::routing::gossip::NodeId;
@@ -8128,10 +8130,12 @@ impl<SP: Deref> FundedChannel<SP> where
81288130 }
81298131 }
81308132
8131- /// Initiate splicing
8133+ /// Initiate splicing.
8134+ /// - witness_weight: The witness weight for contributed inputs.
81328135 #[cfg(splicing)]
81338136 pub fn splice_channel(&mut self, our_funding_contribution_satoshis: i64,
8134- our_funding_inputs: Vec<(TxIn, Transaction)>, funding_feerate_per_kw: u32, locktime: u32,
8137+ our_funding_inputs: Vec<(TxIn, Transaction)>, witness_weight: Weight,
8138+ funding_feerate_per_kw: u32, locktime: u32,
81358139 ) -> Result<msgs::SpliceInit, ChannelError> {
81368140 // Check if a splice has been initiated already.
81378141 // Note: only a single outstanding splice is supported (per spec)
@@ -8174,10 +8178,10 @@ impl<SP: Deref> FundedChannel<SP> where
81748178
81758179 // The +1 is to include the input of the old funding
81768180 let funding_input_count = our_funding_inputs.len() + 1;
8177- // Add weight for inputs (estimated as P2WPKH) *and* spending old funding
8181+ // Input witness weight, extended with weight for spending old funding
81788182 let total_witness_weight = Weight::from_wu(
8179- our_funding_inputs.len() as u64 * P2WPKH_WITNESS_WEIGHT +
8180- 2 * P2WPKH_WITNESS_WEIGHT
8183+ witness_weight.to_wu()
8184+ .saturating_add( 2 * P2WPKH_WITNESS_WEIGHT)
81818185 );
81828186 let estimated_fee = estimate_funding_transaction_fee(true, funding_input_count, total_witness_weight, funding_feerate_per_kw);
81838187 let available_input = sum_input.saturating_sub(estimated_fee);
0 commit comments