@@ -268,7 +268,7 @@ pub enum PeeledOnion<CM: CustomOnionMessageContents> {
268
268
}
269
269
270
270
/// Create an onion message with contents `message` to the destination of `path`.
271
- /// Returns (introduction_node_id , onion_msg)
271
+ /// Returns (first_node_id , onion_msg)
272
272
pub fn create_onion_message < ES : Deref , NS : Deref , T : CustomOnionMessageContents > (
273
273
entropy_source : & ES , node_signer : & NS , secp_ctx : & Secp256k1 < secp256k1:: All > ,
274
274
path : OnionMessagePath , message : OnionMessageContents < T > , reply_path : Option < BlindedPath > ,
@@ -301,8 +301,8 @@ where
301
301
302
302
let blinding_secret_bytes = entropy_source. get_secure_random_bytes ( ) ;
303
303
let blinding_secret = SecretKey :: from_slice ( & blinding_secret_bytes[ ..] ) . expect ( "RNG is busted" ) ;
304
- let ( introduction_node_id , blinding_point) = if intermediate_nodes . len ( ) != 0 {
305
- ( intermediate_nodes [ 0 ] , PublicKey :: from_secret_key ( & secp_ctx, & blinding_secret) )
304
+ let ( first_node_id , blinding_point) = if let Some ( first_node_id ) = intermediate_nodes . first ( ) {
305
+ ( * first_node_id , PublicKey :: from_secret_key ( & secp_ctx, & blinding_secret) )
306
306
} else {
307
307
match destination {
308
308
Destination :: Node ( pk) => ( pk, PublicKey :: from_secret_key ( & secp_ctx, & blinding_secret) ) ,
@@ -318,7 +318,7 @@ where
318
318
let onion_routing_packet = construct_onion_message_packet (
319
319
packet_payloads, packet_keys, prng_seed) . map_err ( |( ) | SendError :: TooBigPacket ) ?;
320
320
321
- Ok ( ( introduction_node_id , msgs:: OnionMessage {
321
+ Ok ( ( first_node_id , msgs:: OnionMessage {
322
322
blinding_point,
323
323
onion_routing_packet
324
324
} ) )
@@ -456,14 +456,14 @@ where
456
456
& self , path : OnionMessagePath , message : OnionMessageContents < T > ,
457
457
reply_path : Option < BlindedPath >
458
458
) -> Result < ( ) , SendError > {
459
- let ( introduction_node_id , onion_msg) = create_onion_message (
459
+ let ( first_node_id , onion_msg) = create_onion_message (
460
460
& self . entropy_source , & self . node_signer , & self . secp_ctx ,
461
461
path, message, reply_path
462
462
) ?;
463
463
464
464
let mut pending_per_peer_msgs = self . pending_messages . lock ( ) . unwrap ( ) ;
465
- if outbound_buffer_full ( & introduction_node_id , & pending_per_peer_msgs) { return Err ( SendError :: BufferFull ) }
466
- match pending_per_peer_msgs. entry ( introduction_node_id ) {
465
+ if outbound_buffer_full ( & first_node_id , & pending_per_peer_msgs) { return Err ( SendError :: BufferFull ) }
466
+ match pending_per_peer_msgs. entry ( first_node_id ) {
467
467
hash_map:: Entry :: Vacant ( _) => Err ( SendError :: InvalidFirstHop ) ,
468
468
hash_map:: Entry :: Occupied ( mut e) => {
469
469
e. get_mut ( ) . push_back ( onion_msg) ;
0 commit comments