@@ -10437,35 +10437,41 @@ where
1043710437 /// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
1043810438 /// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
1043910439 #[cfg(splicing)]
10440- #[rustfmt::skip]
10441- pub fn splice_channel( &mut self, our_funding_contribution_satoshis: i64,
10442- our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
10443- funding_feerate_per_kw: u32, locktime: u32,
10440+ pub fn splice_channel(
10441+ &mut self, our_funding_contribution_satoshis: i64,
10442+ our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
10443+ locktime: u32,
1044410444 ) -> Result<msgs::SpliceInit, APIError> {
1044510445 // Check if a splice has been initiated already.
1044610446 // Note: only a single outstanding splice is supported (per spec)
1044710447 if let Some(pending_splice) = &self.pending_splice {
10448- return Err(APIError::APIMisuseError { err: format!(
10448+ return Err(APIError::APIMisuseError {
10449+ err: format!(
1044910450 "Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
1045010451 self.context.channel_id(),
1045110452 pending_splice.our_funding_contribution,
10452- )});
10453+ ),
10454+ });
1045310455 }
1045410456
1045510457 if !self.context.is_live() {
10456- return Err(APIError::APIMisuseError { err: format!(
10457- "Channel {} cannot be spliced, as channel is not live",
10458- self.context.channel_id()
10459- )});
10458+ return Err(APIError::APIMisuseError {
10459+ err: format!(
10460+ "Channel {} cannot be spliced, as channel is not live",
10461+ self.context.channel_id()
10462+ ),
10463+ });
1046010464 }
1046110465
1046210466 // TODO(splicing): check for quiescence
1046310467
1046410468 if our_funding_contribution_satoshis < 0 {
10465- return Err(APIError::APIMisuseError { err: format!(
10469+ return Err(APIError::APIMisuseError {
10470+ err: format!(
1046610471 "TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
1046710472 self.context.channel_id(), our_funding_contribution_satoshis,
10468- )});
10473+ ),
10474+ });
1046910475 }
1047010476
1047110477 // TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10475,20 +10481,30 @@ where
1047510481 // (Cannot test for miminum required post-splice channel value)
1047610482
1047710483 // Check that inputs are sufficient to cover our contribution.
10478- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, true, funding_feerate_per_kw)
10479- .map_err(|err| APIError::APIMisuseError { err: format!(
10484+ let _fee = check_v2_funding_inputs_sufficient(
10485+ our_funding_contribution_satoshis,
10486+ &our_funding_inputs,
10487+ true,
10488+ true,
10489+ funding_feerate_per_kw,
10490+ )
10491+ .map_err(|err| APIError::APIMisuseError {
10492+ err: format!(
1048010493 "Insufficient inputs for splicing; channel ID {}, err {}",
10481- self.context.channel_id(), err,
10482- )})?;
10494+ self.context.channel_id(),
10495+ err,
10496+ ),
10497+ })?;
1048310498 // Convert inputs
1048410499 let mut funding_inputs = Vec::new();
1048510500 for (tx_in, tx, _w) in our_funding_inputs.into_iter() {
10486- let tx16 = TransactionU16LenLimited::new(tx.clone()).map_err(|_e| APIError::APIMisuseError { err: format!("Too large transaction")})?;
10501+ let tx16 = TransactionU16LenLimited::new(tx.clone())
10502+ .map_err(|_e| APIError::APIMisuseError { err: format!("Too large transaction") })?;
1048710503 funding_inputs.push((tx_in.clone(), tx16));
1048810504 }
1048910505
1049010506 let funding_negotiation_context = FundingNegotiationContext {
10491- our_funding_satoshis: 0, // set at later phase
10507+ our_funding_satoshis: 0, // set at later phase
1049210508 their_funding_satoshis: None, // set at later phase
1049310509 funding_tx_locktime: LockTime::from_consensus(locktime),
1049410510 funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10504,7 +10520,11 @@ where
1050410520 received_funding_txid: None,
1050510521 });
1050610522
10507- let msg = self.get_splice_init(our_funding_contribution_satoshis, funding_feerate_per_kw, locktime);
10523+ let msg = self.get_splice_init(
10524+ our_funding_contribution_satoshis,
10525+ funding_feerate_per_kw,
10526+ locktime,
10527+ );
1050810528 Ok(msg)
1050910529 }
1051010530
0 commit comments