]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Require Destination in construct_keys_callback
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 16 Aug 2024 15:12:24 +0000 (10:12 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Tue, 20 Aug 2024 21:54:09 +0000 (16:54 -0500)
lightning/src/blinded_path/utils.rs
lightning/src/onion_message/messenger.rs

index a654ced66980c2aa7fcb679f0e640f29cb0158fb..8de36c1c88df4856064a94e1d6a6fcc74c09be71 100644 (file)
@@ -89,8 +89,8 @@ macro_rules! build_keys_helper {
 
 #[inline]
 pub(crate) fn construct_keys_callback<'a, T, I, F>(
-       secp_ctx: &Secp256k1<T>, unblinded_path: I, destination: Option<Destination>,
-       session_priv: &SecretKey, mut callback: F
+       secp_ctx: &Secp256k1<T>, unblinded_path: I, destination: Destination, session_priv: &SecretKey,
+       mut callback: F,
 ) -> Result<(), secp256k1::Error>
 where
        T: secp256k1::Signing + secp256k1::Verification,
@@ -102,17 +102,15 @@ where
        for pk in unblinded_path {
                build_keys_in_loop!(pk, false, None);
        }
-       if let Some(dest) = destination {
-               match dest {
-                       Destination::Node(pk) => {
-                               build_keys!(pk, false, None);
-                       },
-                       Destination::BlindedPath(BlindedMessagePath(BlindedPath { blinded_hops, .. })) => {
-                               for hop in blinded_hops {
-                                       build_keys_in_loop!(hop.blinded_node_id, true, Some(hop.encrypted_payload));
-                               }
-                       },
-               }
+       match destination {
+               Destination::Node(pk) => {
+                       build_keys!(pk, false, None);
+               },
+               Destination::BlindedPath(BlindedMessagePath(BlindedPath { blinded_hops, .. })) => {
+                       for hop in blinded_hops {
+                               build_keys_in_loop!(hop.blinded_node_id, true, Some(hop.encrypted_payload));
+                       }
+               },
        }
        Ok(())
 }
index 4f862acfae309f682d203adfe131cc9d65c50bbc..11a2d9f946ba8defd0679f1aa4e0dbb3d17f926a 100644 (file)
@@ -1810,7 +1810,7 @@ fn packet_payloads_and_keys<T: OnionMessageContents, S: secp256k1::Signing + sec
        let mut prev_control_tlvs_ss = None;
        let mut final_control_tlvs = None;
        utils::construct_keys_callback(
-               secp_ctx, unblinded_path.into_iter(), Some(destination), session_priv,
+               secp_ctx, unblinded_path.into_iter(), destination, session_priv,
                |_, onion_packet_ss, ephemeral_pubkey, control_tlvs_ss, unblinded_pk_opt, enc_payload_opt| {
                        if num_unblinded_hops != 0 && unblinded_path_idx < num_unblinded_hops {
                                if let Some(ss) = prev_control_tlvs_ss.take() {