@@ -10363,35 +10363,41 @@ where
10363
10363
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
10364
10364
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
10365
10365
#[cfg(splicing)]
10366
- #[rustfmt::skip]
10367
- pub fn splice_channel( &mut self, our_funding_contribution_satoshis: i64,
10368
- our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
10369
- funding_feerate_per_kw: u32, locktime: u32,
10366
+ pub fn splice_channel(
10367
+ &mut self, our_funding_contribution_satoshis: i64,
10368
+ our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
10369
+ locktime: u32,
10370
10370
) -> Result<msgs::SpliceInit, APIError> {
10371
10371
// Check if a splice has been initiated already.
10372
10372
// Note: only a single outstanding splice is supported (per spec)
10373
10373
if let Some(pending_splice) = &self.pending_splice {
10374
- return Err(APIError::APIMisuseError { err: format!(
10374
+ return Err(APIError::APIMisuseError {
10375
+ err: format!(
10375
10376
"Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
10376
10377
self.context.channel_id(),
10377
10378
pending_splice.our_funding_contribution,
10378
- )});
10379
+ ),
10380
+ });
10379
10381
}
10380
10382
10381
10383
if !self.context.is_live() {
10382
- return Err(APIError::APIMisuseError { err: format!(
10383
- "Channel {} cannot be spliced, as channel is not live",
10384
- self.context.channel_id()
10385
- )});
10384
+ return Err(APIError::APIMisuseError {
10385
+ err: format!(
10386
+ "Channel {} cannot be spliced, as channel is not live",
10387
+ self.context.channel_id()
10388
+ ),
10389
+ });
10386
10390
}
10387
10391
10388
10392
// TODO(splicing): check for quiescence
10389
10393
10390
10394
if our_funding_contribution_satoshis < 0 {
10391
- return Err(APIError::APIMisuseError { err: format!(
10395
+ return Err(APIError::APIMisuseError {
10396
+ err: format!(
10392
10397
"TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
10393
10398
self.context.channel_id(), our_funding_contribution_satoshis,
10394
- )});
10399
+ ),
10400
+ });
10395
10401
}
10396
10402
10397
10403
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10401,11 +10407,20 @@ where
10401
10407
// (Cannot test for miminum required post-splice channel value)
10402
10408
10403
10409
// Check that inputs are sufficient to cover our contribution.
10404
- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, true, funding_feerate_per_kw)
10405
- .map_err(|err| APIError::APIMisuseError { err: format!(
10410
+ let _fee = check_v2_funding_inputs_sufficient(
10411
+ our_funding_contribution_satoshis,
10412
+ &our_funding_inputs,
10413
+ true,
10414
+ true,
10415
+ funding_feerate_per_kw,
10416
+ )
10417
+ .map_err(|err| APIError::APIMisuseError {
10418
+ err: format!(
10406
10419
"Insufficient inputs for splicing; channel ID {}, err {}",
10407
- self.context.channel_id(), err,
10408
- )})?;
10420
+ self.context.channel_id(),
10421
+ err,
10422
+ ),
10423
+ })?;
10409
10424
// Convert inputs
10410
10425
let mut funding_inputs = Vec::new();
10411
10426
for (tx_in, tx, _w) in our_funding_inputs.into_iter() {
@@ -10415,7 +10430,7 @@ where
10415
10430
}
10416
10431
10417
10432
let funding_negotiation_context = FundingNegotiationContext {
10418
- our_funding_satoshis: 0, // set at later phase
10433
+ our_funding_satoshis: 0, // set at later phase
10419
10434
their_funding_satoshis: None, // set at later phase
10420
10435
funding_tx_locktime: LockTime::from_consensus(locktime),
10421
10436
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10430,7 +10445,11 @@ where
10430
10445
received_funding_txid: None,
10431
10446
});
10432
10447
10433
- let msg = self.get_splice_init(our_funding_contribution_satoshis, funding_feerate_per_kw, locktime);
10448
+ let msg = self.get_splice_init(
10449
+ our_funding_contribution_satoshis,
10450
+ funding_feerate_per_kw,
10451
+ locktime,
10452
+ );
10434
10453
Ok(msg)
10435
10454
}
10436
10455
0 commit comments