@@ -30,6 +30,7 @@ use bitcoin::secp256k1::{SecretKey,PublicKey};
3030use  bitcoin:: secp256k1:: Secp256k1 ; 
3131use  bitcoin:: { LockTime ,  secp256k1,  Sequence } ; 
3232
33+ use  crate :: blinded_path:: BlindedPath ; 
3334use  crate :: chain; 
3435use  crate :: chain:: { Confirm ,  ChannelMonitorUpdateStatus ,  Watch ,  BestBlock } ; 
3536use  crate :: chain:: chaininterface:: { BroadcasterInterface ,  ConfirmationTarget ,  FeeEstimator ,  LowerBoundedFeeEstimator } ; 
@@ -5741,6 +5742,10 @@ where
57415742	/// Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the 
57425743/// [`OnionMessenger`] when handling [`InvoiceRequest`] messages for the offer. 
57435744/// 
5745+ /// Uses [`Router::find_partial_paths`] to construct a [`BlindedPath`] for the offer. If one is 
5746+ /// found, also uses a derived signing pubkey for recipient privacy. Otherwise, uses the node id 
5747+ /// as the signing pubkey. 
5748+ /// 
57445749/// [`Offer`]: crate::offers::offer::Offer 
57455750/// [`OnionMessenger`]: crate::onion_message::OnionMessenger 
57465751/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest 
@@ -5751,14 +5756,24 @@ where
57515756		let  expanded_key = & self . inbound_payment_key ; 
57525757		let  entropy = & * self . entropy_source ; 
57535758		let  secp_ctx = & self . secp_ctx ; 
5759+ 		let  builder = OfferBuilder :: deriving_signing_pubkey ( 
5760+ 			description,  node_id,  expanded_key,  entropy,  secp_ctx
5761+ 		) ; 
57545762
5755- 		// TODO: Set blinded paths 
5756- 		OfferBuilder :: deriving_signing_pubkey ( description,  node_id,  expanded_key,  entropy,  secp_ctx) 
5763+ 		match  self . create_blinded_paths ( 1 )  { 
5764+ 			Ok ( paths)  if  !paths. is_empty ( )  => builder. path ( paths. into_iter ( ) . next ( ) . unwrap ( ) ) , 
5765+ 			// TODO: check if node is public? 
5766+ 			Ok ( _)  | Err ( _)  => builder, 
5767+ 		} 
57575768	} 
57585769
57595770	/// Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the 
57605771/// [`OnionMessenger`] when handling [`Invoice`] messages for the refund. 
57615772/// 
5773+ /// Uses [`Router::find_partial_paths`] to construct a [`BlindedPath`] for the refund. If one is 
5774+ /// found, also uses a derived payer id for sender privacy. Otherwise, uses the node id as the 
5775+ /// payer id. 
5776+ /// 
57625777/// [`Refund`]: crate::offers::refund::Refund 
57635778/// [`OnionMessenger`]: crate::onion_message::OnionMessenger 
57645779/// [`Invoice`]: crate::offers::invoice::Invoice 
@@ -5769,11 +5784,15 @@ where
57695784		let  expanded_key = & self . inbound_payment_key ; 
57705785		let  entropy = & * self . entropy_source ; 
57715786		let  secp_ctx = & self . secp_ctx ; 
5772- 
5773- 		// TODO: Set blinded paths 
5774- 		RefundBuilder :: deriving_payer_id ( 
5787+ 		let  builder = RefundBuilder :: deriving_payer_id ( 
57755788			description,  node_id,  expanded_key,  entropy,  secp_ctx,  amount_msats
5776- 		) 
5789+ 		) ?; 
5790+ 
5791+ 		match  self . create_blinded_paths ( 1 )  { 
5792+ 			Ok ( paths)  if  !paths. is_empty ( )  => Ok ( builder. path ( paths. into_iter ( ) . next ( ) . unwrap ( ) ) ) , 
5793+ 			// TODO: check if node is public? 
5794+ 			Ok ( _)  | Err ( _)  => Ok ( builder) , 
5795+ 		} 
57775796	} 
57785797
57795798	/// Creates an [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is 
@@ -5923,6 +5942,23 @@ where
59235942		inbound_payment:: get_payment_preimage ( payment_hash,  payment_secret,  & self . inbound_payment_key ) 
59245943	} 
59255944
5945+ 	/// 
5946+ fn  create_blinded_paths ( & self ,  count :  usize )  -> Result < Vec < BlindedPath > ,  ( ) >  { 
5947+ 		let  last_hops = self . per_peer_state . read ( ) . unwrap ( ) . iter ( ) 
5948+ 			. filter ( |( _,  peer) | peer. lock ( ) . unwrap ( ) . latest_features . supports_route_blinding ( ) ) 
5949+ 			. map ( |( node_id,  _) | * node_id) 
5950+ 			. collect :: < Vec < _ > > ( ) ; 
5951+ 		let  entropy_source = self . entropy_source . deref ( ) ; 
5952+ 		let  secp_ctx = & self . secp_ctx ; 
5953+ 
5954+ 		self . router 
5955+ 			. find_partial_paths ( self . get_our_node_id ( ) ,  last_hops. as_slice ( ) ) ?
5956+ 			. into_iter ( ) 
5957+ 			. map ( |node_pks| BlindedPath :: new_for_message ( & node_pks[ ..] ,  entropy_source,  secp_ctx) ) 
5958+ 			. take ( count) 
5959+ 			. collect ( ) 
5960+ 	} 
5961+ 
59265962	/// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids 
59275963/// are used when constructing the phantom invoice's route hints. 
59285964/// 
0 commit comments