@@ -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};
@@ -6708,6 +6709,9 @@ where
67086709 /// Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the
67096710 /// [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer.
67106711 ///
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.
6714+ ///
67116715 /// [`Offer`]: crate::offers::offer::Offer
67126716 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
67136717 pub fn create_offer_builder(
@@ -6717,16 +6721,25 @@ where
67176721 let expanded_key = &self.inbound_payment_key;
67186722 let entropy = &*self.entropy_source;
67196723 let secp_ctx = &self.secp_ctx;
6724+ let builder = OfferBuilder::deriving_signing_pubkey(
6725+ description, node_id, expanded_key, entropy, secp_ctx
6726+ );
67206727
6721- // TODO: Set blinded paths
6722- OfferBuilder::deriving_signing_pubkey(description, node_id, expanded_key, entropy, secp_ctx)
6728+ match self.create_one_hop_blinded_path() {
6729+ Ok(path) => builder.path(path),
6730+ // TODO: check if node is public?
6731+ Err(_) => builder,
6732+ }
67236733 }
67246734
67256735 /// Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the
67266736 /// [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund.
67276737 ///
67286738 /// The provided `payment_id` is used to ensure that only one invoice is paid for the refund.
67296739 ///
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.
6742+ ///
67306743 /// [`Refund`]: crate::offers::refund::Refund
67316744 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
67326745 pub fn create_refund_builder(
@@ -6737,10 +6750,14 @@ where
67376750 let entropy = &*self.entropy_source;
67386751 let secp_ctx = &self.secp_ctx;
67396752
6740- // TODO: Set blinded paths
67416753 let builder = RefundBuilder::deriving_payer_id(
67426754 description, node_id, expanded_key, entropy, secp_ctx, amount_msats, payment_id
67436755 )?;
6756+ let builder = match self.create_one_hop_blinded_path() {
6757+ Ok(path) => builder.path(path),
6758+ // TODO: check if node is public?
6759+ Err(_) => builder,
6760+ };
67446761 self.pending_outbound_payments
67456762 .add_new_awaiting_invoice(payment_id, retry_strategy)
67466763 .map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
@@ -6873,6 +6890,15 @@ where
68736890 inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
68746891 }
68756892
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, ()> {
6896+ let entropy_source = self.entropy_source.deref();
6897+ let secp_ctx = &self.secp_ctx;
6898+ BlindedPath::new_for_message(&[self.get_our_node_id()], entropy_source, secp_ctx)
6899+
6900+ }
6901+
68766902 /// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
68776903 /// are used when constructing the phantom invoice's route hints.
68786904 ///
0 commit comments