@@ -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.
@@ -10972,25 +10978,7 @@ where
10972
10978
inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
10973
10979
}
10974
10980
10975
- /// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on
10976
- /// the path's intended lifetime.
10977
- ///
10978
- /// Whether or not the path is compact depends on whether the path is short-lived or long-lived,
10979
- /// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
10980
- /// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
10981
- fn create_blinded_paths_using_absolute_expiry(
10982
- &self, context: OffersContext, absolute_expiry: Option<Duration>,
10983
- ) -> Result<Vec<BlindedMessagePath>, ()> {
10984
- let now = self.duration_since_epoch();
10985
- let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
10986
-
10987
- if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
10988
- self.create_compact_blinded_paths(context)
10989
- } else {
10990
- self.create_blinded_paths(MessageContext::Offers(context))
10991
- }
10992
- }
10993
-
10981
+ #[cfg(any(test, async_payments))]
10994
10982
pub(super) fn duration_since_epoch(&self) -> Duration {
10995
10983
#[cfg(not(feature = "std"))]
10996
10984
let now = Duration::from_secs(
@@ -11036,21 +11024,6 @@ where
11036
11024
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
11037
11025
}
11038
11026
11039
- /// Creates a collection of blinded paths by delegating to
11040
- /// [`MessageRouter::create_compact_blinded_paths`].
11041
- ///
11042
- /// Errors if the `MessageRouter` errors.
11043
- fn create_compact_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
11044
- let recipient = self.get_our_node_id();
11045
- let secp_ctx = &self.secp_ctx;
11046
-
11047
- let peers = self.get_peers_for_blinded_path();
11048
-
11049
- self.message_router
11050
- .create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
11051
- .and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
11052
- }
11053
-
11054
11027
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
11055
11028
/// [`Router::create_blinded_payment_paths`].
11056
11029
fn create_blinded_payment_paths(
0 commit comments