Skip to content

Commit aba369e

Browse files
committed
Remove Redundant Variants of create_blinded_paths
Following the updates in previous commits, the other variants of `create_blinded_paths`—namely `create_compact_blinded_paths` and `create_blinded_paths_using_absolute_expiry`—are now redundant. This commit removes these variants as they are no longer necessary.
1 parent 855ce29 commit aba369e

File tree

3 files changed

+2
-98
lines changed

3 files changed

+2
-98
lines changed

lightning/src/offers/flow.rs

+2-44
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,7 @@ where
619619
/// short-lived, while anything with a greater expiration is considered long-lived.
620620
///
621621
/// Using [`OffersMessageFlow::create_offer_builder`] or [`OffersMessageFlow::create_refund_builder`],
622-
/// will included a [`BlindedMessagePath`] created using:
623-
/// - [`MessageRouter::create_compact_blinded_paths`] when short-lived, and
624-
/// - [`MessageRouter::create_blinded_paths`] when long-lived.
622+
/// will included a [`BlindedMessagePath`] created using: [`MessageRouter::create_blinded_paths`]
625623
///
626624
/// [`OffersMessageFlow::create_offer_builder`]: crate::offers::flow::OffersMessageFlow::create_offer_builder
627625
/// [`OffersMessageFlow::create_refund_builder`]: crate::offers::flow::OffersMessageFlow::create_refund_builder
@@ -649,25 +647,7 @@ where
649647
MR::Target: MessageRouter,
650648
L::Target: Logger,
651649
{
652-
/// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on
653-
/// the path's intended lifetime.
654-
///
655-
/// Whether or not the path is compact depends on whether the path is short-lived or long-lived,
656-
/// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
657-
/// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
658-
pub fn create_blinded_paths_using_absolute_expiry(
659-
&self, context: OffersContext, absolute_expiry: Option<Duration>,
660-
) -> Result<Vec<BlindedMessagePath>, ()> {
661-
let now = self.duration_since_epoch();
662-
let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
663-
664-
if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
665-
self.create_compact_blinded_paths(context)
666-
} else {
667-
self.create_blinded_paths(MessageContext::Offers(context))
668-
}
669-
}
670-
650+
#[cfg(test)]
671651
pub(crate) fn duration_since_epoch(&self) -> Duration {
672652
#[cfg(not(feature = "std"))]
673653
let now = self.commons.get_highest_seen_timestamp();
@@ -698,28 +678,6 @@ where
698678
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
699679
}
700680

