@@ -8418,26 +8418,30 @@ impl<SP: Deref> FundedChannel<SP> where
8418
8418
pub fn splice_channel(&mut self, our_funding_contribution_satoshis: i64,
8419
8419
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
8420
8420
funding_feerate_per_kw: u32, locktime: u32,
8421
- ) -> Result<msgs::SpliceInit, ChannelError > {
8421
+ ) -> Result<msgs::SpliceInit, APIError > {
8422
8422
// Check if a splice has been initiated already.
8423
8423
// Note: only a single outstanding splice is supported (per spec)
8424
8424
if let Some(splice_info) = &self.pending_splice_pre {
8425
- return Err(ChannelError::Warn(format!(
8426
- "Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution
8427
- )));
8425
+ return Err(APIError::APIMisuseError { err: format!(
8426
+ "Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
8427
+ self.context.channel_id(), splice_info.our_funding_contribution
8428
+ )});
8428
8429
}
8429
8430
8430
8431
if !matches!(self.context.channel_state, ChannelState::ChannelReady(_)) {
8431
- return Err(ChannelError::Warn(format!("Cannot initiate splicing, as channel is not Ready")));
8432
+ return Err(APIError::APIMisuseError { err: format!(
8433
+ "Channel {} cannot be spliced, as channel is not Ready",
8434
+ self.context.channel_id()
8435
+ )});
8432
8436
}
8433
8437
8434
8438
// TODO(splicing): check for quiescence
8435
8439
8436
8440
if our_funding_contribution_satoshis < 0 {
8437
- return Err(ChannelError::Warn( format!(
8438
- "TODO(splicing): Splice-out not supported, only splice in, contribution {}",
8439
- our_funding_contribution_satoshis,
8440
- )) );
8441
+ return Err(APIError::APIMisuseError { err: format!(
8442
+ "TODO(splicing): Splice-out not supported, only splice in; channel ID {} , contribution {}",
8443
+ self.context.channel_id(), our_funding_contribution_satoshis,
8444
+ )} );
8441
8445
}
8442
8446
8443
8447
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -8449,7 +8453,11 @@ impl<SP: Deref> FundedChannel<SP> where
8449
8453
// Check that inputs are sufficient to cover our contribution.
8450
8454
// Extra common weight is the weight for spending the old funding
8451
8455
let extra_input_weight = Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT);
8452
- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, Some(extra_input_weight), funding_feerate_per_kw)?;
8456
+ let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, Some(extra_input_weight), funding_feerate_per_kw)
8457
+ .map_err(|err| APIError::APIMisuseError { err: format!(
8458
+ "Insufficient inputs for splicing; channel ID {}, err {}",
8459
+ self.context.channel_id(), err,
8460
+ )})?;
8453
8461
8454
8462
self.pending_splice_pre = Some(PendingSplice {
8455
8463
our_funding_contribution: our_funding_contribution_satoshis,
0 commit comments