Skip to content

Commit a4894bd

Browse files
committed
Clean up onion messenger parameters and docs
1 parent b78cb69 commit a4894bd

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,15 @@ pub enum PeeledOnion<CM: CustomOnionMessageContents> {
267267
Receive(OnionMessageContents<CM>, Option<[u8; 32]>, Option<BlindedPath>)
268268
}
269269

270-
/// Create an onion message with contents `message` to the destination of `path`.
271-
/// Returns (first_node_id, onion_msg)
270+
/// Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
271+
/// `path`.
272+
///
273+
/// Returns both the node id of the peer to send the message to and the message itself.
274+
///
275+
/// [`OnionMessage`]: msgs::OnionMessage
272276
pub fn create_onion_message<ES: Deref, NS: Deref, T: CustomOnionMessageContents>(
273277
entropy_source: &ES, node_signer: &NS, secp_ctx: &Secp256k1<secp256k1::All>,
274-
path: OnionMessagePath, message: OnionMessageContents<T>, reply_path: Option<BlindedPath>,
278+
path: OnionMessagePath, contents: OnionMessageContents<T>, reply_path: Option<BlindedPath>,
275279
) -> Result<(PublicKey, msgs::OnionMessage), SendError>
276280
where
277281
ES::Target: EntropySource,
@@ -284,7 +288,7 @@ where
284288
}
285289
}
286290

287-
if message.tlv_type() < 64 { return Err(SendError::InvalidMessage) }
291+
if contents.tlv_type() < 64 { return Err(SendError::InvalidMessage) }
288292

289293
// If we are sending straight to a blinded path and we are the introduction node, we need to
290294
// advance the blinded path by 1 hop so the second hop is the new introduction node.
@@ -311,7 +315,7 @@ where
311315
}
312316
};
313317
let (packet_payloads, packet_keys) = packet_payloads_and_keys(
314-
&secp_ctx, &intermediate_nodes, destination, message, reply_path, &blinding_secret)
318+
&secp_ctx, &intermediate_nodes, destination, contents, reply_path, &blinding_secret)
315319
.map_err(|e| SendError::Secp256k1(e))?;
316320

317321
let prng_seed = entropy_source.get_secure_random_bytes();
@@ -449,16 +453,16 @@ where
449453
}
450454
}
451455

452-
/// Send an onion message with contents `message` to the destination of `path`.
456+
/// Sends an [`msgs::OnionMessage`] with the given `contents` for sending to the destination of
457+
/// `path`.
453458
///
454459
/// See [`OnionMessenger`] for example usage.
455460
pub fn send_onion_message<T: CustomOnionMessageContents>(
456-
&self, path: OnionMessagePath, message: OnionMessageContents<T>,
461+
&self, path: OnionMessagePath, contents: OnionMessageContents<T>,
457462
reply_path: Option<BlindedPath>
458463
) -> Result<(), SendError> {
459464
let (first_node_id, onion_msg) = create_onion_message(
460-
&self.entropy_source, &self.node_signer, &self.secp_ctx,
461-
path, message, reply_path
465+
&self.entropy_source, &self.node_signer, &self.secp_ctx, path, contents, reply_path
462466
)?;
463467

464468
let mut pending_per_peer_msgs = self.pending_messages.lock().unwrap();

0 commit comments

Comments
 (0)