701-
/// Creates a collection of blinded paths by delegating to
702-
/// [`MessageRouter::create_compact_blinded_paths`].
703-
///
704-
/// Errors if the `MessageRouter` errors.
705-
fn create_compact_blinded_paths(
706-
&self, context: OffersContext,
707-
) -> Result<Vec<BlindedMessagePath>, ()> {
708-
let recipient = self.get_our_node_id();
709-
let secp_ctx = &self.secp_ctx;
710-
711-
let peers = self.commons.get_peer_for_blinded_path();
712-
713-
self.message_router
714-
.create_compact_blinded_paths(
715-
recipient,
716-
MessageContext::Offers(context),
717-
peers,
718-
secp_ctx,
719-
)
720-
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
721-
}
722-
723681
fn enqueue_invoice_request(
724682
&self, invoice_request: InvoiceRequest, reply_paths: Vec<BlindedMessagePath>,
725683
) -> Result<(), Bolt12SemanticError> {

lightning/src/onion_message/messenger.rs

-47
Original file line numberDiff line numberDiff line change
@@ -461,28 +461,6 @@ pub trait MessageRouter {
461461
>(
462462
&self, recipient: PublicKey, context: MessageContext, peers: Vec<MessageForwardNode>, secp_ctx: &Secp256k1<T>,
463463
) -> Result<Vec<BlindedMessagePath>, ()>;
464-
465-
/// Creates compact [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are
466-
/// assumed to be direct peers with the `recipient`.
467-
///
468-
/// Compact blinded paths use short channel ids instead of pubkeys for a smaller serialization,
469-
/// which is beneficial when a QR code is used to transport the data. The SCID is passed using
470-
/// a [`MessageForwardNode`] but may be `None` for graceful degradation.
471-
///
472-
/// Implementations using additional intermediate nodes are responsible for using a
473-
/// [`MessageForwardNode`] with `Some` short channel id, if possible. Similarly, implementations
474-
/// should call [`BlindedMessagePath::use_compact_introduction_node`].
475-
///
476-
/// The provided implementation simply delegates to [`MessageRouter::create_blinded_paths`],
477-
/// ignoring the short channel ids.
478-
fn create_compact_blinded_paths<
479-
T: secp256k1::Signing + secp256k1::Verification
480-
>(
481-
&self, recipient: PublicKey, context: MessageContext,
482-
peers: Vec<MessageForwardNode>, secp_ctx: &Secp256k1<T>,
483-
) -> Result<Vec<BlindedMessagePath>, ()> {
484-
self.create_blinded_paths(recipient, context, peers, secp_ctx)
485-
}
486464
}
487465

488466
/// A [`MessageRouter`] that can only route to a directly connected [`Destination`].
@@ -632,15 +610,6 @@ where
632610
) -> Result<Vec<BlindedMessagePath>, ()> {
633611
Self::create_blinded_paths_from_iter(network_graph, recipient, context, peers.into_iter(), entropy_source, secp_ctx, self.is_compact)
634612
}
635-
636-
pub(crate) fn create_compact_blinded_paths<
637-
T: secp256k1::Signing + secp256k1::Verification
638-
>(
639-
network_graph: &G, recipient: PublicKey, context: MessageContext,
640-
peers: Vec<MessageForwardNode>, entropy_source: &ES, secp_ctx: &Secp256k1<T>,
641-
) -> Result<Vec<BlindedMessagePath>, ()> {
642-
Self::create_blinded_paths_from_iter(network_graph, recipient, context, peers.into_iter(), entropy_source, secp_ctx, true)
643-
}
644613
}
645614

646615
impl<G: Deref<Target=NetworkGraph<L>>, L: Deref, ES: Deref> MessageRouter for DefaultMessageRouter<G, L, ES>
@@ -661,14 +630,6 @@ where
661630
) -> Result<Vec<BlindedMessagePath>, ()> {
662631
self.create_blinded_paths_internal(&self.network_graph, recipient, context, peers, &self.entropy_source, secp_ctx)
663632
}
664-
665-
fn create_compact_blinded_paths<
666-
T: secp256k1::Signing + secp256k1::Verification
667-
>(
668-
&self, recipient: PublicKey, context: MessageContext, peers: Vec<MessageForwardNode>, secp_ctx: &Secp256k1<T>,
669-
) -> Result<Vec<BlindedMessagePath>, ()> {
670-
Self::create_compact_blinded_paths(&self.network_graph, recipient, context, peers, &self.entropy_source, secp_ctx)
671-
}
672633
}
673634

674635
/// A [`MessageRouter`] implementation that does not perform routing.
@@ -693,14 +654,6 @@ impl MessageRouter for NullMessageRouter {
693654
) -> Result<Vec<BlindedMessagePath>, ()> {
694655
Ok(Vec::new())
695656
}
696-
697-
fn create_compact_blinded_paths<
698-
T: secp256k1::Signing + secp256k1::Verification
699-
>(
700-
&self, _recipient: PublicKey, _context: MessageContext, _peers: Vec<MessageForwardNode>, _secp_ctx: &Secp256k1<T>,
701-
) -> Result<Vec<BlindedMessagePath>, ()> {
702-
Ok(Vec::new())
703-
}
704657
}
705658

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

lightning/src/util/test_utils.rs

-7
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,6 @@ impl<'a> MessageRouter for TestMessageRouter<'a> {
297297
) -> Result<Vec<BlindedMessagePath>, ()> {
298298
self.inner.create_blinded_paths(recipient, context, peers, secp_ctx)
299299
}
300-
301-
fn create_compact_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
302-
&self, recipient: PublicKey, context: MessageContext,
303-
peers: Vec<MessageForwardNode>, secp_ctx: &Secp256k1<T>,
304-
) -> Result<Vec<BlindedMessagePath>, ()> {
305-
self.inner.create_compact_blinded_paths(recipient, context, peers, secp_ctx)
306-
}
307300
}
308301

309302
pub struct OnlyReadsKeysInterface {}

0 commit comments

Comments
 (0)