@@ -151,7 +151,7 @@ for OnionMessenger<ES, NS, L, NL, MR, OMH, APH, CMH> where
151151/// # use lightning::blinded_path::message::{ForwardNode, MessageContext};
152152/// # use lightning::sign::{EntropySource, KeysManager};
153153/// # use lightning::ln::peer_handler::IgnoringMessageHandler;
154- /// # use lightning::onion_message::messenger::{Destination, MessageRouter, OnionMessagePath, OnionMessenger};
154+ /// # use lightning::onion_message::messenger::{BlindedPathParams, Destination, MessageRouter, OnionMessagePath, OnionMessenger};
155155/// # use lightning::onion_message::packet::OnionMessageContents;
156156/// # use lightning::util::logger::{Logger, Record};
157157/// # use lightning::util::ser::{Writeable, Writer};
@@ -175,7 +175,7 @@ for OnionMessenger<ES, NS, L, NL, MR, OMH, APH, CMH> where
175175/// # })
176176/// # }
177177/// # fn create_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
178- /// # &self, _recipient: PublicKey, _context: MessageContext, _peers: Vec<PublicKey>, _secp_ctx: &Secp256k1<T>
178+ /// # &self, _params: BlindedPathParams, _recipient: PublicKey, _context: MessageContext, _peers: Vec<PublicKey>, _secp_ctx: &Secp256k1<T>
179179/// # ) -> Result<Vec<BlindedPath>, ()> {
180180/// # unreachable!()
181181/// # }
@@ -421,7 +421,7 @@ pub struct PendingOnionMessage<T: OnionMessageContents> {
421421///
422422/// PATHS_PLACEHOLDER` is temporarily used as a default value in situations
423423/// where a path index is required but has not yet been assigned or initialized.
424- pub const PATHS_PLACEHOLDER : usize = 0 ;
424+ pub const PATHS_PLACEHOLDER : usize = 3 ;
425425
426426/// Represents the types of [`BlindedPath`] that can be created.
427427///
@@ -461,7 +461,7 @@ pub trait MessageRouter {
461461 fn create_blinded_paths <
462462 T : secp256k1:: Signing + secp256k1:: Verification
463463 > (
464- & self , recipient : PublicKey , context : MessageContext , peers : Vec < PublicKey > , secp_ctx : & Secp256k1 < T > ,
464+ & self , params : BlindedPathParams , recipient : PublicKey , context : MessageContext , peers : Vec < PublicKey > , secp_ctx : & Secp256k1 < T > ,
465465 ) -> Result < Vec < BlindedPath > , ( ) > ;
466466
467467 /// Creates compact [`BlindedPath`]s to the `recipient` node. The nodes in `peers` are assumed
@@ -487,7 +487,13 @@ pub trait MessageRouter {
487487 . into_iter ( )
488488 . map ( |ForwardNode { node_id, short_channel_id : _ } | node_id)
489489 . collect ( ) ;
490- self . create_blinded_paths ( recipient, context, peers, secp_ctx)
490+
491+ // This parameter is a placeholder. This function is removed in the subsequent commits.
492+ let params = BlindedPathParams {
493+ paths : PATHS_PLACEHOLDER ,
494+ is_compact : true ,
495+ } ;
496+ self . create_blinded_paths ( params, recipient, context, peers, secp_ctx)
491497 }
492498}
493499
@@ -522,12 +528,9 @@ where
522528 I : ExactSizeIterator < Item = ForwardNode > ,
523529 T : secp256k1:: Signing + secp256k1:: Verification
524530 > (
525- network_graph : & G , recipient : PublicKey , context : MessageContext , peers : I ,
526- entropy_source : & ES , secp_ctx : & Secp256k1 < T > , compact_paths : bool ,
531+ params : BlindedPathParams , network_graph : & G , recipient : PublicKey , context : MessageContext , peers : I ,
532+ entropy_source : & ES , secp_ctx : & Secp256k1 < T >
527533 ) -> Result < Vec < BlindedPath > , ( ) > {
528- // Limit the number of blinded paths that are computed.
529- const MAX_PATHS : usize = 3 ;
530-
531534 // Ensure peers have at least three channels so that it is more difficult to infer the
532535 // recipient's node_id.
533536 const MIN_PEER_CHANNELS : usize = 3 ;
@@ -564,7 +567,7 @@ where
564567 . map ( |( peer, _, _) | {
565568 BlindedPath :: new_for_message ( & [ peer] , recipient, context. clone ( ) , & * * entropy_source, secp_ctx)
566569 } )
567- . take ( MAX_PATHS )
570+ . take ( params . paths )
568571 . collect :: < Result < Vec < _ > , _ > > ( ) ;
569572
570573 let mut paths = match paths {
@@ -579,7 +582,7 @@ where
579582 } ,
580583 } ?;
581584
582- if compact_paths {
585+ if params . is_compact {
583586 for path in & mut paths {
584587 path. use_compact_introduction_node ( & network_graph) ;
585588 }
@@ -624,13 +627,13 @@ where
624627 pub ( crate ) fn create_blinded_paths <
625628 T : secp256k1:: Signing + secp256k1:: Verification
626629 > (
627- network_graph : & G , recipient : PublicKey , context : MessageContext ,
630+ params : BlindedPathParams , network_graph : & G , recipient : PublicKey , context : MessageContext ,
628631 peers : Vec < PublicKey > , entropy_source : & ES , secp_ctx : & Secp256k1 < T > ,
629632 ) -> Result < Vec < BlindedPath > , ( ) > {
630633 let peers = peers
631634 . into_iter ( )
632635 . map ( |node_id| ForwardNode { node_id, short_channel_id : None } ) ;
633- Self :: create_blinded_paths_from_iter ( network_graph, recipient, context, peers. into_iter ( ) , entropy_source, secp_ctx, false )
636+ Self :: create_blinded_paths_from_iter ( params , network_graph, recipient, context, peers. into_iter ( ) , entropy_source, secp_ctx)
634637 }
635638
636639 pub ( crate ) fn create_compact_blinded_paths <
@@ -639,7 +642,11 @@ where
639642 network_graph : & G , recipient : PublicKey , context : MessageContext ,
640643 peers : Vec < ForwardNode > , entropy_source : & ES , secp_ctx : & Secp256k1 < T > ,
641644 ) -> Result < Vec < BlindedPath > , ( ) > {
642- Self :: create_blinded_paths_from_iter ( network_graph, recipient, context, peers. into_iter ( ) , entropy_source, secp_ctx, true )
645+ let params = BlindedPathParams {
646+ paths : PATHS_PLACEHOLDER ,
647+ is_compact : true ,
648+ } ;
649+ Self :: create_blinded_paths_from_iter ( params, network_graph, recipient, context, peers. into_iter ( ) , entropy_source, secp_ctx)
643650 }
644651}
645652
@@ -657,9 +664,9 @@ where
657664 fn create_blinded_paths <
658665 T : secp256k1:: Signing + secp256k1:: Verification
659666 > (
660- & self , recipient : PublicKey , context : MessageContext , peers : Vec < PublicKey > , secp_ctx : & Secp256k1 < T > ,
667+ & self , params : BlindedPathParams , recipient : PublicKey , context : MessageContext , peers : Vec < PublicKey > , secp_ctx : & Secp256k1 < T > ,
661668 ) -> Result < Vec < BlindedPath > , ( ) > {
662- Self :: create_blinded_paths ( & self . network_graph , recipient, context, peers, & self . entropy_source , secp_ctx)
669+ Self :: create_blinded_paths ( params , & self . network_graph , recipient, context, peers, & self . entropy_source , secp_ctx)
663670 }
664671
665672 fn create_compact_blinded_paths <
@@ -1235,7 +1242,7 @@ where
12351242 . map_err ( |_| SendError :: PathNotFound )
12361243 }
12371244
1238- fn create_blinded_path ( & self , context : MessageContext ) -> Result < BlindedPath , SendError > {
1245+ fn create_blinded_path ( & self , params : BlindedPathParams , context : MessageContext ) -> Result < BlindedPath , SendError > {
12391246 let recipient = self . node_signer
12401247 . get_node_id ( Recipient :: Node )
12411248 . map_err ( |_| SendError :: GetNodeIdFailed ) ?;
@@ -1248,7 +1255,7 @@ where
12481255 . collect :: < Vec < _ > > ( ) ;
12491256
12501257 self . message_router
1251- . create_blinded_paths ( recipient, context, peers, secp_ctx)
1258+ . create_blinded_paths ( params , recipient, context, peers, secp_ctx)
12521259 . and_then ( |paths| paths. into_iter ( ) . next ( ) . ok_or ( ( ) ) )
12531260 . map_err ( |_| SendError :: PathNotFound )
12541261 }
@@ -1346,7 +1353,11 @@ where
13461353
13471354 let message_type = response. message . msg_type ( ) ;
13481355 let reply_path = if let Some ( context) = context {
1349- match self . create_blinded_path ( context) {
1356+ let params = BlindedPathParams {
1357+ paths : PATHS_PLACEHOLDER ,
1358+ is_compact : false ,
1359+ } ;
1360+ match self . create_blinded_path ( params, context) {
13501361 Ok ( reply_path) => Some ( reply_path) ,
13511362 Err ( err) => {
13521363 log_trace ! (
0 commit comments