Skip to content

Commit 762addf

Browse files
committed
Formatting, remove rustfmt skips
1 parent 1da5547 commit 762addf

File tree

2 files changed

+79
-45
lines changed

2 files changed

+79
-45
lines changed

lightning/src/ln/channel.rs

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10206,35 +10206,41 @@ where
1020610206
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
1020710207
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
1020810208
#[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,
1021310213
) -> Result<msgs::SpliceInit, APIError> {
1021410214
// Check if a splice has been initiated already.
1021510215
// Note: only a single outstanding splice is supported (per spec)
1021610216
if let Some(pending_splice) = &self.pending_splice {
10217-
return Err(APIError::APIMisuseError { err: format!(
10217+
return Err(APIError::APIMisuseError {
10218+
err: format!(
1021810219
"Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
1021910220
self.context.channel_id(),
1022010221
pending_splice.our_funding_contribution,
10221-
)});
10222+
),
10223+
});
1022210224
}
1022310225

1022410226
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+
});
1022910233
}
1023010234

1023110235
// TODO(splicing): check for quiescence
1023210236

1023310237
if our_funding_contribution_satoshis < 0 {
10234-
return Err(APIError::APIMisuseError { err: format!(
10238+
return Err(APIError::APIMisuseError {
10239+
err: format!(
1023510240
"TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
1023610241
self.context.channel_id(), our_funding_contribution_satoshis,
10237-
)});
10242+
),
10243+
});
1023810244
}
1023910245

1024010246
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10244,20 +10250,30 @@ where
1024410250
// (Cannot test for miminum required post-splice channel value)
1024510251

1024610252
// 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!(
1024910262
"Insufficient inputs for splicing; channel ID {}, err {}",
10250-
self.context.channel_id(), err,
10251-
)})?;
10263+
self.context.channel_id(),
10264+
err,
10265+
),
10266+
})?;
1025210267
// Convert inputs
1025310268
let mut funding_inputs = Vec::new();
1025410269
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") })?;
1025610272
funding_inputs.push((tx_in.clone(), tx16));
1025710273
}
1025810274

1025910275
let funding_negotiation_context = FundingNegotiationContext {
10260-
our_funding_satoshis: 0, // set at later phase
10276+
our_funding_satoshis: 0, // set at later phase
1026110277
their_funding_satoshis: None, // set at later phase
1026210278
funding_tx_locktime: LockTime::from_consensus(locktime),
1026310279
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10273,7 +10289,11 @@ where
1027310289
received_funding_txid: None,
1027410290
});
1027510291

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+
);
1027710297
Ok(msg)
1027810298
}
1027910299

lightning/src/ln/channelmanager.rs

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,16 +4538,22 @@ where
45384538

45394539
/// See [`splice_channel`]
45404540
#[cfg(splicing)]
4541-
#[rustfmt::skip]
45424541
fn internal_splice_channel(
4543-
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, our_funding_contribution_satoshis: i64,
4544-
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
4545-
funding_feerate_per_kw: u32, locktime: Option<u32>,
4542+
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey,
4543+
our_funding_contribution_satoshis: i64,
4544+
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
4545+
locktime: Option<u32>,
45464546
) -> Result<(), APIError> {
45474547
let per_peer_state = self.per_peer_state.read().unwrap();
45484548

4549-
let peer_state_mutex = match per_peer_state.get(counterparty_node_id)
4550-
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) }) {
4549+
let peer_state_mutex = match per_peer_state.get(counterparty_node_id).ok_or_else(|| {
4550+
APIError::ChannelUnavailable {
4551+
err: format!(
4552+
"Can't find a peer matching the passed counterparty node_id {}",
4553+
counterparty_node_id
4554+
),
4555+
}
4556+
}) {
45514557
Ok(p) => p,
45524558
Err(e) => return Err(e),
45534559
};
@@ -4560,7 +4566,12 @@ where
45604566
hash_map::Entry::Occupied(mut chan_phase_entry) => {
45614567
let locktime = locktime.unwrap_or_else(|| self.current_best_block().height);
45624568
if let Some(chan) = chan_phase_entry.get_mut().as_funded_mut() {
4563-
let msg = chan.splice_channel(our_funding_contribution_satoshis, our_funding_inputs, funding_feerate_per_kw, locktime)?;
4569+
let msg = chan.splice_channel(
4570+
our_funding_contribution_satoshis,
4571+
our_funding_inputs,
4572+
funding_feerate_per_kw,
4573+
locktime,
4574+
)?;
45644575
peer_state.pending_msg_events.push(MessageSendEvent::SendSpliceInit {
45654576
node_id: *counterparty_node_id,
45664577
msg,
@@ -4571,18 +4582,16 @@ where
45714582
err: format!(
45724583
"Channel with id {} is not funded, cannot splice it",
45734584
channel_id
4574-
)
4585+
),
45754586
})
45764587
}
45774588
},
4578-
hash_map::Entry::Vacant(_) => {
4579-
Err(APIError::ChannelUnavailable {
4580-
err: format!(
4581-
"Channel with id {} not found for the passed counterparty node_id {}",
4582-
channel_id, counterparty_node_id,
4583-
)
4584-
})
4585-
},
4589+
hash_map::Entry::Vacant(_) => Err(APIError::ChannelUnavailable {
4590+
err: format!(
4591+
"Channel with id {} not found for the passed counterparty node_id {}",
4592+
channel_id, counterparty_node_id,
4593+
),
4594+
}),
45864595
}
45874596
}
45884597

@@ -8885,18 +8894,23 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
88858894
}
88868895
}
88878896

8888-
#[rustfmt::skip]
8889-
fn internal_tx_msg<HandleTxMsgFn: Fn(&mut Channel<SP>) -> Result<MessageSendEvent, ChannelError>>(
8890-
&self, counterparty_node_id: &PublicKey, channel_id: ChannelId, tx_msg_handler: HandleTxMsgFn
8897+
fn internal_tx_msg<
8898+
HandleTxMsgFn: Fn(&mut Channel<SP>) -> Result<MessageSendEvent, ChannelError>,
8899+
>(
8900+
&self, counterparty_node_id: &PublicKey, channel_id: ChannelId,
8901+
tx_msg_handler: HandleTxMsgFn,
88918902
) -> Result<(), MsgHandleErrInternal> {
88928903
let per_peer_state = self.per_peer_state.read().unwrap();
8893-
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
8894-
.ok_or_else(|| {
8895-
debug_assert!(false);
8896-
MsgHandleErrInternal::send_err_msg_no_close(
8897-
format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id),
8898-
channel_id)
8899-
})?;
8904+
let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
8905+
debug_assert!(false);
8906+
MsgHandleErrInternal::send_err_msg_no_close(
8907+
format!(
8908+
"Can't find a peer matching the passed counterparty node_id {}",
8909+
counterparty_node_id
8910+
),
8911+
channel_id,
8912+
)
8913+
})?;
89008914
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
89018915
let peer_state = &mut *peer_state_lock;
89028916
match peer_state.channel_by_id.entry(channel_id) {

0 commit comments

Comments
 (0)