Skip to content

Commit 4805560

Browse files
Move PaymentSendFailure into outbound_payment module
And re-export it in channelmanager.rs so it can remain public
1 parent f05c414 commit 4805560

File tree

2 files changed

+68
-65
lines changed

2 files changed

+68
-65
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use crate::ln::msgs;
5151
use crate::ln::onion_utils;
5252
use crate::ln::onion_utils::HTLCFailReason;
5353
use crate::ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VALUE_MSAT};
54+
pub use crate::ln::outbound_payment::PaymentSendFailure;
5455
use crate::ln::outbound_payment::PendingOutboundPayment;
5556
use crate::ln::wire::Encode;
5657
use crate::chain::keysinterface::{Sign, KeysInterface, KeysManager, Recipient};
@@ -1099,70 +1100,6 @@ impl ChannelDetails {
10991100
}
11001101
}
11011102

1102-
/// If a payment fails to send, it can be in one of several states. This enum is returned as the
1103-
/// Err() type describing which state the payment is in, see the description of individual enum
1104-
/// states for more.
1105-
#[derive(Clone, Debug)]
1106-
pub enum PaymentSendFailure {
1107-
/// A parameter which was passed to send_payment was invalid, preventing us from attempting to
1108-
/// send the payment at all.
1109-
///
1110-
/// You can freely resend the payment in full (with the parameter error fixed).
1111-
///
1112-
/// Because the payment failed outright, no payment tracking is done, you do not need to call
1113-
/// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
1114-
/// for this payment.
1115-
ParameterError(APIError),
1116-
/// A parameter in a single path which was passed to send_payment was invalid, preventing us
1117-
/// from attempting to send the payment at all.
1118-
///
1119-
/// You can freely resend the payment in full (with the parameter error fixed).
1120-
///
1121-
/// The results here are ordered the same as the paths in the route object which was passed to
1122-
/// send_payment.
1123-
///
1124-
/// Because the payment failed outright, no payment tracking is done, you do not need to call
1125-
/// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
1126-
/// for this payment.
1127-
PathParameterError(Vec<Result<(), APIError>>),
1128-
/// All paths which were attempted failed to send, with no channel state change taking place.
1129-
/// You can freely resend the payment in full (though you probably want to do so over different
1130-
/// paths than the ones selected).
1131-
///
1132-
/// Because the payment failed outright, no payment tracking is done, you do not need to call
1133-
/// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
1134-
/// for this payment.
1135-
AllFailedResendSafe(Vec<APIError>),
1136-
/// Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not
1137-
/// yet completed (i.e. generated an [`Event::PaymentSent`]) or been abandoned (via
1138-
/// [`ChannelManager::abandon_payment`]).
1139-
///
1140-
/// [`Event::PaymentSent`]: events::Event::PaymentSent
1141-
DuplicatePayment,
1142-
/// Some paths which were attempted failed to send, though possibly not all. At least some
1143-
/// paths have irrevocably committed to the HTLC and retrying the payment in full would result
1144-
/// in over-/re-payment.
1145-
///
1146-
/// The results here are ordered the same as the paths in the route object which was passed to
1147-
/// send_payment, and any `Err`s which are not [`APIError::MonitorUpdateInProgress`] can be
1148-
/// safely retried via [`ChannelManager::retry_payment`].
1149-
///
1150-
/// Any entries which contain `Err(APIError::MonitorUpdateInprogress)` or `Ok(())` MUST NOT be
1151-
/// retried as they will result in over-/re-payment. These HTLCs all either successfully sent
1152-
/// (in the case of `Ok(())`) or will send once a [`MonitorEvent::Completed`] is provided for
1153-
/// the next-hop channel with the latest update_id.
1154-
PartialFailure {
1155-
/// The errors themselves, in the same order as the route hops.
1156-
results: Vec<Result<(), APIError>>,
1157-
/// If some paths failed without irrevocably committing to the new HTLC(s), this will
1158-
/// contain a [`RouteParameters`] object which can be used to calculate a new route that
1159-
/// will pay all remaining unpaid balance.
1160-
failed_paths_retry: Option<RouteParameters>,
1161-
/// The payment id for the payment, which is now at least partially pending.
1162-
payment_id: PaymentId,
1163-
},
1164-
}
1165-
11661103
/// Route hints used in constructing invoices for [phantom node payents].
11671104
///
11681105
/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager

