Skip to content

Commit 4d87461

Browse files
Rework auto retry send errors
Prior to this, we returned PaymentSendFailure from auto retry send payment methods. This implied that we might return a PartialFailure from them, which has never been the case. So it makes sense to rework the errors to be a better fit for the methods. We're taking error handling in a totally different direction now to make it more asynchronous, see send_payment_internal for more information.
1 parent 9f41bd7 commit 4d87461

File tree

4 files changed

+233
-87
lines changed

4 files changed

+233
-87
lines changed

lightning-invoice/src/payment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use lightning::chain;
1717
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
1818
use lightning::chain::keysinterface::{NodeSigner, SignerProvider, EntropySource};
1919
use lightning::ln::{PaymentHash, PaymentSecret};
20-
use lightning::ln::channelmanager::{ChannelManager, PaymentId, PaymentSendFailure, Retry};
20+
use lightning::ln::channelmanager::{ChannelManager, PaymentId, Retry, RetryableSendFailure};
2121
use lightning::routing::router::{PaymentParameters, RouteParameters, Router};
2222
use lightning::util::logger::Logger;
2323

@@ -172,7 +172,7 @@ pub enum PaymentError {
172172
/// An error resulting from the provided [`Invoice`] or payment hash.
173173
Invoice(&'static str),
174174
/// An error occurring when sending a payment.
175-
Sending(PaymentSendFailure),
175+
Sending(RetryableSendFailure),
176176
}
177177

178178
/// A trait defining behavior of an [`Invoice`] payer.

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use core::time::Duration;
7676
use core::ops::Deref;
7777

7878
// Re-export this for use in the public API.
79-
pub use crate::ln::outbound_payment::{PaymentSendFailure, Retry};
79+
pub use crate::ln::outbound_payment::{PaymentSendFailure, Retry, RetryableSendFailure};
8080

8181
// We hold various information about HTLC relay in the HTLC objects in Channel itself:
8282
//
@@ -2531,7 +2531,7 @@ where
25312531

25322532
/// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on
25332533
/// `route_params` and retry failed payment paths based on `retry_strategy`.
2534-
pub fn send_payment_with_retry(&self, payment_hash: PaymentHash, payment_secret: &Option<PaymentSecret>, payment_id: PaymentId, route_params: RouteParameters, retry_strategy: Retry) -> Result<(), PaymentSendFailure> {
2534+
pub fn send_payment_with_retry(&self, payment_hash: PaymentHash, payment_secret: &Option<PaymentSecret>, payment_id: PaymentId, route_params: RouteParameters, retry_strategy: Retry) -> Result<(), RetryableSendFailure> {
25352535
let best_block_height = self.best_block.read().unwrap().height();
25362536
self.pending_outbound_payments
25372537
.send_payment(payment_hash, payment_secret, payment_id, retry_strategy, route_params,
@@ -2609,7 +2609,7 @@ where
26092609
/// payments.
26102610
///
26112611
/// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
2612-
pub fn send_spontaneous_payment_with_retry(&self, payment_preimage: Option<PaymentPreimage>, payment_id: PaymentId, route_params: RouteParameters, retry_strategy: Retry) -> Result<PaymentHash, PaymentSendFailure> {
2612+
pub fn send_spontaneous_payment_with_retry(&self, payment_preimage: Option<PaymentPreimage>, payment_id: PaymentId, route_params: RouteParameters, retry_strategy: Retry) -> Result<PaymentHash, RetryableSendFailure> {
26132613
let best_block_height = self.best_block.read().unwrap().height();
26142614
self.pending_outbound_payments.send_spontaneous_payment(payment_preimage, payment_id,
26152615
retry_strategy, route_params, &self.router, self.list_usable_channels(),

0 commit comments

Comments
 (0)