Add is_intro_node_blinded_forward helper for onion_utils::Hop
authorWilmer Paulino <wilmer@wilmerpaulino.com>
Fri, 8 Mar 2024 08:05:14 +0000 (00:05 -0800)
committerWilmer Paulino <wilmer@wilmerpaulino.com>
Wed, 27 Mar 2024 21:28:02 +0000 (14:28 -0700)
lightning/src/ln/channelmanager.rs
lightning/src/ln/onion_utils.rs

index 3afc61095c309a6a81d339f1083de7e5842f5aab..685caba75c2024469178b04e367db625fd4fbfce 100644 (file)
@@ -3103,15 +3103,6 @@ where
                        msg, &self.node_signer, &self.logger, &self.secp_ctx
                )?;
 
-               let is_intro_node_forward = match next_hop {
-                       onion_utils::Hop::Forward {
-                               next_hop_data: msgs::InboundOnionPayload::BlindedForward {
-                                       intro_node_blinding_point: Some(_), ..
-                               }, ..
-                       } => true,
-                       _ => false,
-               };
-
                macro_rules! return_err {
                        ($msg: expr, $err_code: expr, $data: expr) => {
                                {
@@ -3129,7 +3120,7 @@ where
                                                }));
                                        }
 
-                                       let (err_code, err_data) = if is_intro_node_forward {
+                                       let (err_code, err_data) = if next_hop.is_intro_node_blinded_forward() {
                                                (INVALID_ONION_BLINDING, &[0; 32][..])
                                        } else { ($err_code, $data) };
                                        return Err(HTLCFailureMsg::Relay(msgs::UpdateFailHTLC {
index 53ef0729aa171ba56ff33ba73a55cb4ed922df83..4bb77bb4b51f19774a36076aa5287b738ede252d 100644 (file)
@@ -1054,6 +1054,21 @@ pub(crate) enum Hop {
        },
 }
 
+impl Hop {
+       pub(crate) fn is_intro_node_blinded_forward(&self) -> bool {
+               match self {
+                       Self::Forward {
+                               next_hop_data:
+                                       msgs::InboundOnionPayload::BlindedForward {
+                                               intro_node_blinding_point: Some(_), ..
+                                       },
+                               ..
+                       } => true,
+                       _ => false,
+               }
+       }
+}
+
 /// Error returned when we fail to decode the onion packet.
 #[derive(Debug)]
 pub(crate) enum OnionDecodeErr {