@@ -8243,26 +8243,30 @@ impl<SP: Deref> FundedChannel<SP> where
82438243 pub fn splice_channel(&mut self, our_funding_contribution_satoshis: i64,
82448244 our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
82458245 funding_feerate_per_kw: u32, locktime: u32,
8246- ) -> Result<msgs::SpliceInit, ChannelError > {
8246+ ) -> Result<msgs::SpliceInit, APIError > {
82478247 // Check if a splice has been initiated already.
82488248 // Note: only a single outstanding splice is supported (per spec)
82498249 if let Some(splice_info) = &self.pending_splice_pre {
8250- return Err(ChannelError::Warn(format!(
8251- "Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution
8252- )));
8250+ return Err(APIError::APIMisuseError { err: format!(
8251+ "Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
8252+ self.context.channel_id(), splice_info.our_funding_contribution
8253+ )});
82538254 }
82548255
82558256 if !matches!(self.context.channel_state, ChannelState::ChannelReady(_)) {
8256- return Err(ChannelError::Warn(format!("Cannot initiate splicing, as channel is not Ready")));
8257+ return Err(APIError::APIMisuseError { err: format!(
8258+ "Channel {} cannot be spliced, as channel is not Ready",
8259+ self.context.channel_id()
8260+ )});
82578261 }
82588262
82598263 // TODO(splicing): check for quiescence
82608264
82618265 if our_funding_contribution_satoshis < 0 {
8262- return Err(ChannelError::Warn( format!(
8263- "TODO(splicing): Splice-out not supported, only splice in, contribution {}",
8264- our_funding_contribution_satoshis,
8265- )) );
8266+ return Err(APIError::APIMisuseError { err: format!(
8267+ "TODO(splicing): Splice-out not supported, only splice in; channel ID {} , contribution {}",
8268+ self.context.channel_id(), our_funding_contribution_satoshis,
8269+ )} );
82668270 }
82678271
82688272 // TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -8274,7 +8278,11 @@ impl<SP: Deref> FundedChannel<SP> where
82748278 // Check that inputs are sufficient to cover our contribution.
82758279 // Extra common weight is the weight for spending the old funding
82768280 let extra_input_weight = Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT);
8277- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, Some(extra_input_weight), funding_feerate_per_kw)?;
8281+ let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, Some(extra_input_weight), funding_feerate_per_kw)
8282+ .map_err(|err| APIError::APIMisuseError { err: format!(
8283+ "Insufficient inputs for splicing; channel ID {}, err {}",
8284+ self.context.channel_id(), err,
8285+ )})?;
82788286
82798287 self.pending_splice_pre = Some(PendingSplice {
82808288 our_funding_contribution: our_funding_contribution_satoshis,
0 commit comments