@@ -2156,9 +2156,8 @@ where
2156
2156
/// #
2157
2157
/// # fn example<T: AChannelManager>(channel_manager: T) -> Result<(), Bolt12SemanticError> {
2158
2158
/// # let channel_manager = channel_manager.get_cm();
2159
- /// # let absolute_expiry = None;
2160
2159
/// let offer = channel_manager
2161
- /// .create_offer_builder(absolute_expiry )?
2160
+ /// .create_offer_builder()?
2162
2161
/// # ;
2163
2162
/// # // Needed for compiling for c_bindings
2164
2163
/// # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into();
@@ -2969,9 +2968,7 @@ const MAX_NO_CHANNEL_PEERS: usize = 250;
2969
2968
/// short-lived, while anything with a greater expiration is considered long-lived.
2970
2969
///
2971
2970
/// Using [`ChannelManager::create_offer_builder`] or [`ChannelManager::create_refund_builder`],
2972
- /// will included a [`BlindedMessagePath`] created using:
2973
- /// - [`MessageRouter::create_compact_blinded_paths`] when short-lived, and
2974
- /// - [`MessageRouter::create_blinded_paths`] when long-lived.
2971
+ /// will include a [`BlindedMessagePath`] created using [`MessageRouter::create_blinded_paths`].
2975
2972
///
2976
2973
/// Using compact [`BlindedMessagePath`]s may provide better privacy as the [`MessageRouter`] could select
2977
2974
/// more hops. However, since they use short channel ids instead of pubkeys, they are more likely to
@@ -11570,10 +11567,8 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
11570
11567
///
11571
11568
/// # Privacy
11572
11569
///
11573
- /// Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the offer based on the given
11574
- /// `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for
11575
- /// privacy implications as well as those of the parameterized [`Router`], which implements
11576
- /// [`MessageRouter`].
11570
+ /// Uses the [`MessageRouter`] provided to the [`ChannelManager`] at construction to build a
11571
+ /// [`BlindedMessagePath`] for the offer. See those docs for privacy implications.
11577
11572
///
11578
11573
/// Also, uses a derived signing pubkey in the offer for recipient privacy.
11579
11574
///
@@ -11583,17 +11578,40 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
11583
11578
///
11584
11579
/// # Errors
11585
11580
///
11586
- /// Errors if the parameterized [`Router `] is unable to create a blinded path for the offer.
11581
+ /// Errors if the parameterized [`MessageRouter `] is unable to create a blinded path for the offer.
11587
11582
///
11588
11583
/// [`BlindedMessagePath`]: crate::blinded_path::message::BlindedMessagePath
11589
11584
/// [`Offer`]: crate::offers::offer::Offer
11590
11585
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
11591
- pub fn create_offer_builder(
11592
- &$self, absolute_expiry: Option<Duration>
11593
- ) -> Result<$builder, Bolt12SemanticError> {
11594
- let entropy = &*$self.entropy_source ;
11586
+ pub fn create_offer_builder(&$self) -> Result<$builder, Bolt12SemanticError> {
11587
+ let builder = $self.flow.create_offer_builder(
11588
+ &*$self.entropy_source, $self.get_peers_for_blinded_path()
11589
+ )? ;
11595
11590
11596
- let builder = $self.flow.create_offer_builder(entropy, absolute_expiry, $self.get_peers_for_blinded_path())?;
11591
+ Ok(builder.into())
11592
+ }
11593
+
11594
+ /// Same as [`Self::create_offer_builder`], but allows specifying a custom [`MessageRouter`]
11595
+ /// instead of using the [`MessageRouter`] provided to the [`ChannelManager`] at construction.
11596
+ ///
11597
+ /// This gives users full control over how the [`BlindedMessagePath`] is constructed,
11598
+ /// including the option to omit it entirely.
11599
+ ///
11600
+ /// See [`Self::create_offer_builder`] for details on offer construction, privacy, and limitations.
11601
+ ///
11602
+ /// [`BlindedMessagePath`]: crate::blinded_path::message::BlindedMessagePath
11603
+ /// [`Offer`]: crate::offers::offer::Offer
11604
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
11605
+ pub fn create_offer_builder_using_router<ME: Deref>(
11606
+ &$self,
11607
+ router: ME,
11608
+ ) -> Result<$builder, Bolt12SemanticError>
11609
+ where
11610
+ ME::Target: MessageRouter,
11611
+ {
11612
+ let builder = $self.flow.create_offer_builder_using_router(
11613
+ router, &*$self.entropy_source, $self.get_peers_for_blinded_path()
11614
+ )?;
11597
11615
11598
11616
Ok(builder.into())
11599
11617
}
@@ -11624,8 +11642,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
11624
11642
///
11625
11643
/// Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the refund based on the given
11626
11644
/// `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for
11627
- /// privacy implications as well as those of the parameterized [`Router`], which implements
11628
- /// [`MessageRouter`].
11645
+ /// privacy implications.
11629
11646
///
11630
11647
/// Also, uses a derived payer id in the refund for payer privacy.
11631
11648
///
@@ -11663,6 +11680,55 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
11663
11680
11664
11681
Ok(builder.into())
11665
11682
}
11683
+
11684
+ /// Same as [`Self::create_refund_builder`], but allows specifying a custom [`MessageRouter`]
11685
+ /// instead of using the one provided during [`ChannelManager`] construction for
11686
+ /// [`BlindedMessagePath`] creation.
11687
+ ///
11688
+ /// This gives users full control over how the [`BlindedMessagePath`] is constructed for the
11689
+ /// refund, including the option to omit it entirely. This is useful for testing or when
11690
+ /// alternative privacy strategies are needed.
11691
+ ///
11692
+ /// See [`Self::create_refund_builder`] for:
11693
+ /// - refund recognition by [`ChannelManager`] via [`Bolt12Invoice`] handling,
11694
+ /// - `payment_id` rules and expiration behavior,
11695
+ /// - invoice revocation and refund failure handling,
11696
+ /// - defaulting behavior for `max_total_routing_fee_msat`,
11697
+ /// - and detailed payment and privacy semantics.
11698
+ ///
11699
+ /// # Errors
11700
+ ///
11701
+ /// In addition to the errors in [`Self::create_refund_builder`], this returns an error if
11702
+ /// the provided [`MessageRouter`] fails to construct a valid [`BlindedMessagePath`] for the refund.
11703
+ ///
11704
+ /// [`Refund`]: crate::offers::refund::Refund
11705
+ /// [`BlindedMessagePath`]: crate::blinded_path::message::BlindedMessagePath
11706
+ /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
11707
+ pub fn create_refund_builder_using_router<ME: Deref>(
11708
+ &$self, router: ME, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId,
11709
+ retry_strategy: Retry, route_params_config: RouteParametersConfig
11710
+ ) -> Result<$builder, Bolt12SemanticError>
11711
+ where
11712
+ ME::Target: MessageRouter,
11713
+ {
11714
+ let entropy = &*$self.entropy_source;
11715
+
11716
+ let builder = $self.flow.create_refund_builder_using_router(
11717
+ router, entropy, amount_msats, absolute_expiry,
11718
+ payment_id, $self.get_peers_for_blinded_path()
11719
+ )?;
11720
+
11721
+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop($self);
11722
+
11723
+ let expiration = StaleExpiration::AbsoluteTimeout(absolute_expiry);
11724
+ $self.pending_outbound_payments
11725
+ .add_new_awaiting_invoice(
11726
+ payment_id, expiration, retry_strategy, route_params_config, None,
11727
+ )
11728
+ .map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
11729
+
11730
+ Ok(builder.into())
11731
+ }
11666
11732
} }
11667
11733
11668
11734
impl<
@@ -11821,8 +11887,7 @@ where
11821
11887
/// # Privacy
11822
11888
///
11823
11889
/// For payer privacy, uses a derived payer id and uses [`MessageRouter::create_blinded_paths`]
11824
- /// to construct a [`BlindedMessagePath`] for the reply path. For further privacy implications, see the
11825
- /// docs of the parameterized [`Router`], which implements [`MessageRouter`].
11890
+ /// to construct a [`BlindedMessagePath`] for the reply path.
11826
11891
///
11827
11892
/// # Limitations
11828
11893
///
@@ -12001,8 +12066,7 @@ where
12001
12066
/// # Privacy
12002
12067
///
12003
12068
/// For payer privacy, uses a derived payer id and uses [`MessageRouter::create_blinded_paths`]
12004
- /// to construct a [`BlindedMessagePath`] for the reply path. For further privacy implications, see the
12005
- /// docs of the parameterized [`Router`], which implements [`MessageRouter`].
12069
+ /// to construct a [`BlindedMessagePath`] for the reply path.
12006
12070
///
12007
12071
/// # Limitations
12008
12072
///
@@ -18318,7 +18382,7 @@ pub mod bench {
18318
18382
let scorer = RwLock::new(test_utils::TestScorer::new());
18319
18383
let entropy = test_utils::TestKeysInterface::new(&[0u8; 32], network);
18320
18384
let router = test_utils::TestRouter::new(Arc::new(NetworkGraph::new(network, &logger_a)), &logger_a, &scorer);
18321
- let message_router = test_utils::TestMessageRouter::new (Arc::new(NetworkGraph::new(network, &logger_a)), &entropy);
18385
+ let message_router = test_utils::TestMessageRouter::new_default (Arc::new(NetworkGraph::new(network, &logger_a)), &entropy);
18322
18386
18323
18387
let mut config: UserConfig = Default::default();
18324
18388
config.channel_config.max_dust_htlc_exposure = MaxDustHTLCExposure::FeeRateMultiplier(5_000_000 / 253);
0 commit comments