Skip to content

Commit d1e2b66

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 a3e0241 commit d1e2b66

File tree

3 files changed

+5
-101
lines changed

3 files changed

+5
-101
lines changed

lightning/src/ln/channelmanager.rs

+5-37
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
@@ -10973,25 +10975,6 @@ where
1097310975
inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
1097410976
}
1097510977

10976-
/// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on
10977-
/// the path's intended lifetime.
10978-
///
10979-
/// Whether or not the path is compact depends on whether the path is short-lived or long-lived,
10980-
/// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
10981-
/// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
10982-
fn create_blinded_paths_using_absolute_expiry(
10983-
&self, context: OffersContext, absolute_expiry: Option<Duration>,
10984-
) -> Result<Vec<BlindedMessagePath>, ()> {
10985-
let now = self.duration_since_epoch();
10986-
let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
10987-
10988-
if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
10989-
self.create_compact_blinded_paths(context)
10990-
} else {
10991-
self.create_blinded_paths(MessageContext::Offers(context))
10992-
}
10993-
}
10994-
1099510978
pub(super) fn duration_since_epoch(&self) -> Duration {
1099610979
#[cfg(not(feature = "std"))]
1099710980
let now = Duration::from_secs(
@@ -11037,21 +11020,6 @@ where
1103711020
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
1103811021
}
1103911022

11040-
/// Creates a collection of blinded paths by delegating to
11041-
/// [`MessageRouter::create_compact_blinded_paths`].
11042-
///
11043-
/// Errors if the `MessageRouter` errors.
11044-
fn create_compact_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
11045-
let recipient = self.get_our_node_id();
11046-
let secp_ctx = &self.secp_ctx;
11047-
11048-
let peers = self.get_peers_for_blinded_path();
11049-
11050-
self.message_router
11051-
.create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
11052-
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
11053-
}
11054-
1105511023
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
1105611024
/// [`Router::create_blinded_payment_paths`].
1105711025
fn create_blinded_payment_paths(

lightning/src/onion_message/messenger.rs

-57
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

@@ -756,21 +721,6 @@ where
756721
true,
757722
)
758723
}
759-
760-
fn create_compact_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
761-
&self, recipient: PublicKey, context: MessageContext, peers: Vec<MessageForwardNode>,
762-
secp_ctx: &Secp256k1<T>,
763-
) -> Result<Vec<BlindedMessagePath>, ()> {
764-
DefaultMessageRouter::create_blinded_paths_from_iter(
765-
&self.network_graph,
766-
recipient,
767-
context,
768-
peers.into_iter(),
769-
&self.entropy_source,
770-
secp_ctx,
771-
true,
772-
)
773-
}
774724
}
775725

776726
/// A special [`MessageRouter`] that can doesn't route.
@@ -790,13 +740,6 @@ impl MessageRouter for NullMessageRouter
790740
) -> Result<Vec<BlindedMessagePath>, ()> {
791741
Ok(vec![])
792742
}
793-
794-
fn create_compact_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
795-
&self, _recipient: PublicKey, _context: MessageContext, _peers: Vec<MessageForwardNode>,
796-
_secp_ctx: &Secp256k1<T>,
797-
) -> Result<Vec<BlindedMessagePath>, ()> {
798-
Ok(vec![])
799-
}
800743
}
801744

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

lightning/src/util/test_utils.rs

-7
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)