lightning/src/ln/outbound_payment.rs

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
//! Utilities to send payments and manage outbound payment information.
1111
1212
use crate::ln::{PaymentHash, PaymentSecret};
13+
use crate::ln::channelmanager::PaymentId;
1314
use crate::ln::msgs::DecodeError;
14-
use crate::routing::router::{RouteHop, RoutePath};
15+
use crate::routing::router::{RouteHop, RouteParameters, RoutePath};
16+
use crate::util::errors::APIError;
1517
use crate::prelude::*;
1618

1719
/// Stores the session_priv for each part of a payment that is still pending. For versions 0.0.102
@@ -168,6 +170,70 @@ impl PendingOutboundPayment {
168170
}
169171
}
170172

173+
/// If a payment fails to send, it can be in one of several states. This enum is returned as the
174+
/// Err() type describing which state the payment is in, see the description of individual enum
175+
/// states for more.
176+
#[derive(Clone, Debug)]
177+
pub enum PaymentSendFailure {
178+
/// A parameter which was passed to send_payment was invalid, preventing us from attempting to
179+
/// send the payment at all.
180+
///
181+
/// You can freely resend the payment in full (with the parameter error fixed).
182+
///
183+
/// Because the payment failed outright, no payment tracking is done, you do not need to call
184+
/// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
185+
/// for this payment.
186+
ParameterError(APIError),
187+
/// A parameter in a single path which was passed to send_payment was invalid, preventing us
188+
/// from attempting to send the payment at all.
189+
///
190+
/// You can freely resend the payment in full (with the parameter error fixed).
191+
///
192+
/// The results here are ordered the same as the paths in the route object which was passed to
193+
/// send_payment.
194+
///
195+
/// Because the payment failed outright, no payment tracking is done, you do not need to call
196+
/// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
197+
/// for this payment.
198+
PathParameterError(Vec<Result<(), APIError>>),
199+
/// All paths which were attempted failed to send, with no channel state change taking place.
200+
/// You can freely resend the payment in full (though you probably want to do so over different
201+
/// paths than the ones selected).
202+
///
203+
/// Because the payment failed outright, no payment tracking is done, you do not need to call
204+
/// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
205+
/// for this payment.
206+
AllFailedResendSafe(Vec<APIError>),
207+
/// Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not
208+
/// yet completed (i.e. generated an [`Event::PaymentSent`]) or been abandoned (via
209+
/// [`ChannelManager::abandon_payment`]).
210+
///
211+
/// [`Event::PaymentSent`]: events::Event::PaymentSent
212+
DuplicatePayment,
213+
/// Some paths which were attempted failed to send, though possibly not all. At least some
214+
/// paths have irrevocably committed to the HTLC and retrying the payment in full would result
215+
/// in over-/re-payment.
216+
///
217+
/// The results here are ordered the same as the paths in the route object which was passed to
218+
/// send_payment, and any `Err`s which are not [`APIError::MonitorUpdateInProgress`] can be
219+
/// safely retried via [`ChannelManager::retry_payment`].
220+
///
221+
/// Any entries which contain `Err(APIError::MonitorUpdateInprogress)` or `Ok(())` MUST NOT be
222+
/// retried as they will result in over-/re-payment. These HTLCs all either successfully sent
223+
/// (in the case of `Ok(())`) or will send once a [`MonitorEvent::Completed`] is provided for
224+
/// the next-hop channel with the latest update_id.
225+
PartialFailure {
226+
/// The errors themselves, in the same order as the route hops.
227+
results: Vec<Result<(), APIError>>,
228+
/// If some paths failed without irrevocably committing to the new HTLC(s), this will
229+
/// contain a [`RouteParameters`] object which can be used to calculate a new route that
230+
/// will pay all remaining unpaid balance.
231+
failed_paths_retry: Option<RouteParameters>,
232+
/// The payment id for the payment, which is now at least partially pending.
233+
payment_id: PaymentId,
234+
},
235+
}
236+
171237
impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
172238
(0, Legacy) => {
173239
(0, session_privs, required),

0 commit comments

Comments
 (0)