Skip to content

Commit eb828be

Browse files
committed
Formatting, remove rustfmt skips
1 parent dab3dc2 commit eb828be

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
@@ -10363,35 +10363,41 @@ where
1036310363
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
1036410364
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
1036510365
#[cfg(splicing)]
10366-
#[rustfmt::skip]
10367-
pub fn splice_channel(&mut self, our_funding_contribution_satoshis: i64,
10368-
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
10369-
funding_feerate_per_kw: u32, locktime: u32,
10366+
pub fn splice_channel(
10367+
&mut self, our_funding_contribution_satoshis: i64,
10368+
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
10369+
locktime: u32,
1037010370
) -> Result<msgs::SpliceInit, APIError> {
1037110371
// Check if a splice has been initiated already.
1037210372
// Note: only a single outstanding splice is supported (per spec)
1037310373
if let Some(pending_splice) = &self.pending_splice {
10374-
return Err(APIError::APIMisuseError { err: format!(
10374+
return Err(APIError::APIMisuseError {
10375+
err: format!(
1037510376
"Channel {} cannot be spliced, as it has already a splice pending (contribution {})",
1037610377
self.context.channel_id(),
1037710378
pending_splice.our_funding_contribution,
10378-
)});
10379+
),
10380+
});
1037910381
}
1038010382

1038110383
if !self.context.is_live() {
10382-
return Err(APIError::APIMisuseError { err: format!(
10383-
"Channel {} cannot be spliced, as channel is not live",
10384-
self.context.channel_id()
10385-
)});
10384+
return Err(APIError::APIMisuseError {
10385+
err: format!(
10386+
"Channel {} cannot be spliced, as channel is not live",
10387+
self.context.channel_id()
10388+
),
10389+
});
1038610390
}
1038710391

1038810392
// TODO(splicing): check for quiescence
1038910393

1039010394
if our_funding_contribution_satoshis < 0 {
10391-
return Err(APIError::APIMisuseError { err: format!(
10395+
return Err(APIError::APIMisuseError {
10396+
err: format!(
1039210397
"TODO(splicing): Splice-out not supported, only splice in; channel ID {}, contribution {}",
1039310398
self.context.channel_id(), our_funding_contribution_satoshis,
10394-
)});
10399+
),
10400+
});
1039510401
}
1039610402

1039710403
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
@@ -10401,11 +10407,20 @@ where
1040110407
// (Cannot test for miminum required post-splice channel value)
1040210408

1040310409
// Check that inputs are sufficient to cover our contribution.
10404-
let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, true, funding_feerate_per_kw)
10405-
.map_err(|err| APIError::APIMisuseError { err: format!(
10410+
let _fee = check_v2_funding_inputs_sufficient(
10411+
our_funding_contribution_satoshis,
10412+
&our_funding_inputs,
10413+
true,
10414+
true,
10415+
funding_feerate_per_kw,
10416+
)
10417+
.map_err(|err| APIError::APIMisuseError {
10418+
err: format!(
1040610419
"Insufficient inputs for splicing; channel ID {}, err {}",
10407-
self.context.channel_id(), err,
10408-
)})?;
10420+
self.context.channel_id(),
10421+
err,
10422+
),
10423+
})?;
1040910424
// Convert inputs
1041010425
let mut funding_inputs = Vec::new();
1041110426
for (tx_in, tx, _w) in our_funding_inputs.into_iter() {
@@ -10415,7 +10430,7 @@ where
1041510430
}
1041610431

1041710432
let funding_negotiation_context = FundingNegotiationContext {
10418-
our_funding_satoshis: 0, // set at later phase
10433+
our_funding_satoshis: 0, // set at later phase
1041910434
their_funding_satoshis: None, // set at later phase
1042010435
funding_tx_locktime: LockTime::from_consensus(locktime),
1042110436
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
@@ -10430,7 +10445,11 @@ where
1043010445
received_funding_txid: None,
1043110446
});
1043210447

10433-
let msg = self.get_splice_init(our_funding_contribution_satoshis, funding_feerate_per_kw, locktime);
10448+
let msg = self.get_splice_init(
10449+
our_funding_contribution_satoshis,
10450+
funding_feerate_per_kw,
10451+
locktime,
10452+
);
1043410453
Ok(msg)
1043510454
}
1043610455

lightning/src/ln/channelmanager.rs

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

