Skip to content

Commit aeef39d

Browse files
optout21jkczyz
authored andcommitted
Formatting, remove rustfmt skips
1 parent a21b1a6 commit aeef39d

File tree

2 files changed

+77
-44
lines changed

2 files changed

+77
-44
lines changed

lightning/src/ln/channel.rs

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10378,35 +10378,41 @@ where
1037810378
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
1037910379
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
1038010380
#[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,
1038510385
) -> Result<msgs::SpliceInit, APIError> {
1038610386
// Check if a splice has been initiated already.
1038710387
// Note: only a single outstanding splice is supported (per spec)
1038810388
if let Some(pending_splice) = &self.pending_splice {
10389-
return Err(APIError::APIMisuseError { err: format!(
10389+
return Err(APIError::APIMisuseError {
10390+
err: format!(
1039010391
"Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
1039110392
self.context.channel_id(),
1039210393
pending_splice.our_funding_contribution,
10393-
)});
10394+
),
10395+
});
1039410396
}
1039510397

1039610398
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+
});
1040110405
}
1040210406

1040310407
// TODO(splicing): check for quiescence
1040410408

1040510409
if our_funding_contribution_satoshis < 0 {
10406-
return Err(APIError::APIMisuseError { err: format!(
10410+
return Err(APIError::APIMisuseError {
10411+
err: format!(
1040710412
"TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
1040810413
self.context.channel_id(), our_funding_contribution_satoshis,
10409-
)});
10414+
),
10415+
});
1041010416
}
1041110417

1041210418
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10416,11 +10422,20 @@ where
1041610422
// (Cannot test for miminum required post-splice channel value)
1041710423

1041810424
// 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!(
1042110434
"Insufficient inputs for splicing; channel ID {}, err {}",
10422-
self.context.channel_id(), err,
10423-
)})?;
10435+
self.context.channel_id(),
10436+
err,
10437+
),
10438+
})?;
1042410439
// Convert inputs
1042510440
let mut funding_inputs = Vec::new();
1042610441
for (tx_in, tx, _w) in our_funding_inputs.into_iter() {
@@ -10431,7 +10446,7 @@ where
1043110446

1043210447
let funding_negotiation_context = FundingNegotiationContext {
1043310448
is_initiator: true,
10434-
our_funding_satoshis: 0, // set at later phase
10449+
our_funding_satoshis: 0, // set at later phase
1043510450
their_funding_satoshis: None, // set at later phase
1043610451
funding_tx_locktime: LockTime::from_consensus(locktime),
1043710452
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10446,7 +10461,11 @@ where
1044610461
received_funding_txid: None,
1044710462
});
1044810463

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+
);
1045010469
Ok(msg)
1045110470
}
1045210471

lightning/src/ln/channelmanager.rs

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

45084508
/// See [`splice_channel`]
45094509
#[cfg(splicing)]
4510-
#[rustfmt::skip]
45114510
fn internal_splice_channel(
4512-
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, our_funding_contribution_satoshis: i64,
4513-
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
4514-
funding_feerate_per_kw: u32, locktime: Option<u32>,
4511+
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey,
4512+
our_funding_contribution_satoshis: i64,
4513+
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
4514+
locktime: Option<u32>,
45154515
) -> Result<(), APIError> {
45164516
let per_peer_state = self.per_peer_state.read().unwrap();
45174517

4518-
let peer_state_mutex = match per_peer_state.get(counterparty_node_id)
4519-
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) }) {
4518+
let peer_state_mutex = match per_peer_state.get(counterparty_node_id).ok_or_else(|| {
4519+
APIError::ChannelUnavailable {
4520+
err: format!(
4521+
"Can't find a peer matching the passed counterparty node_id {}",
4522+
counterparty_node_id
4523+
),
4524+
}
4525+
}) {
45204526
Ok(p) => p,
45214527
Err(e) => return Err(e),
45224528
};
@@ -4529,7 +4535,12 @@ where
45294535
hash_map::Entry::Occupied(mut chan_phase_entry) => {
45304536
let locktime = locktime.unwrap_or_else(|| self.current_best_block().height);
45314537
if let Some(chan) = chan_phase_entry.get_mut().as_funded_mut() {
4532-
let msg = chan.splice_channel(our_funding_contribution_satoshis, our_funding_inputs, funding_feerate_per_kw, locktime)?;
4538+
let msg = chan.splice_channel(
4539+
our_funding_contribution_satoshis,
4540+
our_funding_inputs,
4541+
funding_feerate_per_kw,
4542+
locktime,
4543+
)?;
45334544
peer_state.pending_msg_events.push(MessageSendEvent::SendSpliceInit {
45344545
node_id: *counterparty_node_id,
45354546
msg,
@@ -4540,18 +4551,16 @@ where
45404551
err: format!(
45414552
"Channel with id {} is not funded, cannot splice it",
45424553
channel_id
4543-
)
4554+
),
45444555
})
45454556
}
45464557
},
4547-
hash_map::Entry::Vacant(_) => {
4548-
Err(APIError::ChannelUnavailable {
4549-
err: format!(
4550-
"Channel with id {} not found for the passed counterparty node_id {}",
4551-
channel_id, counterparty_node_id,
4552-
)
4553-
})
4554-
},
4558+
hash_map::Entry::Vacant(_) => Err(APIError::ChannelUnavailable {
4559+
err: format!(
4560+
"Channel with id {} not found for the passed counterparty node_id {}",
4561+
channel_id, counterparty_node_id,
4562+
),
4563+
}),
45554564
}
45564565
}
45574566

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

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

0 commit comments

Comments
 (0)