Skip to content

Commit 2f462cf

Browse files
committed
Cleanup: Remove redundant create_blinded_paths variants
With the recent updates to `create_blinded_paths` supporting flexible routing through `MessageRouter`, the specialized variants—`create_compact_blinded_paths` and `create_blinded_paths_using_absolute_expiry`—have become unnecessary. This commit removes those now-redundant functions to simplify the codebase and reduce maintenance overhead.
1 parent 266aebe commit 2f462cf

File tree

3 files changed

+5
-101
lines changed

3 files changed

+5
-101
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,9 +2872,11 @@ const MAX_NO_CHANNEL_PEERS: usize = 250;
28722872
/// short-lived, while anything with a greater expiration is considered long-lived.
28732873
///
28742874
/// 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.
2875+
/// will included a [`BlindedMessagePath`] created using [`MessageRouter::create_blinded_paths`].
2876+
///
2877+
/// To use compact [`BlindedMessagePath`] one can use [`ChannelManager::create_offer_builder_using_router`]
2878+
/// and [`ChannelManager::create_refund_builder_using_router`] to pass a custom router for compact
2879+
/// blinded path creation.
28782880
///
28792881
/// Using compact [`BlindedMessagePath`]s may provide better privacy as the [`MessageRouter`] could select
28802882
/// more hops. However, since they use short channel ids instead of pubkeys, they are more likely to
@@ -10966,25 +10968,6 @@ where
1096610968
inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
1096710969
}
1096810970

10969-
/// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on
10970-
/// the path's intended lifetime.
10971-
///
10972-
/// Whether or not the path is compact depends on whether the path is short-lived or long-lived,
10973-
/// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
10974-
/// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
10975-
fn create_blinded_paths_using_absolute_expiry(
10976-
&self, context: OffersContext, absolute_expiry: Option<Duration>,
10977-
) -> Result<Vec<BlindedMessagePath>, ()> {
10978-
let now = self.duration_since_epoch();
10979-
let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
10980-
10981-
if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
10982-
self.create_compact_blinded_paths(context)
10983-
} else {
10984-
self.create_blinded_paths(MessageContext::Offers(context))
10985-
}
10986-
}
10987-
1098810971
pub(super) fn duration_since_epoch(&self) -> Duration {
1098910972
#[cfg(not(feature = "std"))]
1099010973
let now = Duration::from_secs(
@@ -11030,21 +11013,6 @@ where
1103011013
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
1103111014
}
1103211015

11033-
/// Creates a collection of blinded paths by delegating to
11034-
/// [`MessageRouter::create_compact_blinded_paths`].
11035-
///
11036-
/// Errors if the `MessageRouter` errors.
11037-
fn create_compact_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
11038-
let recipient = self.get_our_node_id();
11039-
let secp_ctx = &self.secp_ctx;
11040-
11041-
let peers = self.get_peers_for_blinded_path();
11042-
11043-
self.message_router
11044-
.create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
11045-
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
11046-
}
11047-
1104811016
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
1104911017
/// [`Router::create_blinded_payment_paths`].
1105011018
fn create_blinded_payment_paths(

lightning/src/onion_message/messenger.rs

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -496,26 +496,6 @@ pub trait MessageRouter {
496496
&self, recipient: PublicKey, context: MessageContext, peers: Vec<MessageForwardNode>,
497497
secp_ctx: &Secp256k1<T>,
498498
) -> Result<Vec<BlindedMessagePath>, ()>;
499-
500-
/// Creates compact [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are
501-
/// assumed to be direct peers with the `recipient`.
502-
///
503-
/// Compact blinded paths use short channel ids instead of pubkeys for a smaller serialization,
504-
/// which is beneficial when a QR code is used to transport the data. The SCID is passed using
505-
/// a [`MessageForwardNode`] but may be `None` for graceful degradation.
506-
///
507-
/// Implementations using additional intermediate nodes are responsible for using a
508-
/// [`MessageForwardNode`] with `Some` short channel id, if possible. Similarly, implementations
509-
/// should call [`BlindedMessagePath::use_compact_introduction_node`].
510-
///
511-
/// The provided implementation simply delegates to [`MessageRouter::create_blinded_paths`],
512-
/// ignoring the short channel ids.
513-
fn create_compact_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
514-
&self, recipient: PublicKey, context: MessageContext, peers: Vec<MessageForwardNode>,
515-
secp_ctx: &Secp256k1<T>,
516-
) -> Result<Vec<BlindedMessagePath>, ()> {
517-
self.create_blinded_paths(recipient, context, peers, secp_ctx)
518-
}
519499
}
520500

521501
/// A [`MessageRouter`] that can only route to a directly connected [`Destination`].
@@ -683,21 +663,6 @@ where
683663
false,
684664
)
685665
}
686-
687-
fn create_compact_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
688-
&self, recipient: PublicKey, context: MessageContext, peers: Vec<MessageForwardNode>,
689-
secp_ctx: &Secp256k1<T>,
690-
) -> Result<Vec<BlindedMessagePath>, ()> {
691-
Self::create_blinded_paths_from_iter(
692-
&self.network_graph,
693-
recipient,
694-
context,
695-
peers.into_iter(),
696-
&self.entropy_source,
697-
secp_ctx,
698-
true,
699-
)
700-
}
701666
}
702667

703668
/// A [`MessageRouter`] that can only route to a directly connected [`Destination`],
@@ -755,21 +720,6 @@ where
755720
true,
756721
)
757722
}
758-
759-
fn create_compact_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
760-
&self, recipient: PublicKey, context: MessageContext, peers: Vec<MessageForwardNode>,
761-
secp_ctx: &Secp256k1<T>,
762-
) -> Result<Vec<BlindedMessagePath>, ()> {
763-
DefaultMessageRouter::create_blinded_paths_from_iter(
764-
&self.network_graph,
765-
recipient,
766-
context,
767-
peers.into_iter(),
768-
&self.entropy_source,
769-
secp_ctx,
770-
true,
771-
)
772-
}
773723
}
774724

775725
/// A special [`MessageRouter`] that can doesn't route.
@@ -788,13 +738,6 @@ impl MessageRouter for NullMessageRouter {
788738
) -> Result<Vec<BlindedMessagePath>, ()> {
789739
Ok(vec![])
790740
}
791-
792-
fn create_compact_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
793-
&self, _recipient: PublicKey, _context: MessageContext, _peers: Vec<MessageForwardNode>,
794-
_secp_ctx: &Secp256k1<T>,
795-
) -> Result<Vec<BlindedMessagePath>, ()> {
796-
Ok(vec![])
797-
}
798741
}
799742

800743
/// A path for sending an [`OnionMessage`].

lightning/src/util/test_utils.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,6 @@ impl<'a> MessageRouter for TestMessageRouter<'a> {
340340
) -> Result<Vec<BlindedMessagePath>, ()> {
341341
self.inner.create_blinded_paths(recipient, context, peers, secp_ctx)
342342
}
343-
344-
fn create_compact_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
345-
&self, recipient: PublicKey, context: MessageContext, peers: Vec<MessageForwardNode>,
346-
secp_ctx: &Secp256k1<T>,
347-
) -> Result<Vec<BlindedMessagePath>, ()> {
348-
self.inner.create_compact_blinded_paths(recipient, context, peers, secp_ctx)
349-
}
350343
}
351344

352345
pub struct OnlyReadsKeysInterface {}

0 commit comments

Comments
 (0)