45104510
/// See [`splice_channel`]
45114511
#[cfg(splicing)]
4512-
#[rustfmt::skip]
45134512
fn internal_splice_channel(
4514-
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, our_funding_contribution_satoshis: i64,
4515-
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
4516-
funding_feerate_per_kw: u32, locktime: Option<u32>,
4513+
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey,
4514+
our_funding_contribution_satoshis: i64,
4515+
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32,
4516+
locktime: Option<u32>,
45174517
) -> Result<(), APIError> {
45184518
let per_peer_state = self.per_peer_state.read().unwrap();
45194519

4520-
let peer_state_mutex = match per_peer_state.get(counterparty_node_id)
4521-
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) }) {
4520+
let peer_state_mutex = match per_peer_state.get(counterparty_node_id).ok_or_else(|| {
4521+
APIError::ChannelUnavailable {
4522+
err: format!(
4523+
"Can't find a peer matching the passed counterparty node_id {}",
4524+
counterparty_node_id
4525+
),
4526+
}
4527+
}) {
45224528
Ok(p) => p,
45234529
Err(e) => return Err(e),
45244530
};
@@ -4531,7 +4537,12 @@ where
45314537
hash_map::Entry::Occupied(mut chan_phase_entry) => {
45324538
let locktime = locktime.unwrap_or_else(|| self.current_best_block().height);
45334539
if let Some(chan) = chan_phase_entry.get_mut().as_funded_mut() {
4534-
let msg = chan.splice_channel(our_funding_contribution_satoshis, our_funding_inputs, funding_feerate_per_kw, locktime)?;
4540+
let msg = chan.splice_channel(
4541+
our_funding_contribution_satoshis,
4542+
our_funding_inputs,
4543+
funding_feerate_per_kw,
4544+
locktime,
4545+
)?;
45354546
peer_state.pending_msg_events.push(MessageSendEvent::SendSpliceInit {
45364547
node_id: *counterparty_node_id,
45374548
msg,
@@ -4542,18 +4553,16 @@ where
45424553
err: format!(
45434554
"Channel with id {} is not funded, cannot splice it",
45444555
channel_id
4545-
)
4556+
),
45464557
})
45474558
}
45484559
},
4549-
hash_map::Entry::Vacant(_) => {
4550-
Err(APIError::ChannelUnavailable {
4551-
err: format!(
4552-
"Channel with id {} not found for the passed counterparty node_id {}",
4553-
channel_id, counterparty_node_id,
4554-
)
4555-
})
4556-
},
4560+
hash_map::Entry::Vacant(_) => Err(APIError::ChannelUnavailable {
4561+
err: format!(
4562+
"Channel with id {} not found for the passed counterparty node_id {}",
4563+
channel_id, counterparty_node_id,
4564+
),
4565+
}),
45574566
}
45584567
}
45594568

@@ -9183,18 +9192,23 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
91839192
}
91849193
}
91859194

9186-
#[rustfmt::skip]
9187-
fn internal_tx_msg<HandleTxMsgFn: Fn(&mut Channel<SP>) -> Result<MessageSendEvent, ChannelError>>(
9188-
&self, counterparty_node_id: &PublicKey, channel_id: ChannelId, tx_msg_handler: HandleTxMsgFn
9195+
fn internal_tx_msg<
9196+
HandleTxMsgFn: Fn(&mut Channel<SP>) -> Result<MessageSendEvent, ChannelError>,
9197+
>(
9198+
&self, counterparty_node_id: &PublicKey, channel_id: ChannelId,
9199+
tx_msg_handler: HandleTxMsgFn,
91899200
) -> Result<(), MsgHandleErrInternal> {
91909201
let per_peer_state = self.per_peer_state.read().unwrap();
9191-
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
9192-
.ok_or_else(|| {
9193-
debug_assert!(false);
9194-
MsgHandleErrInternal::send_err_msg_no_close(
9195-
format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id),
9196-
channel_id)
9197-
})?;
9202+
let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
9203+
debug_assert!(false);
9204+
MsgHandleErrInternal::send_err_msg_no_close(
9205+
format!(
9206+
"Can't find a peer matching the passed counterparty node_id {}",
9207+
counterparty_node_id
9208+
),
9209+
channel_id,
9210+
)
9211+
})?;
91989212
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
91999213
let peer_state = &mut *peer_state_lock;
92009214
match peer_state.channel_by_id.entry(channel_id) {

0 commit comments

Comments
 (0)