@@ -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.
@@ -10970,25 +10976,7 @@ where
10970
10976
inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
10971
10977
}
10972
10978
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))]
10992
10980
pub(super) fn duration_since_epoch(&self) -> Duration {
10993
10981
#[cfg(not(feature = "std"))]
10994
10982
let now = Duration::from_secs(
@@ -11034,21 +11022,6 @@ where
11034
11022
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
11035
11023
}
11036
11024
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
-
11052
11025
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
11053
11026
/// [`Router::create_blinded_payment_paths`].
11054
11027
fn create_blinded_payment_paths(
0 commit comments