@@ -10378,35 +10378,41 @@ where
1037810378 /// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
1037910379 /// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
1038010380 #[cfg(splicing)]
10381- #[rustfmt::skip]
10382- pub fn splice_channel( &mut self, our_funding_contribution_satoshis: i64,
10383- our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
10384- funding_feerate_per_kw: u32, locktime: u32,
10381+ pub fn splice_channel(
10382+ &mut self, our_funding_contribution_satoshis: i64,
10383+ our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
10384+ locktime: u32,
1038510385 ) -> Result<msgs::SpliceInit, APIError> {
1038610386 // Check if a splice has been initiated already.
1038710387 // Note: only a single outstanding splice is supported (per spec)
1038810388 if let Some(pending_splice) = &self.pending_splice {
10389- return Err(APIError::APIMisuseError { err: format!(
10389+ return Err(APIError::APIMisuseError {
10390+ err: format!(
1039010391 "Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
1039110392 self.context.channel_id(),
1039210393 pending_splice.our_funding_contribution,
10393- )});
10394+ ),
10395+ });
1039410396 }
1039510397
1039610398 if !self.context.is_live() {
10397- return Err(APIError::APIMisuseError { err: format!(
10398- "Channel {} cannot be spliced, as channel is not live",
10399- self.context.channel_id()
10400- )});
10399+ return Err(APIError::APIMisuseError {
10400+ err: format!(
10401+ "Channel {} cannot be spliced, as channel is not live",
10402+ self.context.channel_id()
10403+ ),
10404+ });
1040110405 }
1040210406
1040310407 // TODO(splicing): check for quiescence
1040410408
1040510409 if our_funding_contribution_satoshis < 0 {
10406- return Err(APIError::APIMisuseError { err: format!(
10410+ return Err(APIError::APIMisuseError {
10411+ err: format!(
1040710412 "TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
1040810413 self.context.channel_id(), our_funding_contribution_satoshis,
10409- )});
10414+ ),
10415+ });
1041010416 }
1041110417
1041210418 // TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10416,11 +10422,20 @@ where
1041610422 // (Cannot test for miminum required post-splice channel value)
1041710423
1041810424 // Check that inputs are sufficient to cover our contribution.
10419- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, true, funding_feerate_per_kw)
10420- .map_err(|err| APIError::APIMisuseError { err: format!(
10425+ let _fee = check_v2_funding_inputs_sufficient(
10426+ our_funding_contribution_satoshis,
10427+ &our_funding_inputs,
10428+ true,
10429+ true,
10430+ funding_feerate_per_kw,
10431+ )
10432+ .map_err(|err| APIError::APIMisuseError {
10433+ err: format!(
1042110434 "Insufficient inputs for splicing; channel ID {}, err {}",
10422- self.context.channel_id(), err,
10423- )})?;
10435+ self.context.channel_id(),
10436+ err,
10437+ ),
10438+ })?;
1042410439 // Convert inputs
1042510440 let mut funding_inputs = Vec::new();
1042610441 for (tx_in, tx, _w) in our_funding_inputs.into_iter() {
@@ -10431,7 +10446,7 @@ where
1043110446
1043210447 let funding_negotiation_context = FundingNegotiationContext {
1043310448 is_initiator: true,
10434- our_funding_satoshis: 0, // set at later phase
10449+ our_funding_satoshis: 0, // set at later phase
1043510450 their_funding_satoshis: None, // set at later phase
1043610451 funding_tx_locktime: LockTime::from_consensus(locktime),
1043710452 funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10446,7 +10461,11 @@ where
1044610461 received_funding_txid: None,
1044710462 });
1044810463
10449- let msg = self.get_splice_init(our_funding_contribution_satoshis, funding_feerate_per_kw, locktime);
10464+ let msg = self.get_splice_init(
10465+ our_funding_contribution_satoshis,
10466+ funding_feerate_per_kw,
10467+ locktime,
10468+ );
1045010469 Ok(msg)
1045110470 }
1045210471
0 commit comments