Skip to content

Commit 802735e

Browse files
committed
Refactor: Remove redundant create_blinded_paths from ChannelManager
1 parent f6fb5b4 commit 802735e

File tree

1 file changed

+5
-65
lines changed

1 file changed

+5
-65
lines changed

lightning/src/ln/channelmanager.rs

+5-65
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use crate::events::FundingInfo;
3636
use crate::blinded_path::message::{AsyncPaymentsContext, MessageContext, OffersContext};
3737
use crate::blinded_path::NodeIdLookUp;
3838
use crate::blinded_path::message::{BlindedMessagePath, MessageForwardNode};
39-
use crate::blinded_path::payment::{AsyncBolt12OfferContext, BlindedPaymentPath, Bolt12OfferContext, PaymentConstraints, PaymentContext, UnauthenticatedReceiveTlvs};
39+
use crate::blinded_path::payment::{AsyncBolt12OfferContext, Bolt12OfferContext, PaymentContext, UnauthenticatedReceiveTlvs};
4040
use crate::chain;
4141
use crate::chain::{Confirm, ChannelMonitorUpdateStatus, Watch, BestBlock};
4242
use crate::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator, LowerBoundedFeeEstimator};
@@ -90,7 +90,8 @@ use crate::util::logger::{Level, Logger, WithContext};
9090
use crate::util::errors::APIError;
9191
#[cfg(async_payments)]
9292
use crate::offers::static_invoice::{StaticInvoice, StaticInvoiceBuilder};
93-
93+
#[cfg(all(test, async_payments))]
94+
use crate::blinded_path::payment::{BlindedPaymentPath, PaymentConstraints};
9495
#[cfg(feature = "dnssec")]
9596
use crate::blinded_path::message::DNSResolverContext;
9697
#[cfg(feature = "dnssec")]
@@ -10534,25 +10535,6 @@ where
1053410535
inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key)
1053510536
}
1053610537

10537-
/// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on
10538-
/// the path's intended lifetime.
10539-
///
10540-
/// Whether or not the path is compact depends on whether the path is short-lived or long-lived,
10541-
/// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See
10542-
/// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`].
10543-
fn create_blinded_paths_using_absolute_expiry(
10544-
&self, context: OffersContext, absolute_expiry: Option<Duration>,
10545-
) -> Result<Vec<BlindedMessagePath>, ()> {
10546-
let now = self.duration_since_epoch();
10547-
let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY);
10548-
10549-
if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
10550-
self.create_compact_blinded_paths(context)
10551-
} else {
10552-
self.create_blinded_paths(MessageContext::Offers(context))
10553-
}
10554-
}
10555-
1055610538
pub(super) fn duration_since_epoch(&self) -> Duration {
1055710539
#[cfg(not(feature = "std"))]
1055810540
let now = Duration::from_secs(
@@ -10583,42 +10565,10 @@ where
1058310565
.collect::<Vec<_>>()
1058410566
}
1058510567

10586-
/// Creates a collection of blinded paths by delegating to
10587-
/// [`MessageRouter::create_blinded_paths`].
10588-
///
10589-
/// Errors if the `MessageRouter` errors.
10590-
fn create_blinded_paths(&self, context: MessageContext) -> Result<Vec<BlindedMessagePath>, ()> {
10591-
let recipient = self.get_our_node_id();
10592-
let secp_ctx = &self.secp_ctx;
10593-
10594-
let peers = self.get_peers_for_blinded_path()
10595-
.into_iter()
10596-
.map(|node| node.node_id)
10597-
.collect();
10598-
10599-
self.message_router
10600-
.create_blinded_paths(recipient, context, peers, secp_ctx)
10601-
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
10602-
}
10603-
10604-
/// Creates a collection of blinded paths by delegating to
10605-
/// [`MessageRouter::create_compact_blinded_paths`].
10606-
///
10607-
/// Errors if the `MessageRouter` errors.
10608-
fn create_compact_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
10609-
let recipient = self.get_our_node_id();
10610-
let secp_ctx = &self.secp_ctx;
10611-
10612-
let peers = self.get_peers_for_blinded_path();
10613-
10614-
self.message_router
10615-
.create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
10616-
.and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
10617-
}
10618-
10568+
#[cfg(all(test, async_payments))]
1061910569
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
1062010570
/// [`Router::create_blinded_payment_paths`].
10621-
fn create_blinded_payment_paths(
10571+
fn test_create_blinded_payment_paths(
1062210572
&self, amount_msats: Option<u64>, payment_secret: PaymentSecret, payment_context: PaymentContext,
1062310573
relative_expiry_seconds: u32
1062410574
) -> Result<Vec<BlindedPaymentPath>, ()> {
@@ -10652,16 +10602,6 @@ where
1065210602
)
1065310603
}
1065410604

10655-
#[cfg(all(test, async_payments))]
10656-
pub(super) fn test_create_blinded_payment_paths(
10657-
&self, amount_msats: Option<u64>, payment_secret: PaymentSecret, payment_context: PaymentContext,
10658-
relative_expiry_seconds: u32
10659-
) -> Result<Vec<BlindedPaymentPath>, ()> {
10660-
self.create_blinded_payment_paths(
10661-
amount_msats, payment_secret, payment_context, relative_expiry_seconds
10662-
)
10663-
}
10664-
1066510605
/// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
1066610606
/// are used when constructing the phantom invoice's route hints.
1066710607
///

0 commit comments

Comments
 (0)