@@ -2868,18 +2868,24 @@ const MAX_PEER_STORAGE_SIZE: usize = 1024;
2868
2868
/// many peers we reject new (inbound) connections.
2869
2869
const MAX_NO_CHANNEL_PEERS: usize = 250;
2870
2870
2871
+ #[cfg(test)]
2871
2872
/// The maximum expiration from the current time where an [`Offer`] or [`Refund`] is considered
2872
2873
/// short-lived, while anything with a greater expiration is considered long-lived.
2873
2874
///
2874
2875
/// 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.
2878
2884
///
2879
2885
/// Using compact [`BlindedMessagePath`]s may provide better privacy as the [`MessageRouter`] could select
2880
2886
/// more hops. However, since they use short channel ids instead of pubkeys, they are more likely to
2881
2887
/// 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);
2883
2889
2884
2890
/// Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments.
2885
2891
/// These include payments that have yet to find a successful path, or have unresolved HTLCs.
@@ -10971,25 +10977,7 @@ where
10971
10977
inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
10972
10978
}
10973
10979
10974
- /// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on
10975
- /// the path's intended lifetime.
10976
- ///
10977
- /// Whether or not the path is compact depends on whether the path is short-lived or long-lived,
10978
- /// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
10979
- /// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
10980
- fn create_blinded_paths_using_absolute_expiry(
10981
- &self, context: OffersContext, absolute_expiry: Option<Duration>,
10982
- ) -> Result<Vec<BlindedMessagePath>, ()> {
10983
- let now = self.duration_since_epoch();
10984
- let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
10985
-
10986
- if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
10987
- self.create_compact_blinded_paths(context)
10988
- } else {
10989
- self.create_blinded_paths(MessageContext::Offers(context))
10990
- }
10991
- }
10992
-
10980
+ #[cfg(any(test, async_payments))]
10993
10981
pub(super) fn duration_since_epoch(&self) -> Duration {
10994
10982
#[cfg(not(feature = "std"))]
10995
10983
let now = Duration::from_secs(
@@ -11035,21 +11023,6 @@ where
11035
11023
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
11036
11024
}
11037
11025
11038
- /// Creates a collection of blinded paths by delegating to
11039
- /// [`MessageRouter::create_compact_blinded_paths`].
11040
- ///
11041
- /// Errors if the `MessageRouter` errors.
11042
- fn create_compact_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
11043
- let recipient = self.get_our_node_id();
11044
- let secp_ctx = &self.secp_ctx;
11045
-
11046
- let peers = self.get_peers_for_blinded_path();
11047
-
11048
- self.message_router
11049
- .create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
11050
- .and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
11051
- }
11052
-
11053
11026
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
11054
11027
/// [`Router::create_blinded_payment_paths`].
11055
11028
fn create_blinded_payment_paths(
0 commit comments