Skip to content

Commit 3f940d3

Browse files
committed
Add is_intro_node_blinded_forward helper for onion_utils::Hop
1 parent e255b23 commit 3f940d3

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,15 +3103,6 @@ where
31033103
msg, &self.node_signer, &self.logger, &self.secp_ctx
31043104
)?;
31053105

3106-
let is_intro_node_forward = match next_hop {
3107-
onion_utils::Hop::Forward {
3108-
next_hop_data: msgs::InboundOnionPayload::BlindedForward {
3109-
intro_node_blinding_point: Some(_), ..
3110-
}, ..
3111-
} => true,
3112-
_ => false,
3113-
};
3114-
31153106
macro_rules! return_err {
31163107
($msg: expr, $err_code: expr, $data: expr) => {
31173108
{
@@ -3129,7 +3120,7 @@ where
31293120
}));
31303121
}
31313122

3132-
let (err_code, err_data) = if is_intro_node_forward {
3123+
let (err_code, err_data) = if next_hop.is_intro_node_blinded_forward() {
31333124
(INVALID_ONION_BLINDING, &[0; 32][..])
31343125
} else { ($err_code, $data) };
31353126
return Err(HTLCFailureMsg::Relay(msgs::UpdateFailHTLC {

lightning/src/ln/onion_utils.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,21 @@ pub(crate) enum Hop {
10541054
},
10551055
}
10561056

1057+
impl Hop {
1058+
pub(crate) fn is_intro_node_blinded_forward(&self) -> bool {
1059+
match self {
1060+
Self::Forward {
1061+
next_hop_data:
1062+
msgs::InboundOnionPayload::BlindedForward {
1063+
intro_node_blinding_point: Some(_), ..
1064+
},
1065+
..
1066+
} => true,
1067+
_ => false,
1068+
}
1069+
}
1070+
}
1071+
10571072
/// Error returned when we fail to decode the onion packet.
10581073
#[derive(Debug)]
10591074
pub(crate) enum OnionDecodeErr {

0 commit comments

Comments
 (0)