@@ -1728,12 +1728,16 @@ where
1728
1728
/// # use lightning::events::{Event, EventsProvider, PaymentPurpose};
1729
1729
/// # use lightning::ln::channelmanager::AChannelManager;
1730
1730
/// # use lightning::offers::parse::Bolt12SemanticError;
1731
+ /// # use lightning::onion_message::messenger::BlindedPathParams;
1731
1732
/// #
1732
1733
/// # fn example<T: AChannelManager>(channel_manager: T) -> Result<(), Bolt12SemanticError> {
1733
1734
/// # let channel_manager = channel_manager.get_cm();
1734
- /// # let absolute_expiry = None;
1735
+ /// # let params = BlindedPathParams {
1736
+ /// # paths: 0,
1737
+ /// # is_compact: false,
1738
+ /// # };
1735
1739
/// let offer = channel_manager
1736
- /// .create_offer_builder(absolute_expiry )?
1740
+ /// .create_offer_builder(Some(params) )?
1737
1741
/// # ;
1738
1742
/// # // Needed for compiling for c_bindings
1739
1743
/// # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into();
@@ -1831,16 +1835,21 @@ where
1831
1835
/// # use lightning::events::{Event, EventsProvider};
1832
1836
/// # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry};
1833
1837
/// # use lightning::offers::parse::Bolt12SemanticError;
1838
+ /// # use lightning::onion_message::messenger::BlindedPathParams;
1834
1839
/// #
1835
1840
/// # fn example<T: AChannelManager>(
1836
1841
/// # channel_manager: T, amount_msats: u64, absolute_expiry: Duration, retry: Retry,
1837
1842
/// # max_total_routing_fee_msat: Option<u64>
1838
1843
/// # ) -> Result<(), Bolt12SemanticError> {
1839
1844
/// # let channel_manager = channel_manager.get_cm();
1840
- /// let payment_id = PaymentId([42; 32]);
1845
+ /// # let params = BlindedPathParams {
1846
+ /// # paths: 0,
1847
+ /// # is_compact: false,
1848
+ /// # };
1849
+ /// # let payment_id = PaymentId([42; 32]);
1841
1850
/// let refund = channel_manager
1842
1851
/// .create_refund_builder(
1843
- /// amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat
1852
+ /// Some(params), amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat
1844
1853
/// )?
1845
1854
/// # ;
1846
1855
/// # // Needed for compiling for c_bindings
@@ -8870,7 +8879,7 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
8870
8879
/// [`Offer`]: crate::offers::offer::Offer
8871
8880
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
8872
8881
pub fn create_offer_builder(
8873
- &$self, absolute_expiry : Option<Duration>
8882
+ &$self, params : Option<BlindedPathParams>,
8874
8883
) -> Result<$builder, Bolt12SemanticError> {
8875
8884
let node_id = $self.get_our_node_id();
8876
8885
let expanded_key = &$self.inbound_payment_key;
@@ -8879,17 +8888,16 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
8879
8888
8880
8889
let nonce = Nonce::from_entropy_source(entropy);
8881
8890
let context = OffersContext::InvoiceRequest { nonce };
8882
- let path = $self.create_blinded_paths_using_absolute_expiry(context, absolute_expiry)
8883
- .and_then(|paths| paths.into_iter().next().ok_or(()))
8884
- .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8885
- let builder = OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
8886
- .chain_hash($self.chain_hash)
8887
- .path(path);
8888
8891
8889
- let builder = match absolute_expiry {
8890
- None => builder,
8891
- Some(absolute_expiry) => builder.absolute_expiry(absolute_expiry),
8892
- };
8892
+ let mut builder = OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
8893
+ .chain_hash($self.chain_hash);
8894
+ if let Some(params) = params {
8895
+ let path = $self.create_blinded_paths(params, context)
8896
+ .and_then(|paths| paths.into_iter().next().ok_or(()))
8897
+ .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8898
+
8899
+ builder = builder.path(path);
8900
+ }
8893
8901
8894
8902
Ok(builder.into())
8895
8903
}
@@ -8942,7 +8950,8 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
8942
8950
/// [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
8943
8951
/// [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
8944
8952
pub fn create_refund_builder(
8945
- &$self, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId,
8953
+ &$self, params: Option<BlindedPathParams>, amount_msats: u64,
8954
+ absolute_expiry: Duration, payment_id: PaymentId,
8946
8955
retry_strategy: Retry, max_total_routing_fee_msat: Option<u64>
8947
8956
) -> Result<$builder, Bolt12SemanticError> {
8948
8957
let node_id = $self.get_our_node_id();
@@ -8952,16 +8961,20 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
8952
8961
8953
8962
let nonce = Nonce::from_entropy_source(entropy);
8954
8963
let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: None };
8955
- let path = $self.create_blinded_paths_using_absolute_expiry(context, Some(absolute_expiry))
8956
- .and_then(|paths| paths.into_iter().next().ok_or(()))
8957
- .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8958
8964
8959
- let builder = RefundBuilder::deriving_payer_id(
8965
+ let mut builder = RefundBuilder::deriving_payer_id(
8960
8966
node_id, expanded_key, nonce, secp_ctx, amount_msats, payment_id
8961
8967
)?
8962
8968
.chain_hash($self.chain_hash)
8963
- .absolute_expiry(absolute_expiry)
8964
- .path(path);
8969
+ .absolute_expiry(absolute_expiry);
8970
+
8971
+ if let Some(params) = params {
8972
+ let path = $self.create_blinded_paths(params, context)
8973
+ .and_then(|paths| paths.into_iter().next().ok_or(()))
8974
+ .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8975
+
8976
+ builder = builder.path(path);
8977
+ };
8965
8978
8966
8979
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop($self);
8967
8980
@@ -9336,29 +9349,7 @@ where
9336
9349
inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
9337
9350
}
9338
9351
9339
- /// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on
9340
- /// the path's intended lifetime.
9341
- ///
9342
- /// Whether or not the path is compact depends on whether the path is short-lived or long-lived,
9343
- /// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
9344
- /// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
9345
- fn create_blinded_paths_using_absolute_expiry(
9346
- &self, context: OffersContext, absolute_expiry: Option<Duration>,
9347
- ) -> Result<Vec<BlindedMessagePath>, ()> {
9348
- let now = self.duration_since_epoch();
9349
- let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
9350
-
9351
- if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
9352
- self.create_compact_blinded_paths(context)
9353
- } else {
9354
- let params = BlindedPathParams {
9355
- paths: PATHS_PLACEHOLDER,
9356
- is_compact: false
9357
- };
9358
- self.create_blinded_paths(params, context)
9359
- }
9360
- }
9361
-
9352
+ #[cfg(test)]
9362
9353
pub(super) fn duration_since_epoch(&self) -> Duration {
9363
9354
#[cfg(not(feature = "std"))]
9364
9355
let now = Duration::from_secs(
@@ -9397,6 +9388,7 @@ where
9397
9388
/// [`MessageRouter::create_compact_blinded_paths`].
9398
9389
///
9399
9390
/// Errors if the `MessageRouter` errors.
9391
+ #[allow(unused)]
9400
9392
fn create_compact_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
9401
9393
let recipient = self.get_our_node_id();
9402
9394
let secp_ctx = &self.secp_ctx;
0 commit comments