@@ -10206,35 +10206,41 @@ where
10206
10206
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
10207
10207
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
10208
10208
#[cfg(splicing)]
10209
- #[rustfmt::skip]
10210
- pub fn splice_channel( &mut self, our_funding_contribution_satoshis: i64,
10211
- our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
10212
- funding_feerate_per_kw: u32, locktime: u32,
10209
+ pub fn splice_channel(
10210
+ &mut self, our_funding_contribution_satoshis: i64,
10211
+ our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
10212
+ locktime: u32,
10213
10213
) -> Result<msgs::SpliceInit, APIError> {
10214
10214
// Check if a splice has been initiated already.
10215
10215
// Note: only a single outstanding splice is supported (per spec)
10216
10216
if let Some(pending_splice) = &self.pending_splice {
10217
- return Err(APIError::APIMisuseError { err: format!(
10217
+ return Err(APIError::APIMisuseError {
10218
+ err: format!(
10218
10219
"Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
10219
10220
self.context.channel_id(),
10220
10221
pending_splice.our_funding_contribution,
10221
- )});
10222
+ ),
10223
+ });
10222
10224
}
10223
10225
10224
10226
if !self.context.is_live() {
10225
- return Err(APIError::APIMisuseError { err: format!(
10226
- "Channel {} cannot be spliced, as channel is not live",
10227
- self.context.channel_id()
10228
- )});
10227
+ return Err(APIError::APIMisuseError {
10228
+ err: format!(
10229
+ "Channel {} cannot be spliced, as channel is not live",
10230
+ self.context.channel_id()
10231
+ ),
10232
+ });
10229
10233
}
10230
10234
10231
10235
// TODO(splicing): check for quiescence
10232
10236
10233
10237
if our_funding_contribution_satoshis < 0 {
10234
- return Err(APIError::APIMisuseError { err: format!(
10238
+ return Err(APIError::APIMisuseError {
10239
+ err: format!(
10235
10240
"TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
10236
10241
self.context.channel_id(), our_funding_contribution_satoshis,
10237
- )});
10242
+ ),
10243
+ });
10238
10244
}
10239
10245
10240
10246
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10244,20 +10250,30 @@ where
10244
10250
// (Cannot test for miminum required post-splice channel value)
10245
10251
10246
10252
// Check that inputs are sufficient to cover our contribution.
10247
- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, true, funding_feerate_per_kw)
10248
- .map_err(|err| APIError::APIMisuseError { err: format!(
10253
+ let _fee = check_v2_funding_inputs_sufficient(
10254
+ our_funding_contribution_satoshis,
10255
+ &our_funding_inputs,
10256
+ true,
10257
+ true,
10258
+ funding_feerate_per_kw,
10259
+ )
10260
+ .map_err(|err| APIError::APIMisuseError {
10261
+ err: format!(
10249
10262
"Insufficient inputs for splicing; channel ID {}, err {}",
10250
- self.context.channel_id(), err,
10251
- )})?;
10263
+ self.context.channel_id(),
10264
+ err,
10265
+ ),
10266
+ })?;
10252
10267
// Convert inputs
10253
10268
let mut funding_inputs = Vec::new();
10254
10269
for (tx_in, tx, _w) in our_funding_inputs.into_iter() {
10255
- let tx16 = TransactionU16LenLimited::new(tx.clone()).map_err(|_e| APIError::APIMisuseError { err: format!("Too large transaction")})?;
10270
+ let tx16 = TransactionU16LenLimited::new(tx.clone())
10271
+ .map_err(|_e| APIError::APIMisuseError { err: format!("Too large transaction") })?;
10256
10272
funding_inputs.push((tx_in.clone(), tx16));
10257
10273
}
10258
10274
10259
10275
let funding_negotiation_context = FundingNegotiationContext {
10260
- our_funding_satoshis: 0, // set at later phase
10276
+ our_funding_satoshis: 0, // set at later phase
10261
10277
their_funding_satoshis: None, // set at later phase
10262
10278
funding_tx_locktime: LockTime::from_consensus(locktime),
10263
10279
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10273,7 +10289,11 @@ where
10273
10289
received_funding_txid: None,
10274
10290
});
10275
10291
10276
- let msg = self.get_splice_init(our_funding_contribution_satoshis, funding_feerate_per_kw, locktime);
10292
+ let msg = self.get_splice_init(
10293
+ our_funding_contribution_satoshis,
10294
+ funding_feerate_per_kw,
10295
+ locktime,
10296
+ );
10277
10297
Ok(msg)
10278
10298
}
10279
10299
0 commit comments