@@ -10404,35 +10404,41 @@ where
10404
10404
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
10405
10405
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
10406
10406
#[cfg(splicing)]
10407
- #[rustfmt::skip]
10408
- pub fn splice_channel( &mut self, our_funding_contribution_satoshis: i64,
10409
- our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
10410
- funding_feerate_per_kw: u32, locktime: u32,
10407
+ pub fn splice_channel(
10408
+ &mut self, our_funding_contribution_satoshis: i64,
10409
+ our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
10410
+ locktime: u32,
10411
10411
) -> Result<msgs::SpliceInit, APIError> {
10412
10412
// Check if a splice has been initiated already.
10413
10413
// Note: only a single outstanding splice is supported (per spec)
10414
10414
if let Some(pending_splice) = &self.pending_splice {
10415
- return Err(APIError::APIMisuseError { err: format!(
10415
+ return Err(APIError::APIMisuseError {
10416
+ err: format!(
10416
10417
"Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
10417
10418
self.context.channel_id(),
10418
10419
pending_splice.our_funding_contribution,
10419
- )});
10420
+ ),
10421
+ });
10420
10422
}
10421
10423
10422
10424
if !self.context.is_live() {
10423
- return Err(APIError::APIMisuseError { err: format!(
10424
- "Channel {} cannot be spliced, as channel is not live",
10425
- self.context.channel_id()
10426
- )});
10425
+ return Err(APIError::APIMisuseError {
10426
+ err: format!(
10427
+ "Channel {} cannot be spliced, as channel is not live",
10428
+ self.context.channel_id()
10429
+ ),
10430
+ });
10427
10431
}
10428
10432
10429
10433
// TODO(splicing): check for quiescence
10430
10434
10431
10435
if our_funding_contribution_satoshis < 0 {
10432
- return Err(APIError::APIMisuseError { err: format!(
10436
+ return Err(APIError::APIMisuseError {
10437
+ err: format!(
10433
10438
"TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
10434
10439
self.context.channel_id(), our_funding_contribution_satoshis,
10435
- )});
10440
+ ),
10441
+ });
10436
10442
}
10437
10443
10438
10444
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10442,11 +10448,20 @@ where
10442
10448
// (Cannot test for miminum required post-splice channel value)
10443
10449
10444
10450
// Check that inputs are sufficient to cover our contribution.
10445
- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, true, funding_feerate_per_kw)
10446
- .map_err(|err| APIError::APIMisuseError { err: format!(
10451
+ let _fee = check_v2_funding_inputs_sufficient(
10452
+ our_funding_contribution_satoshis,
10453
+ &our_funding_inputs,
10454
+ true,
10455
+ true,
10456
+ funding_feerate_per_kw,
10457
+ )
10458
+ .map_err(|err| APIError::APIMisuseError {
10459
+ err: format!(
10447
10460
"Insufficient inputs for splicing; channel ID {}, err {}",
10448
- self.context.channel_id(), err,
10449
- )})?;
10461
+ self.context.channel_id(),
10462
+ err,
10463
+ ),
10464
+ })?;
10450
10465
// Convert inputs
10451
10466
let mut funding_inputs = Vec::new();
10452
10467
for (tx_in, tx, _w) in our_funding_inputs.into_iter() {
@@ -10456,7 +10471,7 @@ where
10456
10471
}
10457
10472
10458
10473
let funding_negotiation_context = FundingNegotiationContext {
10459
- our_funding_satoshis: 0, // set at later phase
10474
+ our_funding_satoshis: 0, // set at later phase
10460
10475
their_funding_satoshis: None, // set at later phase
10461
10476
funding_tx_locktime: LockTime::from_consensus(locktime),
10462
10477
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10471,7 +10486,11 @@ where
10471
10486
received_funding_txid: None,
10472
10487
});
10473
10488
10474
- let msg = self.get_splice_init(our_funding_contribution_satoshis, funding_feerate_per_kw, locktime);
10489
+ let msg = self.get_splice_init(
10490
+ our_funding_contribution_satoshis,
10491
+ funding_feerate_per_kw,
10492
+ locktime,
10493
+ );
10475
10494
Ok(msg)
10476
10495
}
10477
10496
0 commit comments