Skip to content

Commit a08cc4e

Browse files
committed
f: allow signature change
1 parent c39c0c0 commit a08cc4e

File tree

1 file changed

+64
-37
lines changed

1 file changed

+64
-37
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 64 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,9 @@ impl Verification for PaymentId {
613613
}
614614

615615
impl PaymentId {
616-
#[rustfmt::skip]
617-
fn for_inbound_from_htlcs<I: Iterator<Item=(ChannelId, u64)>>(key: &[u8; 32], htlcs: I) -> PaymentId {
616+
fn for_inbound_from_htlcs<I: Iterator<Item = (ChannelId, u64)>>(
617+
key: &[u8; 32], htlcs: I,
618+
) -> PaymentId {
618619
let mut prev_pair = None;
619620
let mut hasher = HmacEngine::new(key);
620621
for (channel_id, htlc_id) in htlcs {
@@ -784,8 +785,9 @@ impl HTLCSource {
784785

785786
/// Checks whether this HTLCSource could possibly match the given HTLC output in a commitment
786787
/// transaction. Useful to ensure different datastructures match up.
787-
#[rustfmt::skip]
788-
pub(crate) fn possibly_matches_output(&self, htlc: &super::chan_utils::HTLCOutputInCommitment) -> bool {
788+
pub(crate) fn possibly_matches_output(
789+
&self, htlc: &super::chan_utils::HTLCOutputInCommitment,
790+
) -> bool {
789791
if let HTLCSource::OutboundRoute { first_hop_htlc_msat, .. } = self {
790792
*first_hop_htlc_msat == htlc.amount_msat
791793
} else {
@@ -874,8 +876,10 @@ impl MsgHandleErrInternal {
874876
Self { err, closes_channel: false, shutdown_finish: None }
875877
}
876878
#[inline]
877-
#[rustfmt::skip]
878-
fn from_finish_shutdown(err: String, channel_id: ChannelId, shutdown_res: ShutdownResult, channel_update: Option<msgs::ChannelUpdate>) -> Self {
879+
fn from_finish_shutdown(
880+
err: String, channel_id: ChannelId, shutdown_res: ShutdownResult,
881+
channel_update: Option<msgs::ChannelUpdate>,
882+
) -> Self {
879883
let err_msg = msgs::ErrorMessage { channel_id, data: err.clone() };
880884
let action = if shutdown_res.monitor_update.is_some() {
881885
// We have a closing `ChannelMonitorUpdate`, which means the channel was funded and we
@@ -1674,8 +1678,19 @@ pub trait AChannelManager {
16741678
/// A type that may be dereferenced to [`Self::Logger`].
16751679
type L: Deref<Target = Self::Logger>;
16761680
/// Returns a reference to the actual [`ChannelManager`] object.
1677-
#[rustfmt::skip]
1678-
fn get_cm(&self) -> &ChannelManager<Self::M, Self::T, Self::ES, Self::NS, Self::SP, Self::F, Self::R, Self::MR, Self::L>;
1681+
fn get_cm(
1682+
&self,
1683+
) -> &ChannelManager<
1684+
Self::M,
1685+
Self::T,
1686+
Self::ES,
1687+
Self::NS,
1688+
Self::SP,
1689+
Self::F,
1690+
Self::R,
1691+
Self::MR,
1692+
Self::L,
1693+
>;
16791694
}
16801695

16811696
impl<
@@ -2817,8 +2832,9 @@ impl<'a> PersistenceNotifierGuard<'a, fn() -> NotifyOption> {
28172832
/// This must always be called if the changes included a `ChannelMonitorUpdate`, as well as in
28182833
/// other cases where losing the changes on restart may result in a force-close or otherwise
28192834
/// isn't ideal.
2820-
#[rustfmt::skip]
2821-
fn notify_on_drop<C: AChannelManager>(cm: &'a C) -> PersistenceNotifierGuard<'a, impl FnMut() -> NotifyOption> {
2835+
fn notify_on_drop<C: AChannelManager>(
2836+
cm: &'a C,
2837+
) -> PersistenceNotifierGuard<'a, impl FnMut() -> NotifyOption> {
28222838
Self::optionally_notify(cm, || -> NotifyOption { NotifyOption::DoPersist })
28232839
}
28242840

@@ -2850,9 +2866,9 @@ impl<'a> PersistenceNotifierGuard<'a, fn() -> NotifyOption> {
28502866
/// Note that if any [`ChannelMonitorUpdate`]s are possibly generated,
28512867
/// [`ChannelManager::process_background_events`] MUST be called first (or
28522868
/// [`Self::optionally_notify`] used).
2853-
#[rustfmt::skip]
2854-
fn optionally_notify_skipping_background_events<F: Fn() -> NotifyOption, C: AChannelManager>
2855-
(cm: &'a C, persist_check: F) -> PersistenceNotifierGuard<'a, F> {
2869+
fn optionally_notify_skipping_background_events<F: Fn() -> NotifyOption, C: AChannelManager>(
2870+
cm: &'a C, persist_check: F,
2871+
) -> PersistenceNotifierGuard<'a, F> {
28562872
let read_guard = cm.get_cm().total_consistency_lock.read().unwrap();
28572873

28582874
PersistenceNotifierGuard {
@@ -4100,8 +4116,9 @@ where
41004116
/// [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
41014117
/// [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
41024118
/// [`SendShutdown`]: MessageSendEvent::SendShutdown
4103-
#[rustfmt::skip]
4104-
pub fn close_channel(&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey) -> Result<(), APIError> {
4119+
pub fn close_channel(
4120+
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey,
4121+
) -> Result<(), APIError> {
41054122
self.close_channel_internal(channel_id, counterparty_node_id, None, None)
41064123
}
41074124

@@ -4367,9 +4384,9 @@ where
43674384
///
43684385
/// Fails if `channel_id` is unknown to the manager, or if the `counterparty_node_id`
43694386
/// isn't the counterparty of the corresponding channel.
4370-
#[rustfmt::skip]
4371-
pub fn force_close_broadcasting_latest_txn(&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, error_message: String)
4372-
-> Result<(), APIError> {
4387+
pub fn force_close_broadcasting_latest_txn(
4388+
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, error_message: String,
4389+
) -> Result<(), APIError> {
43734390
self.force_close_sending_error(channel_id, counterparty_node_id, true, error_message)
43744391
}
43754392

@@ -4383,9 +4400,9 @@ where
43834400
/// `counterparty_node_id` isn't the counterparty of the corresponding channel.
43844401
/// You can always broadcast the latest local transaction(s) via
43854402
/// [`ChannelMonitor::broadcast_latest_holder_commitment_txn`].
4386-
#[rustfmt::skip]
4387-
pub fn force_close_without_broadcasting_txn(&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, error_message: String)
4388-
-> Result<(), APIError> {
4403+
pub fn force_close_without_broadcasting_txn(
4404+
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, error_message: String,
4405+
) -> Result<(), APIError> {
43894406
self.force_close_sending_error(channel_id, counterparty_node_id, false, error_message)
43904407
}
43914408

@@ -4987,8 +5004,9 @@ where
49875004
}
49885005

49895006
#[cfg(test)]
4990-
#[rustfmt::skip]
4991-
pub(crate) fn test_set_payment_metadata(&self, payment_id: PaymentId, new_payment_metadata: Option<Vec<u8>>) {
5007+
pub(crate) fn test_set_payment_metadata(
5008+
&self, payment_id: PaymentId, new_payment_metadata: Option<Vec<u8>>,
5009+
) {
49925010
self.pending_outbound_payments.test_set_payment_metadata(payment_id, new_payment_metadata);
49935011
}
49945012

@@ -5239,8 +5257,9 @@ where
52395257
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
52405258
/// payment probe.
52415259
#[cfg(test)]
5242-
#[rustfmt::skip]
5243-
pub(crate) fn payment_is_probe(&self, payment_hash: &PaymentHash, payment_id: &PaymentId) -> bool {
5260+
pub(crate) fn payment_is_probe(
5261+
&self, payment_hash: &PaymentHash, payment_id: &PaymentId,
5262+
) -> bool {
52445263
outbound_payment::payment_is_probe(payment_hash, payment_id, self.probing_cookie_secret)
52455264
}
52465265

@@ -7432,9 +7451,11 @@ where
74327451
}
74337452
}
74347453

7435-
#[rustfmt::skip]
74367454
fn claim_funds_from_hop<
7437-
ComplFunc: FnOnce(Option<u64>, bool) -> (Option<MonitorUpdateCompletionAction>, Option<RAAMonitorUpdateBlockingAction>)
7455+
ComplFunc: FnOnce(
7456+
Option<u64>,
7457+
bool,
7458+
) -> (Option<MonitorUpdateCompletionAction>, Option<RAAMonitorUpdateBlockingAction>),
74387459
>(
74397460
&self, prev_hop: HTLCPreviousHopData, payment_preimage: PaymentPreimage,
74407461
payment_info: Option<PaymentClaimDetails>, completion_action: ComplFunc,
@@ -8659,8 +8680,9 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
86598680
}
86608681
}
86618682

8662-
#[rustfmt::skip]
8663-
fn internal_tx_add_input(&self, counterparty_node_id: PublicKey, msg: &msgs::TxAddInput) -> Result<(), MsgHandleErrInternal> {
8683+
fn internal_tx_add_input(
8684+
&self, counterparty_node_id: PublicKey, msg: &msgs::TxAddInput,
8685+
) -> Result<(), MsgHandleErrInternal> {
86648686
self.internal_tx_msg(&counterparty_node_id, msg.channel_id, |channel: &mut Channel<SP>| {
86658687
match channel.as_unfunded_v2_mut() {
86668688
Some(unfunded_channel) => {
@@ -11795,8 +11817,10 @@ where
1179511817
///
1179611818
/// An [`EventHandler`] may safely call back to the provider in order to handle an event.
1179711819
/// However, it must not call [`Writeable::write`] as doing so would result in a deadlock.
11798-
#[rustfmt::skip]
11799-
fn process_pending_events<H: Deref>(&self, handler: H) where H::Target: EventHandler {
11820+
fn process_pending_events<H: Deref>(&self, handler: H)
11821+
where
11822+
H::Target: EventHandler,
11823+
{
1180011824
let mut ev;
1180111825
process_events_body!(self, ev, handler.handle_event(ev));
1180211826
}
@@ -12525,8 +12549,9 @@ where
1252512549
});
1252612550
}
1252712551

12528-
#[rustfmt::skip]
12529-
fn handle_update_fail_malformed_htlc(&self, counterparty_node_id: PublicKey, msg: &msgs::UpdateFailMalformedHTLC) {
12552+
fn handle_update_fail_malformed_htlc(
12553+
&self, counterparty_node_id: PublicKey, msg: &msgs::UpdateFailMalformedHTLC,
12554+
) {
1253012555
// Note that we never need to persist the updated ChannelManager for an inbound
1253112556
// update_fail_malformed_htlc message - the message itself doesn't change our channel state
1253212557
// only the `commitment_signed` message afterwards will.
@@ -12593,8 +12618,9 @@ where
1259312618
});
1259412619
}
1259512620

12596-
#[rustfmt::skip]
12597-
fn handle_channel_reestablish(&self, counterparty_node_id: PublicKey, msg: &msgs::ChannelReestablish) {
12621+
fn handle_channel_reestablish(
12622+
&self, counterparty_node_id: PublicKey, msg: &msgs::ChannelReestablish,
12623+
) {
1259812624
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
1259912625
let res = self.internal_channel_reestablish(&counterparty_node_id, msg);
1260012626
let persist = match &res {
@@ -16204,8 +16230,9 @@ mod tests {
1620416230
assert!(inbound_payment::verify(payment_hash, &payment_data, nodes[0].node.highest_seen_timestamp.load(Ordering::Acquire) as u64, &nodes[0].node.inbound_payment_key, &nodes[0].logger).is_ok());
1620516231
}
1620616232

16207-
#[rustfmt::skip]
16208-
fn check_not_connected_to_peer_error<T>(res_err: Result<T, APIError>, expected_public_key: PublicKey) {
16233+
fn check_not_connected_to_peer_error<T>(
16234+
res_err: Result<T, APIError>, expected_public_key: PublicKey,
16235+
) {
1620916236
let expected_message = format!("Not connected to node: {}", expected_public_key);
1621016237
check_api_error_message(expected_message, res_err)
1621116238
}

0 commit comments

Comments
 (0)