@@ -2868,18 +2868,24 @@ const MAX_PEER_STORAGE_SIZE: usize = 1024;
28682868/// many peers we reject new (inbound) connections.
28692869const MAX_NO_CHANNEL_PEERS: usize = 250;
28702870
2871+ #[cfg(test)]
28712872/// The maximum expiration from the current time where an [`Offer`] or [`Refund`] is considered
28722873/// short-lived, while anything with a greater expiration is considered long-lived.
28732874///
28742875/// Using [`ChannelManager::create_offer_builder`] or [`ChannelManager::create_refund_builder`],
2875- /// will included a [`BlindedMessagePath`] created using:
2876- /// - [`MessageRouter::create_compact_blinded_paths`] when short-lived, and
2877- /// - [`MessageRouter::create_blinded_paths`] when long-lived.
2876+ /// will included a [`BlindedMessagePath`] created using [`MessageRouter::create_blinded_paths`].
2877+ ///
2878+ /// To generate compact [`BlindedMessagePath`]s:
2879+ /// 1. Parameterize [`ChannelManager`] with a [`MessageRouter`] implementation that always creates
2880+ /// compact paths via [`MessageRouter::create_blinded_paths`].
2881+ /// 2. Use [`ChannelManager::create_offer_builder_using_router`] or
2882+ /// [`ChannelManager::create_refund_builder_using_router`] to provide a custom router that
2883+ /// generates compact paths.
28782884///
28792885/// Using compact [`BlindedMessagePath`]s may provide better privacy as the [`MessageRouter`] could select
28802886/// more hops. However, since they use short channel ids instead of pubkeys, they are more likely to
28812887/// become invalid over time as channels are closed. Thus, they are only suitable for short-term use.
2882- pub const MAX_SHORT_LIVED_RELATIVE_EXPIRY: Duration = Duration::from_secs(60 * 60 * 24);
2888+ pub(super) const MAX_SHORT_LIVED_RELATIVE_EXPIRY: Duration = Duration::from_secs(60 * 60 * 24);
28832889
28842890/// Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments.
28852891/// These include payments that have yet to find a successful path, or have unresolved HTLCs.
@@ -10970,25 +10976,7 @@ where
1097010976 inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
1097110977 }
1097210978
10973- /// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on
10974- /// the path's intended lifetime.
10975- ///
10976- /// Whether or not the path is compact depends on whether the path is short-lived or long-lived,
10977- /// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
10978- /// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
10979- fn create_blinded_paths_using_absolute_expiry(
10980- &self, context: OffersContext, absolute_expiry: Option<Duration>,
10981- ) -> Result<Vec<BlindedMessagePath>, ()> {
10982- let now = self.duration_since_epoch();
10983- let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
10984-
10985- if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
10986- self.create_compact_blinded_paths(context)
10987- } else {
10988- self.create_blinded_paths(MessageContext::Offers(context))
10989- }
10990- }
10991-
10979+ #[cfg(any(test, async_payments))]
1099210980 pub(super) fn duration_since_epoch(&self) -> Duration {
1099310981 #[cfg(not(feature = "std"))]
1099410982 let now = Duration::from_secs(
@@ -11034,21 +11022,6 @@ where
1103411022 .and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
1103511023 }
1103611024
11037- /// Creates a collection of blinded paths by delegating to
11038- /// [`MessageRouter::create_compact_blinded_paths`].
11039- ///
11040- /// Errors if the `MessageRouter` errors.
11041- fn create_compact_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
11042- let recipient = self.get_our_node_id();
11043- let secp_ctx = &self.secp_ctx;
11044-
11045- let peers = self.get_peers_for_blinded_path();
11046-
11047- self.message_router
11048- .create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
11049- .and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
11050- }
11051-
1105211025 /// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
1105311026 /// [`Router::create_blinded_payment_paths`].
1105411027 fn create_blinded_payment_paths(
0 commit comments