Skip to content

Commit b3d257d

Browse files
Delete unnecessary whitespace in process_pending_forwards
Only whitespace diff
1 parent 582b827 commit b3d257d

File tree

1 file changed

+64
-64
lines changed

1 file changed

+64
-64
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3158,79 +3158,79 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
31583158
outgoing_cltv_value
31593159
}
31603160
}) => {
3161-
macro_rules! failure_handler {
3162-
($msg: expr, $err_code: expr, $err_data: expr, $phantom_ss: expr, $next_hop_unknown: expr) => {
3163-
log_info!(self.logger, "Failed to accept/forward incoming HTLC: {}", $msg);
3164-
3165-
let htlc_source = HTLCSource::PreviousHopData(HTLCPreviousHopData {
3166-
short_channel_id: prev_short_channel_id,
3167-
outpoint: prev_funding_outpoint,
3168-
htlc_id: prev_htlc_id,
3169-
incoming_packet_shared_secret: incoming_shared_secret,
3170-
phantom_shared_secret: $phantom_ss,
3171-
});
3172-
3173-
let reason = if $next_hop_unknown {
3174-
HTLCDestination::UnknownNextHop { requested_forward_scid: short_chan_id }
3175-
} else {
3176-
HTLCDestination::FailedPayment{ payment_hash }
3177-
};
3178-
3179-
failed_forwards.push((htlc_source, payment_hash,
3180-
HTLCFailReason::Reason { failure_code: $err_code, data: $err_data },
3181-
reason
3182-
));
3183-
continue;
3184-
}
3161+
macro_rules! failure_handler {
3162+
($msg: expr, $err_code: expr, $err_data: expr, $phantom_ss: expr, $next_hop_unknown: expr) => {
3163+
log_info!(self.logger, "Failed to accept/forward incoming HTLC: {}", $msg);
3164+
3165+
let htlc_source = HTLCSource::PreviousHopData(HTLCPreviousHopData {
3166+
short_channel_id: prev_short_channel_id,
3167+
outpoint: prev_funding_outpoint,
3168+
htlc_id: prev_htlc_id,
3169+
incoming_packet_shared_secret: incoming_shared_secret,
3170+
phantom_shared_secret: $phantom_ss,
3171+
});
3172+
3173+
let reason = if $next_hop_unknown {
3174+
HTLCDestination::UnknownNextHop { requested_forward_scid: short_chan_id }
3175+
} else {
3176+
HTLCDestination::FailedPayment{ payment_hash }
3177+
};
3178+
3179+
failed_forwards.push((htlc_source, payment_hash,
3180+
HTLCFailReason::Reason { failure_code: $err_code, data: $err_data },
3181+
reason
3182+
));
3183+
continue;
31853184
}
3186-
macro_rules! fail_forward {
3187-
($msg: expr, $err_code: expr, $err_data: expr, $phantom_ss: expr) => {
3188-
{
3189-
failure_handler!($msg, $err_code, $err_data, $phantom_ss, true);
3190-
}
3185+
}
3186+
macro_rules! fail_forward {
3187+
($msg: expr, $err_code: expr, $err_data: expr, $phantom_ss: expr) => {
3188+
{
3189+
failure_handler!($msg, $err_code, $err_data, $phantom_ss, true);
31913190
}
31923191
}
3193-
macro_rules! failed_payment {
3194-
($msg: expr, $err_code: expr, $err_data: expr, $phantom_ss: expr) => {
3195-
{
3196-
failure_handler!($msg, $err_code, $err_data, $phantom_ss, false);
3197-
}
3192+
}
3193+
macro_rules! failed_payment {
3194+
($msg: expr, $err_code: expr, $err_data: expr, $phantom_ss: expr) => {
3195+
{
3196+
failure_handler!($msg, $err_code, $err_data, $phantom_ss, false);
31983197
}
31993198
}
3200-
if let PendingHTLCRouting::Forward { onion_packet, .. } = routing {
3201-
let phantom_secret_res = self.keys_manager.get_node_secret(Recipient::PhantomNode);
3202-
if phantom_secret_res.is_ok() && fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, short_chan_id) {
3203-
let phantom_shared_secret = SharedSecret::new(&onion_packet.public_key.unwrap(), &phantom_secret_res.unwrap()).secret_bytes();
3204-
let next_hop = match onion_utils::decode_next_payment_hop(phantom_shared_secret, &onion_packet.hop_data, onion_packet.hmac, payment_hash) {
3205-
Ok(res) => res,
3206-
Err(onion_utils::OnionDecodeErr::Malformed { err_msg, err_code }) => {
3207-
let sha256_of_onion = Sha256::hash(&onion_packet.hop_data).into_inner();
3208-
// In this scenario, the phantom would have sent us an
3209-
// `update_fail_malformed_htlc`, meaning here we encrypt the error as
3210-
// if it came from us (the second-to-last hop) but contains the sha256
3211-
// of the onion.
3212-
failed_payment!(err_msg, err_code, sha256_of_onion.to_vec(), None);
3213-
},
3214-
Err(onion_utils::OnionDecodeErr::Relay { err_msg, err_code }) => {
3215-
failed_payment!(err_msg, err_code, Vec::new(), Some(phantom_shared_secret));
3216-
},
3217-
};
3218-
match next_hop {
3219-
onion_utils::Hop::Receive(hop_data) => {
3220-
match self.construct_recv_pending_htlc_info(hop_data, incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value, Some(phantom_shared_secret)) {
3221-
Ok(info) => phantom_receives.push((prev_short_channel_id, prev_funding_outpoint, vec![(info, prev_htlc_id)])),
3222-
Err(ReceiveError { err_code, err_data, msg }) => failed_payment!(msg, err_code, err_data, Some(phantom_shared_secret))
3223-
}
3224-
},
3225-
_ => panic!(),
3226-
}
3227-
} else {
3228-
fail_forward!(format!("Unknown short channel id {} for forward HTLC", short_chan_id), 0x4000 | 10, Vec::new(), None);
3199+
}
3200+
if let PendingHTLCRouting::Forward { onion_packet, .. } = routing {
3201+
let phantom_secret_res = self.keys_manager.get_node_secret(Recipient::PhantomNode);
3202+
if phantom_secret_res.is_ok() && fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, short_chan_id) {
3203+
let phantom_shared_secret = SharedSecret::new(&onion_packet.public_key.unwrap(), &phantom_secret_res.unwrap()).secret_bytes();
3204+
let next_hop = match onion_utils::decode_next_payment_hop(phantom_shared_secret, &onion_packet.hop_data, onion_packet.hmac, payment_hash) {
3205+
Ok(res) => res,
3206+
Err(onion_utils::OnionDecodeErr::Malformed { err_msg, err_code }) => {
3207+
let sha256_of_onion = Sha256::hash(&onion_packet.hop_data).into_inner();
3208+
// In this scenario, the phantom would have sent us an
3209+
// `update_fail_malformed_htlc`, meaning here we encrypt the error as
3210+
// if it came from us (the second-to-last hop) but contains the sha256
3211+
// of the onion.
3212+
failed_payment!(err_msg, err_code, sha256_of_onion.to_vec(), None);
3213+
},
3214+
Err(onion_utils::OnionDecodeErr::Relay { err_msg, err_code }) => {
3215+
failed_payment!(err_msg, err_code, Vec::new(), Some(phantom_shared_secret));
3216+
},
3217+
};
3218+
match next_hop {
3219+
onion_utils::Hop::Receive(hop_data) => {
3220+
match self.construct_recv_pending_htlc_info(hop_data, incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value, Some(phantom_shared_secret)) {
3221+
Ok(info) => phantom_receives.push((prev_short_channel_id, prev_funding_outpoint, vec![(info, prev_htlc_id)])),
3222+
Err(ReceiveError { err_code, err_data, msg }) => failed_payment!(msg, err_code, err_data, Some(phantom_shared_secret))
3223+
}
3224+
},
3225+
_ => panic!(),
32293226
}
32303227
} else {
32313228
fail_forward!(format!("Unknown short channel id {} for forward HTLC", short_chan_id), 0x4000 | 10, Vec::new(), None);
32323229
}
3233-
},
3230+
} else {
3231+
fail_forward!(format!("Unknown short channel id {} for forward HTLC", short_chan_id), 0x4000 | 10, Vec::new(), None);
3232+
}
3233+
},
32343234
HTLCForwardInfo::FailHTLC { .. } => {
32353235
// Channel went away before we could fail it. This implies
32363236
// the channel is now on chain and our counterparty is

0 commit comments

Comments
 (0)