Export Onion Message structs in their respective modules
[rust-lightning] / lightning / src / onion_message / messenger.rs
index f627f9736b3eca0ee7d7f3d0395f57baa0aeb7e4..3ee9d8fc4fabe81b9438367ac96bfcd903c97638 100644 (file)
@@ -20,8 +20,8 @@ use crate::ln::features::{InitFeatures, NodeFeatures};
 use crate::ln::msgs::{self, OnionMessageHandler};
 use crate::ln::onion_utils;
 use crate::ln::peer_handler::IgnoringMessageHandler;
-use super::blinded_route::{BlindedPath, ForwardTlvs, ReceiveTlvs};
-pub use super::packet::{CustomOnionMessageContents, OnionMessageContents};
+use super::blinded_path::{BlindedPath, ForwardTlvs, ReceiveTlvs};
+use super::packet::{CustomOnionMessageContents, OnionMessageContents};
 use super::packet::{BIG_PACKET_HOP_DATA_LEN, ForwardControlTlvs, Packet, Payload, ReceiveControlTlvs, SMALL_PACKET_HOP_DATA_LEN};
 use super::utils;
 use crate::util::events::OnionMessageProvider;
@@ -46,7 +46,8 @@ use crate::prelude::*;
 /// # use lightning::chain::keysinterface::{InMemorySigner, KeysManager, KeysInterface};
 /// # use lightning::ln::msgs::DecodeError;
 /// # use lightning::ln::peer_handler::IgnoringMessageHandler;
-/// # use lightning::onion_message::{BlindedPath, CustomOnionMessageContents, Destination, OnionMessageContents, OnionMessenger};
+/// # use lightning::onion_message::blinded_path::BlindedPath;
+/// # use lightning::onion_message::messenger::{CustomOnionMessageContents, Destination, OnionMessageContents, OnionMessenger};
 /// # use lightning::util::logger::{Logger, Record};
 /// # use lightning::util::ser::{Writeable, Writer};
 /// # use lightning::io;
@@ -89,17 +90,17 @@ use crate::prelude::*;
 /// let message = OnionMessageContents::Custom(your_custom_message);
 /// onion_messenger.send_onion_message(&intermediate_hops, Destination::Node(destination_node_id), message, reply_path);
 ///
-/// // Create a blinded route to yourself, for someone to send an onion message to.
+/// // Create a blinded path to yourself, for someone to send an onion message to.
 /// # let your_node_id = hop_node_id1;
 /// let hops = [hop_node_id3, hop_node_id4, your_node_id];
-/// let blinded_route = BlindedPath::new(&hops, &keys_manager, &secp_ctx).unwrap();
+/// let blinded_path = BlindedPath::new(&hops, &keys_manager, &secp_ctx).unwrap();
 ///
-/// // Send a custom onion message to a blinded route.
+/// // Send a custom onion message to a blinded path.
 /// # let intermediate_hops = [hop_node_id1, hop_node_id2];
 /// let reply_path = None;
 /// # let your_custom_message = YourCustomMessage {};
 /// let message = OnionMessageContents::Custom(your_custom_message);
-/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedPath(blinded_route), message, reply_path);
+/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedPath(blinded_path), message, reply_path);
 /// ```
 ///
 /// [offers]: <https://github.com/lightning/bolts/pull/798>
@@ -122,7 +123,7 @@ pub struct OnionMessenger<K: Deref, L: Deref, CMH: Deref>
 pub enum Destination {
        /// We're sending this onion message to a node.
        Node(PublicKey),
-       /// We're sending this onion message to a blinded route.
+       /// We're sending this onion message to a blinded path.
        BlindedPath(BlindedPath),
 }
 
@@ -158,8 +159,8 @@ pub enum SendError {
        ///
        /// [`KeysInterface`]: crate::chain::keysinterface::KeysInterface
        GetNodeIdFailed,
-       /// We attempted to send to a blinded route where we are the introduction node, and failed to
-       /// advance the blinded route to make the second hop the new introduction node. Either
+       /// We attempted to send to a blinded path where we are the introduction node, and failed to
+       /// advance the blinded path to make the second hop the new introduction node. Either
        /// [`KeysInterface::ecdh`] failed, we failed to tweak the current blinding point to get the
        /// new blinding point, or we were attempting to send to ourselves.
        BlindedPathAdvanceFailed,
@@ -216,14 +217,14 @@ impl<K: Deref, L: Deref, CMH: Deref> OnionMessenger<K, L, CMH>
                let OnionMessageContents::Custom(ref msg) = message;
                if msg.tlv_type() < 64 { return Err(SendError::InvalidMessage) }
 
-               // If we are sending straight to a blinded route and we are the introduction node, we need to
-               // advance the blinded route by 1 hop so the second hop is the new introduction node.
+               // If we are sending straight to a blinded path and we are the introduction node, we need to
+               // advance the blinded path by 1 hop so the second hop is the new introduction node.
                if intermediate_nodes.len() == 0 {
-                       if let Destination::BlindedPath(ref mut blinded_route) = destination {
+                       if let Destination::BlindedPath(ref mut blinded_path) = destination {
                                let our_node_id = self.keys_manager.get_node_id(Recipient::Node)
                                        .map_err(|()| SendError::GetNodeIdFailed)?;
-                               if blinded_route.introduction_node_id == our_node_id {
-                                       blinded_route.advance_by_one(&self.keys_manager, &self.secp_ctx)
+                               if blinded_path.introduction_node_id == our_node_id {
+                                       blinded_path.advance_by_one(&self.keys_manager, &self.secp_ctx)
                                                .map_err(|()| SendError::BlindedPathAdvanceFailed)?;
                                }
                        }
@@ -346,7 +347,7 @@ impl<K: Deref, L: Deref, CMH: Deref> OnionMessageHandler for OnionMessenger<K, L
                                // TODO: we need to check whether `next_node_id` is our node, in which case this is a dummy
                                // blinded hop and this onion message is destined for us. In this situation, we should keep
                                // unwrapping the onion layers to get to the final payload. Since we don't have the option
-                               // of creating blinded routes with dummy hops currently, we should be ok to not handle this
+                               // of creating blinded paths with dummy hops currently, we should be ok to not handle this
                                // for now.
                                let new_pubkey = match onion_utils::next_hop_packet_pubkey(&self.secp_ctx, msg.onion_routing_packet.public_key, &onion_decode_ss) {
                                        Ok(pk) => pk,