@@ -1725,12 +1725,16 @@ where
17251725/// # use lightning::events::{Event, EventsProvider, PaymentPurpose};
17261726/// # use lightning::ln::channelmanager::AChannelManager;
17271727/// # use lightning::offers::parse::Bolt12SemanticError;
1728+ /// # use lightning::onion_message::messenger::BlindedPathParams;
17281729/// #
17291730/// # fn example<T: AChannelManager>(channel_manager: T) -> Result<(), Bolt12SemanticError> {
17301731/// # let channel_manager = channel_manager.get_cm();
1731- /// # let absolute_expiry = None;
1732+ /// # let params = BlindedPathParams {
1733+ /// # paths: 0,
1734+ /// # is_compact: false,
1735+ /// # };
17321736/// let offer = channel_manager
1733- /// .create_offer_builder(absolute_expiry )?
1737+ /// .create_offer_builder(Some(params) )?
17341738/// # ;
17351739/// # // Needed for compiling for c_bindings
17361740/// # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into();
@@ -1828,16 +1832,21 @@ where
18281832/// # use lightning::events::{Event, EventsProvider};
18291833/// # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry};
18301834/// # use lightning::offers::parse::Bolt12SemanticError;
1835+ /// # use lightning::onion_message::messenger::BlindedPathParams;
18311836/// #
18321837/// # fn example<T: AChannelManager>(
18331838/// # channel_manager: T, amount_msats: u64, absolute_expiry: Duration, retry: Retry,
18341839/// # max_total_routing_fee_msat: Option<u64>
18351840/// # ) -> Result<(), Bolt12SemanticError> {
18361841/// # let channel_manager = channel_manager.get_cm();
1837- /// let payment_id = PaymentId([42; 32]);
1842+ /// # let params = BlindedPathParams {
1843+ /// # paths: 0,
1844+ /// # is_compact: false,
1845+ /// # };
1846+ /// # let payment_id = PaymentId([42; 32]);
18381847/// let refund = channel_manager
18391848/// .create_refund_builder(
1840- /// amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat
1849+ /// Some(params), amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat
18411850/// )?
18421851/// # ;
18431852/// # // Needed for compiling for c_bindings
@@ -8831,7 +8840,7 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
88318840 /// [`Offer`]: crate::offers::offer::Offer
88328841 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
88338842 pub fn create_offer_builder(
8834- &$self, absolute_expiry : Option<Duration>
8843+ &$self, params : Option<BlindedPathParams>,
88358844 ) -> Result<$builder, Bolt12SemanticError> {
88368845 let node_id = $self.get_our_node_id();
88378846 let expanded_key = &$self.inbound_payment_key;
@@ -8840,17 +8849,15 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
88408849
88418850 let nonce = Nonce::from_entropy_source(entropy);
88428851 let context = OffersContext::InvoiceRequest { nonce };
8843- let path = $self.create_blinded_paths_using_absolute_expiry(context, absolute_expiry)
8852+ let mut builder = OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
8853+ .chain_hash($self.chain_hash);
8854+ if let Some(params) = params {
8855+ let path = $self.create_blinded_paths(params, context)
88448856 .and_then(|paths| paths.into_iter().next().ok_or(()))
88458857 .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8846- let builder = OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
8847- .chain_hash($self.chain_hash)
8848- .path(path);
8849-
8850- let builder = match absolute_expiry {
8851- None => builder,
8852- Some(absolute_expiry) => builder.absolute_expiry(absolute_expiry),
8853- };
8858+
8859+ builder = builder.path(path);
8860+ }
88548861
88558862 Ok(builder.into())
88568863 }
@@ -8903,7 +8910,8 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
89038910 /// [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
89048911 /// [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
89058912 pub fn create_refund_builder(
8906- &$self, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId,
8913+ &$self, params: Option<BlindedPathParams>, amount_msats: u64,
8914+ absolute_expiry: Duration, payment_id: PaymentId,
89078915 retry_strategy: Retry, max_total_routing_fee_msat: Option<u64>
89088916 ) -> Result<$builder, Bolt12SemanticError> {
89098917 let node_id = $self.get_our_node_id();
@@ -8914,15 +8922,19 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
89148922 let nonce = Nonce::from_entropy_source(entropy);
89158923 let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: None };
89168924
8917- let path = $self.create_blinded_paths_using_absolute_expiry(context, Some(absolute_expiry))
8918- .and_then(|paths| paths.into_iter().next().ok_or(()))
8919- .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8920- let builder = RefundBuilder::deriving_payer_id(
8925+ let mut builder = RefundBuilder::deriving_payer_id(
89218926 node_id, expanded_key, nonce, secp_ctx, amount_msats, payment_id
89228927 )?
89238928 .chain_hash($self.chain_hash)
8924- .absolute_expiry(absolute_expiry)
8925- .path(path);
8929+ .absolute_expiry(absolute_expiry);
8930+
8931+ if let Some(params) = params {
8932+ let path = $self.create_blinded_paths(params, context)
8933+ .and_then(|paths| paths.into_iter().next().ok_or(()))
8934+ .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8935+
8936+ builder = builder.path(path);
8937+ };
89268938
89278939 let _persistence_guard = PersistenceNotifierGuard::notify_on_drop($self);
89288940
@@ -9296,29 +9308,7 @@ where
92969308 inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
92979309 }
92989310
9299- /// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on
9300- /// the path's intended lifetime.
9301- ///
9302- /// Whether or not the path is compact depends on whether the path is short-lived or long-lived,
9303- /// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
9304- /// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
9305- fn create_blinded_paths_using_absolute_expiry(
9306- &self, context: OffersContext, absolute_expiry: Option<Duration>,
9307- ) -> Result<Vec<BlindedMessagePath>, ()> {
9308- let now = self.duration_since_epoch();
9309- let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
9310-
9311- if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
9312- self.create_compact_blinded_paths(context)
9313- } else {
9314- let params = BlindedPathParams {
9315- paths: PATHS_PLACEHOLDER,
9316- is_compact: false
9317- };
9318- self.create_blinded_paths(params, context)
9319- }
9320- }
9321-
9311+ #[cfg(test)]
93229312 pub(super) fn duration_since_epoch(&self) -> Duration {
93239313 #[cfg(not(feature = "std"))]
93249314 let now = Duration::from_secs(
@@ -9357,6 +9347,7 @@ where
93579347 /// [`MessageRouter::create_compact_blinded_paths`].
93589348 ///
93599349 /// Errors if the `MessageRouter` errors.
9350+ #[allow(unused)]
93609351 fn create_compact_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
93619352 let recipient = self.get_our_node_id();
93629353 let secp_ctx = &self.secp_ctx;
0 commit comments