@@ -20,7 +20,7 @@ use crate::blinded_path::message::{advance_path_by_one, ForwardTlvs, ReceiveTlvs
20
20
use crate :: blinded_path:: utils;
21
21
use crate :: sign:: { EntropySource , KeysManager , NodeSigner , Recipient } ;
22
22
use crate :: ln:: features:: { InitFeatures , NodeFeatures } ;
23
- use crate :: ln:: msgs:: { self , OnionMessageHandler } ;
23
+ use crate :: ln:: msgs:: { self , OnionMessage , OnionMessageHandler } ;
24
24
use crate :: ln:: onion_utils;
25
25
use crate :: ln:: peer_handler:: IgnoringMessageHandler ;
26
26
pub use super :: packet:: { CustomOnionMessageContents , OnionMessageContents } ;
@@ -132,7 +132,6 @@ use crate::prelude::*;
132
132
/// onion_messenger.send_onion_message(path, message, reply_path);
133
133
/// ```
134
134
///
135
- /// [`OnionMessage`]: crate::ln::msgs::OnionMessage
136
135
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
137
136
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
138
137
pub struct OnionMessenger < ES : Deref , NS : Deref , L : Deref , MR : Deref , OMH : Deref , CMH : Deref >
@@ -147,20 +146,16 @@ where
147
146
entropy_source : ES ,
148
147
node_signer : NS ,
149
148
logger : L ,
150
- pending_messages : Mutex < HashMap < PublicKey , VecDeque < msgs :: OnionMessage > > > ,
149
+ pending_messages : Mutex < HashMap < PublicKey , VecDeque < OnionMessage > > > ,
151
150
secp_ctx : Secp256k1 < secp256k1:: All > ,
152
151
message_router : MR ,
153
152
offers_handler : OMH ,
154
153
custom_handler : CMH ,
155
154
}
156
155
157
156
/// A trait defining behavior for routing an [`OnionMessage`].
158
- ///
159
- /// [`OnionMessage`]: msgs::OnionMessage
160
157
pub trait MessageRouter {
161
158
/// Returns a route for sending an [`OnionMessage`] to the given [`Destination`].
162
- ///
163
- /// [`OnionMessage`]: msgs::OnionMessage
164
159
fn find_path (
165
160
& self , sender : PublicKey , peers : Vec < PublicKey > , destination : Destination
166
161
) -> Result < OnionMessagePath , ( ) > ;
@@ -177,7 +172,7 @@ impl MessageRouter for DefaultMessageRouter {
177
172
}
178
173
}
179
174
180
- /// A path for sending an [`msgs:: OnionMessage`].
175
+ /// A path for sending an [`OnionMessage`].
181
176
#[ derive( Clone ) ]
182
177
pub struct OnionMessagePath {
183
178
/// Nodes on the path between the sender and the destination.
@@ -262,7 +257,7 @@ pub trait CustomOnionMessageHandler {
262
257
/// or a Receive payload with decrypted contents.
263
258
pub enum PeeledOnion < CM : CustomOnionMessageContents > {
264
259
/// Forwarded onion, with the next node id and a new onion
265
- Forward ( PublicKey , msgs :: OnionMessage ) ,
260
+ Forward ( PublicKey , OnionMessage ) ,
266
261
/// Received onion message, with decrypted contents, path_id, and reply path
267
262
Receive ( OnionMessageContents < CM > , Option < [ u8 ; 32 ] > , Option < BlindedPath > )
268
263
}
@@ -271,12 +266,10 @@ pub enum PeeledOnion<CM: CustomOnionMessageContents> {
271
266
/// `path`.
272
267
///
273
268
/// Returns both the node id of the peer to send the message to and the message itself.
274
- ///
275
- /// [`OnionMessage`]: msgs::OnionMessage
276
269
pub fn create_onion_message < ES : Deref , NS : Deref , T : CustomOnionMessageContents > (
277
270
entropy_source : & ES , node_signer : & NS , secp_ctx : & Secp256k1 < secp256k1:: All > ,
278
271
path : OnionMessagePath , contents : OnionMessageContents < T > , reply_path : Option < BlindedPath > ,
279
- ) -> Result < ( PublicKey , msgs :: OnionMessage ) , SendError >
272
+ ) -> Result < ( PublicKey , OnionMessage ) , SendError >
280
273
where
281
274
ES :: Target : EntropySource ,
282
275
NS :: Target : NodeSigner ,
@@ -322,7 +315,7 @@ where
322
315
let onion_routing_packet = construct_onion_message_packet (
323
316
packet_payloads, packet_keys, prng_seed) . map_err ( |( ) | SendError :: TooBigPacket ) ?;
324
317
325
- Ok ( ( first_node_id, msgs :: OnionMessage {
318
+ Ok ( ( first_node_id, OnionMessage {
326
319
blinding_point,
327
320
onion_routing_packet
328
321
} ) )
@@ -332,7 +325,7 @@ where
332
325
/// Returns either a Forward (another onion message), or Receive (decrypted content)
333
326
pub fn peel_onion < NS : Deref , L : Deref , CMH : Deref > (
334
327
node_signer : NS , secp_ctx : & Secp256k1 < secp256k1:: All > , logger : L , custom_handler : CMH ,
335
- msg : & msgs :: OnionMessage ,
328
+ msg : & OnionMessage ,
336
329
) -> Result < PeeledOnion < <<CMH >:: Target as CustomOnionMessageHandler >:: CustomMessage > , ( ) >
337
330
where
338
331
NS :: Target : NodeSigner ,
@@ -392,7 +385,7 @@ where
392
385
hop_data : new_packet_bytes,
393
386
hmac : next_hop_hmac,
394
387
} ;
395
- let onion_message = msgs :: OnionMessage {
388
+ let onion_message = OnionMessage {
396
389
blinding_point : match next_blinding_override {
397
390
Some ( blinding_point) => blinding_point,
398
391
None => {
@@ -453,7 +446,7 @@ where
453
446
}
454
447
}
455
448
456
- /// Sends an [`msgs:: OnionMessage`] with the given `contents` for sending to the destination of
449
+ /// Sends an [`OnionMessage`] with the given `contents` for sending to the destination of
457
450
/// `path`.
458
451
///
459
452
/// See [`OnionMessenger`] for example usage.
@@ -527,7 +520,7 @@ where
527
520
}
528
521
529
522
#[ cfg( test) ]
530
- pub ( super ) fn release_pending_msgs ( & self ) -> HashMap < PublicKey , VecDeque < msgs :: OnionMessage > > {
523
+ pub ( super ) fn release_pending_msgs ( & self ) -> HashMap < PublicKey , VecDeque < OnionMessage > > {
531
524
let mut pending_msgs = self . pending_messages . lock ( ) . unwrap ( ) ;
532
525
let mut msgs = HashMap :: new ( ) ;
533
526
// We don't want to disconnect the peers by removing them entirely from the original map, so we
@@ -539,7 +532,7 @@ where
539
532
}
540
533
}
541
534
542
- fn outbound_buffer_full ( peer_node_id : & PublicKey , buffer : & HashMap < PublicKey , VecDeque < msgs :: OnionMessage > > ) -> bool {
535
+ fn outbound_buffer_full ( peer_node_id : & PublicKey , buffer : & HashMap < PublicKey , VecDeque < OnionMessage > > ) -> bool {
543
536
const MAX_TOTAL_BUFFER_SIZE : usize = ( 1 << 20 ) * 128 ;
544
537
const MAX_PER_PEER_BUFFER_SIZE : usize = ( 1 << 10 ) * 256 ;
545
538
let mut total_buffered_bytes = 0 ;
@@ -575,7 +568,7 @@ where
575
568
/// Handle an incoming onion message. Currently, if a message was destined for us we will log, but
576
569
/// soon we'll delegate the onion message to a handler that can generate invoices or send
577
570
/// payments.
578
- fn handle_onion_message ( & self , _peer_node_id : & PublicKey , msg : & msgs :: OnionMessage ) {
571
+ fn handle_onion_message ( & self , _peer_node_id : & PublicKey , msg : & OnionMessage ) {
579
572
match peel_onion (
580
573
& * self . node_signer , & self . secp_ctx , & * self . logger , & * self . custom_handler , msg
581
574
) {
@@ -649,7 +642,7 @@ where
649
642
features
650
643
}
651
644
652
- fn next_onion_message_for_peer ( & self , peer_node_id : PublicKey ) -> Option < msgs :: OnionMessage > {
645
+ fn next_onion_message_for_peer ( & self , peer_node_id : PublicKey ) -> Option < OnionMessage > {
653
646
let mut pending_msgs = self . pending_messages . lock ( ) . unwrap ( ) ;
654
647
if let Some ( msgs) = pending_msgs. get_mut ( & peer_node_id) {
655
648
return msgs. pop_front ( )
0 commit comments