@@ -58,6 +58,7 @@ use crate::offers::invoice_request::InvoiceRequestBuilder;
5858use  crate :: offers:: offer:: { Offer ,  OfferBuilder } ; 
5959use  crate :: offers:: parse:: SemanticError ; 
6060use  crate :: offers:: refund:: RefundBuilder ; 
61+ use  crate :: onion_message:: BlindedPath ; 
6162use  crate :: util:: config:: { UserConfig ,  ChannelConfig } ; 
6263use  crate :: util:: events:: { Event ,  EventHandler ,  EventsProvider ,  MessageSendEvent ,  MessageSendEventsProvider ,  ClosureReason ,  HTLCDestination } ; 
6364use  crate :: util:: events; 
@@ -5434,6 +5435,10 @@ where
54345435	/// Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the 
54355436/// [`OnionMessenger`] when handling [`InvoiceRequest`] messages for the offer. 
54365437/// 
5438+ /// Uses [`Router::find_partial_paths`] to construct a [`BlindedPath`] for the offer. If one is 
5439+ /// found, also uses a derived signing pubkey for recipient privacy. Otherwise, uses the node id 
5440+ /// as the signing pubkey. 
5441+ /// 
54375442/// [`Offer`]: crate::offers::offer::Offer 
54385443/// [`OnionMessenger`]: crate::onion_message::OnionMessenger 
54395444/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest 
@@ -5442,13 +5447,25 @@ where
54425447		let  expanded_key = & self . inbound_payment_key ; 
54435448		let  nonce = inbound_payment:: Nonce :: from_entropy_source ( & * self . entropy_source ) ; 
54445449
5445- 		// TODO: Set blinded paths 
5446- 		OfferBuilder :: deriving_signing_pubkey ( description,  node_id,  expanded_key,  nonce) 
5450+ 		match  self . create_blinded_paths ( 1 )  { 
5451+ 			Ok ( paths)  if  !paths. is_empty ( )  => { 
5452+ 				OfferBuilder :: deriving_signing_pubkey ( description,  node_id,  expanded_key,  nonce) 
5453+ 					. path ( paths. into_iter ( ) . next ( ) . unwrap ( ) ) 
5454+ 			} , 
5455+ 			// TODO: check if node is public? 
5456+ 			Ok ( _)  | Err ( _)  => { 
5457+ 				OfferBuilder :: deriving_signing_pubkey ( description,  node_id,  expanded_key,  nonce) 
5458+ 			} , 
5459+ 		} 
54475460	} 
54485461
54495462	/// Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the 
54505463/// [`OnionMessenger`] when handling [`Invoice`] messages for the refund. 
54515464/// 
5465+ /// Uses [`Router::find_partial_paths`] to construct a [`BlindedPath`] for the refund. If one is 
5466+ /// found, also uses a derived payer id for sender privacy. Otherwise, uses the node id as the 
5467+ /// payer id. 
5468+ /// 
54525469/// [`Refund`]: crate::offers::refund::Refund 
54535470/// [`OnionMessenger`]: crate::onion_message::OnionMessenger 
54545471/// [`Invoice`]: crate::offers::invoice::Invoice 
@@ -5459,8 +5476,21 @@ where
54595476		let  expanded_key = & self . inbound_payment_key ; 
54605477		let  nonce = inbound_payment:: Nonce :: from_entropy_source ( & * self . entropy_source ) ; 
54615478
5462- 		// TODO: Set blinded paths 
5463- 		RefundBuilder :: deriving_payer_id ( description,  node_id,  expanded_key,  nonce,  amount_msats) 
5479+ 		let  builder = match  self . create_blinded_paths ( 1 )  { 
5480+ 			Ok ( paths)  if  !paths. is_empty ( )  => { 
5481+ 				RefundBuilder :: deriving_payer_id ( 
5482+ 					description,  node_id,  expanded_key,  nonce,  amount_msats
5483+ 				) ?. path ( paths. into_iter ( ) . next ( ) . unwrap ( ) ) 
5484+ 			} , 
5485+ 			// TODO: check if node is public? 
5486+ 			Ok ( _)  | Err ( _)  => { 
5487+ 				RefundBuilder :: deriving_payer_id ( 
5488+ 					description,  node_id,  expanded_key,  nonce,  amount_msats
5489+ 				) ?
5490+ 			} , 
5491+ 		} ; 
5492+ 
5493+ 		Ok ( builder) 
54645494	} 
54655495
54665496	/// Creates an [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is 
@@ -5608,6 +5638,23 @@ where
56085638		inbound_payment:: get_payment_preimage ( payment_hash,  payment_secret,  & self . inbound_payment_key ) 
56095639	} 
56105640
5641+ 	/// 
5642+ fn  create_blinded_paths ( & self ,  count :  usize )  -> Result < Vec < BlindedPath > ,  ( ) >  { 
5643+ 		let  last_hops = self . per_peer_state . read ( ) . unwrap ( ) . iter ( ) 
5644+ 			. filter ( |( _,  peer) | peer. lock ( ) . unwrap ( ) . latest_features . supports_route_blinding ( ) ) 
5645+ 			. map ( |( node_id,  _) | * node_id) 
5646+ 			. collect :: < Vec < _ > > ( ) ; 
5647+ 		let  entropy_source = self . entropy_source . deref ( ) ; 
5648+ 		let  secp_ctx = & self . secp_ctx ; 
5649+ 
5650+ 		self . router 
5651+ 			. find_partial_paths ( self . get_our_node_id ( ) ,  last_hops. as_slice ( ) ) ?
5652+ 			. into_iter ( ) 
5653+ 			. map ( |node_pks| BlindedPath :: without_id ( & node_pks[ ..] ,  entropy_source,  secp_ctx) ) 
5654+ 			. take ( count) 
5655+ 			. collect ( ) 
5656+ 	} 
5657+ 
56115658	/// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids 
56125659/// are used when constructing the phantom invoice's route hints. 
56135660/// 
0 commit comments