@@ -10206,35 +10206,41 @@ where
1020610206 /// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
1020710207 /// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
1020810208 #[cfg(splicing)]
10209- #[rustfmt::skip]
10210- pub fn splice_channel( &mut self, our_funding_contribution_satoshis: i64,
10211- our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
10212- funding_feerate_per_kw: u32, locktime: u32,
10209+ pub fn splice_channel(
10210+ &mut self, our_funding_contribution_satoshis: i64,
10211+ our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
10212+ locktime: u32,
1021310213 ) -> Result<msgs::SpliceInit, APIError> {
1021410214 // Check if a splice has been initiated already.
1021510215 // Note: only a single outstanding splice is supported (per spec)
1021610216 if let Some(pending_splice) = &self.pending_splice {
10217- return Err(APIError::APIMisuseError { err: format!(
10217+ return Err(APIError::APIMisuseError {
10218+ err: format!(
1021810219 "Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
1021910220 self.context.channel_id(),
1022010221 pending_splice.our_funding_contribution,
10221- )});
10222+ ),
10223+ });
1022210224 }
1022310225
1022410226 if !self.context.is_live() {
10225- return Err(APIError::APIMisuseError { err: format!(
10226- "Channel {} cannot be spliced, as channel is not live",
10227- self.context.channel_id()
10228- )});
10227+ return Err(APIError::APIMisuseError {
10228+ err: format!(
10229+ "Channel {} cannot be spliced, as channel is not live",
10230+ self.context.channel_id()
10231+ ),
10232+ });
1022910233 }
1023010234
1023110235 // TODO(splicing): check for quiescence
1023210236
1023310237 if our_funding_contribution_satoshis < 0 {
10234- return Err(APIError::APIMisuseError { err: format!(
10238+ return Err(APIError::APIMisuseError {
10239+ err: format!(
1023510240 "TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
1023610241 self.context.channel_id(), our_funding_contribution_satoshis,
10237- )});
10242+ ),
10243+ });
1023810244 }
1023910245
1024010246 // TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10244,20 +10250,30 @@ where
1024410250 // (Cannot test for miminum required post-splice channel value)
1024510251
1024610252 // Check that inputs are sufficient to cover our contribution.
10247- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, true, funding_feerate_per_kw)
10248- .map_err(|err| APIError::APIMisuseError { err: format!(
10253+ let _fee = check_v2_funding_inputs_sufficient(
10254+ our_funding_contribution_satoshis,
10255+ &our_funding_inputs,
10256+ true,
10257+ true,
10258+ funding_feerate_per_kw,
10259+ )
10260+ .map_err(|err| APIError::APIMisuseError {
10261+ err: format!(
1024910262 "Insufficient inputs for splicing; channel ID {}, err {}",
10250- self.context.channel_id(), err,
10251- )})?;
10263+ self.context.channel_id(),
10264+ err,
10265+ ),
10266+ })?;
1025210267 // Convert inputs
1025310268 let mut funding_inputs = Vec::new();
1025410269 for (tx_in, tx, _w) in our_funding_inputs.into_iter() {
10255- let tx16 = TransactionU16LenLimited::new(tx.clone()).map_err(|_e| APIError::APIMisuseError { err: format!("Too large transaction")})?;
10270+ let tx16 = TransactionU16LenLimited::new(tx.clone())
10271+ .map_err(|_e| APIError::APIMisuseError { err: format!("Too large transaction") })?;
1025610272 funding_inputs.push((tx_in.clone(), tx16));
1025710273 }
1025810274
1025910275 let funding_negotiation_context = FundingNegotiationContext {
10260- our_funding_satoshis: 0, // set at later phase
10276+ our_funding_satoshis: 0, // set at later phase
1026110277 their_funding_satoshis: None, // set at later phase
1026210278 funding_tx_locktime: LockTime::from_consensus(locktime),
1026310279 funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10273,7 +10289,11 @@ where
1027310289 received_funding_txid: None,
1027410290 });
1027510291
10276- let msg = self.get_splice_init(our_funding_contribution_satoshis, funding_feerate_per_kw, locktime);
10292+ let msg = self.get_splice_init(
10293+ our_funding_contribution_satoshis,
10294+ funding_feerate_per_kw,
10295+ locktime,
10296+ );
1027710297 Ok(msg)
1027810298 }
1027910299
0 commit comments