Skip to content

Commit 3577418

Browse files
committed
Formatting, remove rustfmt skips
1 parent c3ec314 commit 3577418

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
@@ -10015,35 +10015,41 @@ where
1001510015
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
1001610016
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
1001710017
#[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,
1002210022
) -> Result<msgs::SpliceInit, APIError> {
1002310023
// Check if a splice has been initiated already.
1002410024
// Note: only a single outstanding splice is supported (per spec)
1002510025
if let Some(pending_splice) = &self.pending_splice {
10026-
return Err(APIError::APIMisuseError { err: format!(
10026+
return Err(APIError::APIMisuseError {
10027+
err: format!(
1002710028
"Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
1002810029
self.context.channel_id(),
1002910030
pending_splice.our_funding_contribution,
10030-
)});
10031+
),
10032+
});
1003110033
}
1003210034

1003310035
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+
});
1003810042
}
1003910043

1004010044
// TODO(splicing): check for quiescence
1004110045

1004210046
if our_funding_contribution_satoshis < 0 {
10043-
return Err(APIError::APIMisuseError { err: format!(
10047+
return Err(APIError::APIMisuseError {
10048+
err: format!(
1004410049
"TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
1004510050
self.context.channel_id(), our_funding_contribution_satoshis,
10046-
)});
10051+
),
10052+
});
1004710053
}
1004810054

1004910055
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10053,20 +10059,30 @@ where
1005310059
// (Cannot test for miminum required post-splice channel value)
1005410060

1005510061
// 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!(
1005810071
"Insufficient inputs for splicing; channel ID {}, err {}",
10059-
self.context.channel_id(), err,
10060-
)})?;
10072+
self.context.channel_id(),
10073+
err,
10074+
),
10075+
})?;
1006110076
// Convert inputs
1006210077
let mut funding_inputs = Vec::new();
1006310078
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") })?;
1006510081
funding_inputs.push((tx_in.clone(), tx16));
1006610082
}
1006710083

1006810084
let funding_negotiation_context = FundingNegotiationContext {
10069-
our_funding_satoshis: 0, // set at later phase
10085+
our_funding_satoshis: 0, // set at later phase
1007010086
their_funding_satoshis: None, // set at later phase
1007110087
funding_tx_locktime: LockTime::from_consensus(locktime),
1007210088
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10082,7 +10098,11 @@ where
1008210098
received_funding_txid: None,
1008310099
});
1008410100

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+
);
1008610106
Ok(msg)
1008710107
}
1008810108

lightning/src/ln/channelmanager.rs

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

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

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

@@ -8883,18 +8892,23 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
88838892
}
88848893
}
88858894

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

0 commit comments

Comments
 (0)