@@ -4519,24 +4519,32 @@ where
4519
4519
}
4520
4520
}
4521
4521
4522
- /// Sends a payment along a given route.
4523
- ///
4524
- /// This method is *DEPRECATED*, use [`Self::send_payment`] instead. If you wish to fix the
4525
- /// route for a payment, do so by matching the [`PaymentId`] passed to
4526
- /// [`Router::find_route_with_id`].
4527
- ///
4528
- /// Value parameters are provided via the last hop in route, see documentation for [`RouteHop`]
4529
- /// fields for more info.
4522
+ // Deprecated send method, for testing use [`Self::send_payment`] and
4523
+ // [`TestRouter::expect_find_route`] instead.
4524
+ //
4525
+ // [`TestRouter::expect_find_route`]: crate::util::test_utils::TestRouter::expect_find_route
4526
+ #[cfg(any(test, fuzzing))]
4527
+ pub fn send_payment_with_route(&self, route: Route, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, payment_id: PaymentId) -> Result<(), PaymentSendFailure> {
4528
+ let best_block_height = self.best_block.read().unwrap().height;
4529
+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
4530
+ self.pending_outbound_payments
4531
+ .send_payment_with_route(&route, payment_hash, recipient_onion, payment_id,
4532
+ &self.entropy_source, &self.node_signer, best_block_height,
4533
+ |args| self.send_payment_along_path(args))
4534
+ }
4535
+
4536
+ /// Sends a payment to the route found using the provided [`RouteParameters`], retrying failed
4537
+ /// payment paths based on the provided `Retry`.
4530
4538
///
4531
4539
/// May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via
4532
4540
/// [`PeerManager::process_events`]).
4533
4541
///
4534
4542
/// # Avoiding Duplicate Payments
4535
4543
///
4536
4544
/// If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
4537
- /// method will error with an [`APIError::InvalidRoute `]. Note, however, that once a payment
4538
- /// is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
4539
- /// [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a
4545
+ /// method will error with [`RetryableSendFailure::DuplicatePayment `]. Note, however, that once a
4546
+ /// payment is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of
4547
+ /// an [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a
4540
4548
/// second payment with the same [`PaymentId`].
4541
4549
///
4542
4550
/// Thus, in order to ensure duplicate payments are not sent, you should implement your own
@@ -4550,43 +4558,18 @@ where
4550
4558
/// using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
4551
4559
/// [`ChannelManager::list_recent_payments`] for more information.
4552
4560
///
4553
- /// # Possible Error States on [`PaymentSendFailure`]
4554
- ///
4555
- /// Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with
4556
- /// each entry matching the corresponding-index entry in the route paths, see
4557
- /// [`PaymentSendFailure`] for more info.
4558
- ///
4559
- /// In general, a path may raise:
4560
- /// * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
4561
- /// node public key) is specified.
4562
- /// * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been
4563
- /// closed, doesn't exist, or the peer is currently disconnected.
4564
- /// * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
4565
- /// relevant updates.
4566
- ///
4567
- /// Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been
4568
- /// irrevocably committed to on our end. In such a case, do NOT retry the payment with a
4569
- /// different route unless you intend to pay twice!
4561
+ /// Routes are automatically found using the [`Router] provided on startup. To fix a route for a
4562
+ /// particular payment, match the [`PaymentId`] passed to [`Router::find_route_with_id`].
4570
4563
///
4571
- /// [`RouteHop`]: crate::routing::router::RouteHop
4572
4564
/// [`Event::PaymentSent`]: events::Event::PaymentSent
4573
4565
/// [`Event::PaymentFailed`]: events::Event::PaymentFailed
4574
4566
/// [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs
4575
4567
/// [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
4576
4568
/// [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
4577
- #[cfg_attr(not(any(test, feature = "_test_utils")), deprecated(note = "Use `send_payment` instead"))]
4578
- pub fn send_payment_with_route(&self, route: Route, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, payment_id: PaymentId) -> Result<(), PaymentSendFailure> {
4579
- let best_block_height = self.best_block.read().unwrap().height;
4580
- let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
4581
- self.pending_outbound_payments
4582
- .send_payment_with_route(&route, payment_hash, recipient_onion, payment_id,
4583
- &self.entropy_source, &self.node_signer, best_block_height,
4584
- |args| self.send_payment_along_path(args))
4585
- }
4586
-
4587
- /// Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on
4588
- /// `route_params` and retry failed payment paths based on `retry_strategy`.
4589
- pub fn send_payment(&self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, payment_id: PaymentId, route_params: RouteParameters, retry_strategy: Retry) -> Result<(), RetryableSendFailure> {
4569
+ pub fn send_payment(
4570
+ &self, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, payment_id: PaymentId,
4571
+ route_params: RouteParameters, retry_strategy: Retry
4572
+ ) -> Result<(), RetryableSendFailure> {
4590
4573
let best_block_height = self.best_block.read().unwrap().height;
4591
4574
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
4592
4575
self.pending_outbound_payments
@@ -4801,8 +4784,26 @@ where
4801
4784
/// would be able to guess -- otherwise, an intermediate node may claim the payment and it will
4802
4785
/// never reach the recipient.
4803
4786
///
4804
- /// See [`send_payment`] documentation for more details on the return value of this function
4805
- /// and idempotency guarantees provided by the [`PaymentId`] key.
4787
+ /// See [`send_payment`] documentation for more details on the idempotency guarantees provided by
4788
+ /// the [`PaymentId`] key.
4789
+ ///
4790
+ /// # Possible Error States on [`PaymentSendFailure`]
4791
+ ///
4792
+ /// Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with
4793
+ /// each entry matching the corresponding-index entry in the route paths, see
4794
+ /// [`PaymentSendFailure`] for more info.
4795
+ ///
4796
+ /// In general, a path may raise:
4797
+ /// * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
4798
+ /// node public key) is specified.
4799
+ /// * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been
4800
+ /// closed, doesn't exist, or the peer is currently disconnected.
4801
+ /// * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
4802
+ /// relevant updates.
4803
+ ///
4804
+ /// Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been
4805
+ /// irrevocably committed to on our end. In such a case, do NOT retry the payment with a
4806
+ /// different route unless you intend to pay twice!
4806
4807
///
4807
4808
/// Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
4808
4809
/// [`send_payment`] for more information about the risks of duplicate preimage usage.
0 commit comments