From: Jeffrey Czyz Date: Thu, 5 Oct 2023 01:23:34 +0000 (-1000) Subject: Clean up onion messenger parameters and docs X-Git-Tag: v0.0.118~11^2~11 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=a4894bd3caa31a77044ec5c62149249df56d3ec5;p=rust-lightning Clean up onion messenger parameters and docs --- diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index f271e2c20..3b65bb4b1 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -267,11 +267,15 @@ pub enum PeeledOnion { Receive(OnionMessageContents, Option<[u8; 32]>, Option) } -/// Create an onion message with contents `message` to the destination of `path`. -/// Returns (first_node_id, onion_msg) +/// Creates an [`OnionMessage`] with the given `contents` for sending to the destination of +/// `path`. +/// +/// Returns both the node id of the peer to send the message to and the message itself. +/// +/// [`OnionMessage`]: msgs::OnionMessage pub fn create_onion_message( entropy_source: &ES, node_signer: &NS, secp_ctx: &Secp256k1, - path: OnionMessagePath, message: OnionMessageContents, reply_path: Option, + path: OnionMessagePath, contents: OnionMessageContents, reply_path: Option, ) -> Result<(PublicKey, msgs::OnionMessage), SendError> where ES::Target: EntropySource, @@ -284,7 +288,7 @@ where } } - if message.tlv_type() < 64 { return Err(SendError::InvalidMessage) } + if contents.tlv_type() < 64 { return Err(SendError::InvalidMessage) } // 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. @@ -311,7 +315,7 @@ where } }; let (packet_payloads, packet_keys) = packet_payloads_and_keys( - &secp_ctx, &intermediate_nodes, destination, message, reply_path, &blinding_secret) + &secp_ctx, &intermediate_nodes, destination, contents, reply_path, &blinding_secret) .map_err(|e| SendError::Secp256k1(e))?; let prng_seed = entropy_source.get_secure_random_bytes(); @@ -449,16 +453,16 @@ where } } - /// Send an onion message with contents `message` to the destination of `path`. + /// Sends an [`msgs::OnionMessage`] with the given `contents` for sending to the destination of + /// `path`. /// /// See [`OnionMessenger`] for example usage. pub fn send_onion_message( - &self, path: OnionMessagePath, message: OnionMessageContents, + &self, path: OnionMessagePath, contents: OnionMessageContents, reply_path: Option ) -> Result<(), SendError> { let (first_node_id, onion_msg) = create_onion_message( - &self.entropy_source, &self.node_signer, &self.secp_ctx, - path, message, reply_path + &self.entropy_source, &self.node_signer, &self.secp_ctx, path, contents, reply_path )?; let mut pending_per_peer_msgs = self.pending_messages.lock().unwrap();