Skip to content

Commit cc516ad

Browse files
committed
Add is_intro_node_blinded_forward helper for onion_utils::Hop
1 parent db54cb8 commit cc516ad

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
@@ -3100,15 +3100,6 @@ where
31003100
msg, &self.node_signer, &self.logger, &self.secp_ctx
31013101
)?;
31023102

3103-
let is_intro_node_forward = match next_hop {
3104-
onion_utils::Hop::Forward {
3105-
next_hop_data: msgs::InboundOnionPayload::BlindedForward {
3106-
intro_node_blinding_point: Some(_), ..
3107-
}, ..
3108-
} => true,
3109-
_ => false,
3110-
};
3111-
31123103
macro_rules! return_err {
31133104
($msg: expr, $err_code: expr, $data: expr) => {
31143105
{
@@ -3126,7 +3117,7 @@ where
31263117
}));
31273118
}
31283119

3129-
let (err_code, err_data) = if is_intro_node_forward {
3120+
let (err_code, err_data) = if next_hop.is_intro_node_blinded_forward() {
31303121
(INVALID_ONION_BLINDING, &[0; 32][..])
31313122
} else { ($err_code, $data) };
31323123
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
@@ -1053,6 +1053,21 @@ pub(crate) enum Hop {
10531053
},
10541054
}
10551055

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

0 commit comments

Comments
 (0)