@@ -10378,35 +10378,41 @@ where
10378
10378
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
10379
10379
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
10380
10380
#[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,
10385
10385
) -> Result<msgs::SpliceInit, APIError> {
10386
10386
// Check if a splice has been initiated already.
10387
10387
// Note: only a single outstanding splice is supported (per spec)
10388
10388
if let Some(pending_splice) = &self.pending_splice {
10389
- return Err(APIError::APIMisuseError { err: format!(
10389
+ return Err(APIError::APIMisuseError {
10390
+ err: format!(
10390
10391
"Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
10391
10392
self.context.channel_id(),
10392
10393
pending_splice.our_funding_contribution,
10393
- )});
10394
+ ),
10395
+ });
10394
10396
}
10395
10397
10396
10398
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
+ });
10401
10405
}
10402
10406
10403
10407
// TODO(splicing): check for quiescence
10404
10408
10405
10409
if our_funding_contribution_satoshis < 0 {
10406
- return Err(APIError::APIMisuseError { err: format!(
10410
+ return Err(APIError::APIMisuseError {
10411
+ err: format!(
10407
10412
"TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
10408
10413
self.context.channel_id(), our_funding_contribution_satoshis,
10409
- )});
10414
+ ),
10415
+ });
10410
10416
}
10411
10417
10412
10418
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10416,11 +10422,20 @@ where
10416
10422
// (Cannot test for miminum required post-splice channel value)
10417
10423
10418
10424
// 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!(
10421
10434
"Insufficient inputs for splicing; channel ID {}, err {}",
10422
- self.context.channel_id(), err,
10423
- )})?;
10435
+ self.context.channel_id(),
10436
+ err,
10437
+ ),
10438
+ })?;
10424
10439
// Convert inputs
10425
10440
let mut funding_inputs = Vec::new();
10426
10441
for (tx_in, tx, _w) in our_funding_inputs.into_iter() {
@@ -10431,7 +10446,7 @@ where
10431
10446
10432
10447
let funding_negotiation_context = FundingNegotiationContext {
10433
10448
is_initiator: true,
10434
- our_funding_satoshis: 0, // set at later phase
10449
+ our_funding_satoshis: 0, // set at later phase
10435
10450
their_funding_satoshis: None, // set at later phase
10436
10451
funding_tx_locktime: LockTime::from_consensus(locktime),
10437
10452
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10446,7 +10461,11 @@ where
10446
10461
received_funding_txid: None,
10447
10462
});
10448
10463
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
+ );
10450
10469
Ok(msg)
10451
10470
}
10452
10471
0 commit comments