@@ -30,6 +30,7 @@ use bitcoin::secp256k1::{SecretKey,PublicKey};
30
30
use bitcoin:: secp256k1:: Secp256k1 ;
31
31
use bitcoin:: { LockTime , secp256k1, Sequence } ;
32
32
33
+ use crate :: blinded_path:: BlindedPath ;
33
34
use crate :: chain;
34
35
use crate :: chain:: { Confirm , ChannelMonitorUpdateStatus , Watch , BestBlock } ;
35
36
use crate :: chain:: chaininterface:: { BroadcasterInterface , ConfirmationTarget , FeeEstimator , LowerBoundedFeeEstimator } ;
@@ -6086,6 +6087,10 @@ where
6086
6087
/// Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the
6087
6088
/// [`OnionMessenger`] when handling [`InvoiceRequest`] messages for the offer.
6088
6089
///
6090
+ /// Uses [`Router::find_partial_paths`] to construct a [`BlindedPath`] for the offer. If one is
6091
+ /// found, also uses a derived signing pubkey for recipient privacy. Otherwise, uses the node id
6092
+ /// as the signing pubkey.
6093
+ ///
6089
6094
/// [`Offer`]: crate::offers::offer::Offer
6090
6095
/// [`OnionMessenger`]: crate::onion_message::OnionMessenger
6091
6096
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
@@ -6096,14 +6101,24 @@ where
6096
6101
let expanded_key = & self . inbound_payment_key ;
6097
6102
let entropy = & * self . entropy_source ;
6098
6103
let secp_ctx = & self . secp_ctx ;
6104
+ let builder = OfferBuilder :: deriving_signing_pubkey (
6105
+ description, node_id, expanded_key, entropy, secp_ctx
6106
+ ) ;
6099
6107
6100
- // TODO: Set blinded paths
6101
- OfferBuilder :: deriving_signing_pubkey ( description, node_id, expanded_key, entropy, secp_ctx)
6108
+ match self . create_blinded_paths ( 1 ) {
6109
+ Ok ( paths) if !paths. is_empty ( ) => builder. path ( paths. into_iter ( ) . next ( ) . unwrap ( ) ) ,
6110
+ // TODO: check if node is public?
6111
+ Ok ( _) | Err ( _) => builder,
6112
+ }
6102
6113
}
6103
6114
6104
6115
/// Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the
6105
6116
/// [`OnionMessenger`] when handling [`Invoice`] messages for the refund.
6106
6117
///
6118
+ /// Uses [`Router::find_partial_paths`] to construct a [`BlindedPath`] for the refund. If one is
6119
+ /// found, also uses a derived payer id for sender privacy. Otherwise, uses the node id as the
6120
+ /// payer id.
6121
+ ///
6107
6122
/// [`Refund`]: crate::offers::refund::Refund
6108
6123
/// [`OnionMessenger`]: crate::onion_message::OnionMessenger
6109
6124
/// [`Invoice`]: crate::offers::invoice::Invoice
@@ -6114,11 +6129,15 @@ where
6114
6129
let expanded_key = & self . inbound_payment_key ;
6115
6130
let entropy = & * self . entropy_source ;
6116
6131
let secp_ctx = & self . secp_ctx ;
6117
-
6118
- // TODO: Set blinded paths
6119
- RefundBuilder :: deriving_payer_id (
6132
+ let builder = RefundBuilder :: deriving_payer_id (
6120
6133
description, node_id, expanded_key, entropy, secp_ctx, amount_msats
6121
- )
6134
+ ) ?;
6135
+
6136
+ match self . create_blinded_paths ( 1 ) {
6137
+ Ok ( paths) if !paths. is_empty ( ) => Ok ( builder. path ( paths. into_iter ( ) . next ( ) . unwrap ( ) ) ) ,
6138
+ // TODO: check if node is public?
6139
+ Ok ( _) | Err ( _) => Ok ( builder) ,
6140
+ }
6122
6141
}
6123
6142
6124
6143
/// Creates an [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is
@@ -6237,6 +6256,23 @@ where
6237
6256
inbound_payment:: get_payment_preimage ( payment_hash, payment_secret, & self . inbound_payment_key )
6238
6257
}
6239
6258
6259
+ ///
6260
+ fn create_blinded_paths ( & self , count : usize ) -> Result < Vec < BlindedPath > , ( ) > {
6261
+ let last_hops = self . per_peer_state . read ( ) . unwrap ( ) . iter ( )
6262
+ . filter ( |( _, peer) | peer. lock ( ) . unwrap ( ) . latest_features . supports_route_blinding ( ) )
6263
+ . map ( |( node_id, _) | * node_id)
6264
+ . collect :: < Vec < _ > > ( ) ;
6265
+ let entropy_source = self . entropy_source . deref ( ) ;
6266
+ let secp_ctx = & self . secp_ctx ;
6267
+
6268
+ self . router
6269
+ . find_partial_paths ( self . get_our_node_id ( ) , last_hops. as_slice ( ) ) ?
6270
+ . into_iter ( )
6271
+ . map ( |node_pks| BlindedPath :: new_for_message ( & node_pks[ ..] , entropy_source, secp_ctx) )
6272
+ . take ( count)
6273
+ . collect ( )
6274
+ }
6275
+
6240
6276
/// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
6241
6277
/// are used when constructing the phantom invoice's route hints.
6242
6278
///
0 commit comments