@@ -6709,8 +6709,9 @@ where
6709
6709
/// Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the
6710
6710
/// [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer.
6711
6711
///
6712
- /// Uses a one-hop [`BlindedPath`] for the offer with [`ChannelManager::get_our_node_id`] as the
6713
- /// introduction node and a derived signing pubkey for recipient privacy.
6712
+ /// Uses [`Router::find_partial_paths`] to construct a [`BlindedPath`] for the offer. If one is
6713
+ /// found, also uses a derived signing pubkey for recipient privacy. Otherwise, uses the node id
6714
+ /// as the signing pubkey.
6714
6715
///
6715
6716
/// [`Offer`]: crate::offers::offer::Offer
6716
6717
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
@@ -6725,10 +6726,10 @@ where
6725
6726
description, node_id, expanded_key, entropy, secp_ctx
6726
6727
);
6727
6728
6728
- match self.create_one_hop_blinded_path( ) {
6729
- Ok(path) => builder.path(path ),
6729
+ match self.create_blinded_paths(1 ) {
6730
+ Ok(paths) if !paths.is_empty() => builder.path(paths.into_iter().next().unwrap() ),
6730
6731
// TODO: check if node is public?
6731
- Err(_) => builder,
6732
+ Ok(_) | Err(_) => builder,
6732
6733
}
6733
6734
}
6734
6735
@@ -6737,8 +6738,9 @@ where
6737
6738
///
6738
6739
/// The provided `payment_id` is used to ensure that only one invoice is paid for the refund.
6739
6740
///
6740
- /// Uses a one-hop [`BlindedPath`] for the refund with [`ChannelManager::get_our_node_id`] as
6741
- /// the introduction node and a derived payer id for sender privacy.
6741
+ /// Uses [`Router::find_partial_paths`] to construct a [`BlindedPath`] for the refund. If one is
6742
+ /// found, also uses a derived payer id for sender privacy. Otherwise, uses the node id as the
6743
+ /// payer id.
6742
6744
///
6743
6745
/// [`Refund`]: crate::offers::refund::Refund
6744
6746
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
@@ -6753,10 +6755,10 @@ where
6753
6755
let builder = RefundBuilder::deriving_payer_id(
6754
6756
description, node_id, expanded_key, entropy, secp_ctx, amount_msats, payment_id
6755
6757
)?;
6756
- let builder = match self.create_one_hop_blinded_path( ) {
6757
- Ok(path) => builder.path(path ),
6758
+ let builder = match self.create_blinded_paths(1 ) {
6759
+ Ok(paths) if !paths.is_empty() => builder.path(paths.into_iter().next().unwrap() ),
6758
6760
// TODO: check if node is public?
6759
- Err(_) => builder,
6761
+ Ok(_) | Err(_) => builder,
6760
6762
};
6761
6763
self.pending_outbound_payments
6762
6764
.add_new_awaiting_invoice(payment_id, retry_strategy)
@@ -6890,13 +6892,25 @@ where
6890
6892
inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
6891
6893
}
6892
6894
6893
- /// Creates a one-hop blinded path with [`ChannelManager::get_our_node_id`] as the introduction
6894
- /// node.
6895
- fn create_one_hop_blinded_path(&self) -> Result<BlindedPath, ()> {
6895
+ /// Creates `count` blinded paths using our immediate peers as the introduction nodes.
6896
+ ///
6897
+ /// May return fewer paths if there are fewer than `count` peers that [support route blinding].
6898
+ ///
6899
+ /// [support route blinding]: crate::ln::features::InitFeatures::supports_route_blinding
6900
+ fn create_blinded_paths(&self, count: usize) -> Result<Vec<BlindedPath>, ()> {
6901
+ let last_hops = self.per_peer_state.read().unwrap().iter()
6902
+ .filter(|(_, peer)| peer.lock().unwrap().latest_features.supports_route_blinding())
6903
+ .map(|(node_id, _)| *node_id)
6904
+ .collect::<Vec<_>>();
6896
6905
let entropy_source = self.entropy_source.deref();
6897
6906
let secp_ctx = &self.secp_ctx;
6898
- BlindedPath::new_for_message(&[self.get_our_node_id()], entropy_source, secp_ctx)
6899
6907
6908
+ self.router
6909
+ .find_partial_paths(self.get_our_node_id(), last_hops.as_slice())?
6910
+ .into_iter()
6911
+ .map(|node_pks| BlindedPath::new_for_message(&node_pks[..], entropy_source, secp_ctx))
6912
+ .take(count)
6913
+ .collect()
6900
6914
}
6901
6915
6902
6916
/// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
0 commit comments