@@ -10015,35 +10015,41 @@ where
10015
10015
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
10016
10016
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
10017
10017
#[cfg(splicing)]
10018
- #[rustfmt::skip]
10019
- pub fn splice_channel( &mut self, our_funding_contribution_satoshis: i64,
10020
- our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
10021
- funding_feerate_per_kw: u32, locktime: u32,
10018
+ pub fn splice_channel(
10019
+ &mut self, our_funding_contribution_satoshis: i64,
10020
+ our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
10021
+ locktime: u32,
10022
10022
) -> Result<msgs::SpliceInit, APIError> {
10023
10023
// Check if a splice has been initiated already.
10024
10024
// Note: only a single outstanding splice is supported (per spec)
10025
10025
if let Some(pending_splice) = &self.pending_splice {
10026
- return Err(APIError::APIMisuseError { err: format!(
10026
+ return Err(APIError::APIMisuseError {
10027
+ err: format!(
10027
10028
"Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
10028
10029
self.context.channel_id(),
10029
10030
pending_splice.our_funding_contribution,
10030
- )});
10031
+ ),
10032
+ });
10031
10033
}
10032
10034
10033
10035
if !self.context.is_live() {
10034
- return Err(APIError::APIMisuseError { err: format!(
10035
- "Channel {} cannot be spliced, as channel is not live",
10036
- self.context.channel_id()
10037
- )});
10036
+ return Err(APIError::APIMisuseError {
10037
+ err: format!(
10038
+ "Channel {} cannot be spliced, as channel is not live",
10039
+ self.context.channel_id()
10040
+ ),
10041
+ });
10038
10042
}
10039
10043
10040
10044
// TODO(splicing): check for quiescence
10041
10045
10042
10046
if our_funding_contribution_satoshis < 0 {
10043
- return Err(APIError::APIMisuseError { err: format!(
10047
+ return Err(APIError::APIMisuseError {
10048
+ err: format!(
10044
10049
"TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
10045
10050
self.context.channel_id(), our_funding_contribution_satoshis,
10046
- )});
10051
+ ),
10052
+ });
10047
10053
}
10048
10054
10049
10055
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10053,20 +10059,30 @@ where
10053
10059
// (Cannot test for miminum required post-splice channel value)
10054
10060
10055
10061
// Check that inputs are sufficient to cover our contribution.
10056
- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, true, funding_feerate_per_kw)
10057
- .map_err(|err| APIError::APIMisuseError { err: format!(
10062
+ let _fee = check_v2_funding_inputs_sufficient(
10063
+ our_funding_contribution_satoshis,
10064
+ &our_funding_inputs,
10065
+ true,
10066
+ true,
10067
+ funding_feerate_per_kw,
10068
+ )
10069
+ .map_err(|err| APIError::APIMisuseError {
10070
+ err: format!(
10058
10071
"Insufficient inputs for splicing; channel ID {}, err {}",
10059
- self.context.channel_id(), err,
10060
- )})?;
10072
+ self.context.channel_id(),
10073
+ err,
10074
+ ),
10075
+ })?;
10061
10076
// Convert inputs
10062
10077
let mut funding_inputs = Vec::new();
10063
10078
for (tx_in, tx, _w) in our_funding_inputs.into_iter() {
10064
- let tx16 = TransactionU16LenLimited::new(tx.clone()).map_err(|_e| APIError::APIMisuseError { err: format!("Too large transaction")})?;
10079
+ let tx16 = TransactionU16LenLimited::new(tx.clone())
10080
+ .map_err(|_e| APIError::APIMisuseError { err: format!("Too large transaction") })?;
10065
10081
funding_inputs.push((tx_in.clone(), tx16));
10066
10082
}
10067
10083
10068
10084
let funding_negotiation_context = FundingNegotiationContext {
10069
- our_funding_satoshis: 0, // set at later phase
10085
+ our_funding_satoshis: 0, // set at later phase
10070
10086
their_funding_satoshis: None, // set at later phase
10071
10087
funding_tx_locktime: LockTime::from_consensus(locktime),
10072
10088
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10082,7 +10098,11 @@ where
10082
10098
received_funding_txid: None,
10083
10099
});
10084
10100
10085
- let msg = self.get_splice_init(our_funding_contribution_satoshis, funding_feerate_per_kw, locktime);
10101
+ let msg = self.get_splice_init(
10102
+ our_funding_contribution_satoshis,
10103
+ funding_feerate_per_kw,
10104
+ locktime,
10105
+ );
10086
10106
Ok(msg)
10087
10107
}
10088
10108
0 commit comments