@@ -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;
@@ -8216,10 +8218,12 @@ impl<SP: Deref> FundedChannel<SP> where
82168218 }
82178219 }
82188220
8219- /// Initiate splicing
8221+ /// Initiate splicing.
8222+ /// - witness_weight: The witness weight for contributed inputs.
82208223 #[cfg(splicing)]
82218224 pub fn splice_channel(&mut self, our_funding_contribution_satoshis: i64,
8222- our_funding_inputs: Vec<(TxIn, Transaction)>, funding_feerate_per_kw: u32, locktime: u32,
8225+ our_funding_inputs: Vec<(TxIn, Transaction)>, witness_weight: Weight,
8226+ funding_feerate_per_kw: u32, locktime: u32,
82238227 ) -> Result<msgs::SpliceInit, ChannelError> {
82248228 // Check if a splice has been initiated already.
82258229 // Note: only a single outstanding splice is supported (per spec)
@@ -8262,10 +8266,10 @@ impl<SP: Deref> FundedChannel<SP> where
82628266
82638267 // The +1 is to include the input of the old funding
82648268 let funding_input_count = our_funding_inputs.len() + 1;
8265- // Add weight for inputs (estimated as P2WPKH) *and* spending old funding
8269+ // Input witness weight, extended with weight for spending old funding
82668270 let total_witness_weight = Weight::from_wu(
8267- our_funding_inputs.len() as u64 * P2WPKH_WITNESS_WEIGHT +
8268- 2 * P2WPKH_WITNESS_WEIGHT
8271+ witness_weight.to_wu()
8272+ .saturating_add( 2 * P2WPKH_WITNESS_WEIGHT)
82698273 );
82708274 let estimated_fee = estimate_funding_transaction_fee(true, funding_input_count, total_witness_weight, funding_feerate_per_kw);
82718275 let available_input = sum_input.saturating_sub(estimated_fee);
0 commit comments