@@ -1704,12 +1704,16 @@ where
1704
1704
/// # use lightning::events::{Event, EventsProvider, PaymentPurpose};
1705
1705
/// # use lightning::ln::channelmanager::AChannelManager;
1706
1706
/// # use lightning::offers::parse::Bolt12SemanticError;
1707
+ /// # use lightning::onion_message::messenger::BlindedPathParams;
1707
1708
/// #
1708
1709
/// # fn example<T: AChannelManager>(channel_manager: T) -> Result<(), Bolt12SemanticError> {
1709
1710
/// # let channel_manager = channel_manager.get_cm();
1710
- /// # let absolute_expiry = None;
1711
+ /// # let params = BlindedPathParams {
1712
+ /// # paths: 0,
1713
+ /// # is_compact: false,
1714
+ /// # };
1711
1715
/// let offer = channel_manager
1712
- /// .create_offer_builder(absolute_expiry )?
1716
+ /// .create_offer_builder(Some(params) )?
1713
1717
/// # ;
1714
1718
/// # // Needed for compiling for c_bindings
1715
1719
/// # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into();
@@ -1807,16 +1811,21 @@ where
1807
1811
/// # use lightning::events::{Event, EventsProvider};
1808
1812
/// # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry};
1809
1813
/// # use lightning::offers::parse::Bolt12SemanticError;
1814
+ /// # use lightning::onion_message::messenger::BlindedPathParams;
1810
1815
/// #
1811
1816
/// # fn example<T: AChannelManager>(
1812
1817
/// # channel_manager: T, amount_msats: u64, absolute_expiry: Duration, retry: Retry,
1813
1818
/// # max_total_routing_fee_msat: Option<u64>
1814
1819
/// # ) -> Result<(), Bolt12SemanticError> {
1815
1820
/// # let channel_manager = channel_manager.get_cm();
1816
- /// let payment_id = PaymentId([42; 32]);
1821
+ /// # let params = BlindedPathParams {
1822
+ /// # paths: 0,
1823
+ /// # is_compact: false,
1824
+ /// # };
1825
+ /// # let payment_id = PaymentId([42; 32]);
1817
1826
/// let refund = channel_manager
1818
1827
/// .create_refund_builder(
1819
- /// amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat
1828
+ /// Some(params), amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat
1820
1829
/// )?
1821
1830
/// # ;
1822
1831
/// # // Needed for compiling for c_bindings
@@ -8808,7 +8817,7 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
8808
8817
/// [`Offer`]: crate::offers::offer::Offer
8809
8818
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
8810
8819
pub fn create_offer_builder(
8811
- &$self, absolute_expiry : Option<Duration>
8820
+ &$self, params : Option<BlindedPathParams>,
8812
8821
) -> Result<$builder, Bolt12SemanticError> {
8813
8822
let node_id = $self.get_our_node_id();
8814
8823
let expanded_key = &$self.inbound_payment_key;
@@ -8817,17 +8826,15 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
8817
8826
8818
8827
let nonce = Nonce::from_entropy_source(entropy);
8819
8828
let context = OffersContext::InvoiceRequest { nonce };
8820
- let path = $self.create_blinded_paths_using_absolute_expiry(context, absolute_expiry)
8829
+ let mut builder = OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
8830
+ .chain_hash($self.chain_hash);
8831
+ if let Some(params) = params {
8832
+ let path = $self.create_blinded_paths(params, context)
8821
8833
.and_then(|paths| paths.into_iter().next().ok_or(()))
8822
8834
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
8823
- let builder = OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
8824
- .chain_hash($self.chain_hash)
8825
- .path(path);
8826
-
8827
- let builder = match absolute_expiry {
8828
- None => builder,
8829
- Some(absolute_expiry) => builder.absolute_expiry(absolute_expiry),
8830
- };
8835
+
8836
+ builder = builder.path(path);
8837
+ }
8831
8838
8832
8839
Ok(builder.into())
8833
8840
}
@@ -8880,7 +8887,8 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
8880
8887
/// [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
8881
8888
/// [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
8882
8889
pub fn create_refund_builder(
8883
- &$self, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId,
8890
+ &$self, params: Option<BlindedPathParams>, amount_msats: u64,
8891
+ absolute_expiry: Duration, payment_id: PaymentId,
8884
8892
retry_strategy: Retry, max_total_routing_fee_msat: Option<u64>
8885
8893
) -> Result<$builder, Bolt12SemanticError> {
8886
8894
let node_id = $self.get_our_node_id();
@@ -8891,15 +8899,19 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
8891
8899
let nonce = Nonce::from_entropy_source(entropy);
8892
8900
let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: None };
8893
8901
8894
- let path = $self.create_blinded_paths_using_absolute_expiry(context, Some(absolute_expiry))
8895
- .and_then(|paths| paths.into_iter().next().ok_or(()))
8896
- .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8897
- let builder = RefundBuilder::deriving_payer_id(
8902
+ let mut builder = RefundBuilder::deriving_payer_id(
8898
8903
node_id, expanded_key, nonce, secp_ctx, amount_msats, payment_id
8899
8904
)?
8900
8905
.chain_hash($self.chain_hash)
8901
- .absolute_expiry(absolute_expiry)
8902
- .path(path);
8906
+ .absolute_expiry(absolute_expiry);
8907
+
8908
+ if let Some(params) = params {
8909
+ let path = $self.create_blinded_paths(params, context)
8910
+ .and_then(|paths| paths.into_iter().next().ok_or(()))
8911
+ .map_err(|_| Bolt12SemanticError::MissingPaths)?;
8912
+
8913
+ builder = builder.path(path);
8914
+ };
8903
8915
8904
8916
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop($self);
8905
8917
@@ -9273,29 +9285,7 @@ where
9273
9285
inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
9274
9286
}
9275
9287
9276
- /// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on
9277
- /// the path's intended lifetime.
9278
- ///
9279
- /// Whether or not the path is compact depends on whether the path is short-lived or long-lived,
9280
- /// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
9281
- /// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
9282
- fn create_blinded_paths_using_absolute_expiry(
9283
- &self, context: OffersContext, absolute_expiry: Option<Duration>,
9284
- ) -> Result<Vec<BlindedMessagePath>, ()> {
9285
- let now = self.duration_since_epoch();
9286
- let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
9287
-
9288
- if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
9289
- self.create_compact_blinded_paths(context)
9290
- } else {
9291
- let params = BlindedPathParams {
9292
- paths: PATHS_PLACEHOLDER,
9293
- is_compact: false
9294
- };
9295
- self.create_blinded_paths(params, context)
9296
- }
9297
- }
9298
-
9288
+ #[cfg(test)]
9299
9289
pub(super) fn duration_since_epoch(&self) -> Duration {
9300
9290
#[cfg(not(feature = "std"))]
9301
9291
let now = Duration::from_secs(
@@ -9334,6 +9324,7 @@ where
9334
9324
/// [`MessageRouter::create_compact_blinded_paths`].
9335
9325
///
9336
9326
/// Errors if the `MessageRouter` errors.
9327
+ #[allow(unused)]
9337
9328
fn create_compact_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
9338
9329
let recipient = self.get_our_node_id();
9339
9330
let secp_ctx = &self.secp_ctx;
0 commit comments