@@ -267,11 +267,15 @@ pub enum PeeledOnion<CM: CustomOnionMessageContents> {
267
267
Receive ( OnionMessageContents < CM > , Option < [ u8 ; 32 ] > , Option < BlindedPath > )
268
268
}
269
269
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
272
276
pub fn create_onion_message < ES : Deref , NS : Deref , T : CustomOnionMessageContents > (
273
277
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 > ,
275
279
) -> Result < ( PublicKey , msgs:: OnionMessage ) , SendError >
276
280
where
277
281
ES :: Target : EntropySource ,
@@ -284,7 +288,7 @@ where
284
288
}
285
289
}
286
290
287
- if message . tlv_type ( ) < 64 { return Err ( SendError :: InvalidMessage ) }
291
+ if contents . tlv_type ( ) < 64 { return Err ( SendError :: InvalidMessage ) }
288
292
289
293
// If we are sending straight to a blinded path and we are the introduction node, we need to
290
294
// advance the blinded path by 1 hop so the second hop is the new introduction node.
@@ -311,7 +315,7 @@ where
311
315
}
312
316
} ;
313
317
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)
315
319
. map_err ( |e| SendError :: Secp256k1 ( e) ) ?;
316
320
317
321
let prng_seed = entropy_source. get_secure_random_bytes ( ) ;
@@ -449,16 +453,16 @@ where
449
453
}
450
454
}
451
455
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`.
453
458
///
454
459
/// See [`OnionMessenger`] for example usage.
455
460
pub fn send_onion_message < T : CustomOnionMessageContents > (
456
- & self , path : OnionMessagePath , message : OnionMessageContents < T > ,
461
+ & self , path : OnionMessagePath , contents : OnionMessageContents < T > ,
457
462
reply_path : Option < BlindedPath >
458
463
) -> Result < ( ) , SendError > {
459
464
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
462
466
) ?;
463
467
464
468
let mut pending_per_peer_msgs = self . pending_messages . lock ( ) . unwrap ( ) ;
0 commit comments