-pub enum PaymentSendFailure {
- /// A parameter which was passed to send_payment was invalid, preventing us from attempting to
- /// send the payment at all. No channel state has been changed or messages sent to peers, and
- /// once you've changed the parameter at error, you can freely retry the payment in full.
- ParameterError(crate::lightning::util::errors::APIError),
- /// A parameter in a single path which was passed to send_payment was invalid, preventing us
- /// from attempting to send the payment at all. No channel state has been changed or messages
- /// sent to peers, and once you've changed the parameter at error, you can freely retry the
- /// payment in full.
- ///
- /// The results here are ordered the same as the paths in the route object which was passed to
- /// send_payment.
- PathParameterError(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ),
- /// All paths which were attempted failed to send, with no channel state change taking place.
- /// You can freely retry the payment in full (though you probably want to do so over different
- /// paths than the ones selected).
- AllFailedRetrySafe(crate::c_types::derived::CVec_APIErrorZ),
- /// Some paths which were attempted failed to send, though possibly not all. At least some
- /// paths have irrevocably committed to the HTLC and retrying the payment in full would result
- /// in over-/re-payment.
- ///
- /// The results here are ordered the same as the paths in the route object which was passed to
- /// send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely
- /// retried (though there is currently no API with which to do so).
- ///
- /// Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried
- /// as they will result in over-/re-payment. These HTLCs all either successfully sent (in the
- /// case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel
- /// with the latest update_id.
- PartialFailure {
- /// The errors themselves, in the same order as the route hops.
- results: crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ,
- /// If some paths failed without irrevocably committing to the new HTLC(s), this will
- /// contain a [`RouteParameters`] object which can be used to calculate a new route that
- /// will pay all remaining unpaid balance.
- ///
- /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
- failed_paths_retry: crate::lightning::routing::router::RouteParameters,
- /// The payment id for the payment, which is now at least partially pending.
- payment_id: crate::c_types::ThirtyTwoBytes,
+pub enum ChannelShutdownState {
+ /// Channel has not sent or received a shutdown message.
+ NotShuttingDown,
+ /// Local node has sent a shutdown message for this channel.
+ ShutdownInitiated,
+ /// Shutdown message exchanges have concluded and the channels are in the midst of
+ /// resolving all existing open HTLCs before closing can continue.
+ ResolvingHTLCs,
+ /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates.
+ NegotiatingClosingFee,
+ /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about
+ /// to drop the channel.
+ ShutdownComplete,
+}
+use lightning::ln::channelmanager::ChannelShutdownState as ChannelShutdownStateImport;
+pub(crate) type nativeChannelShutdownState = ChannelShutdownStateImport;
+
+impl ChannelShutdownState {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeChannelShutdownState {
+ match self {
+ ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown,
+ ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated,
+ ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs,
+ ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee,
+ ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeChannelShutdownState {
+ match self {
+ ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown,
+ ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated,
+ ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs,
+ ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee,
+ ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeChannelShutdownState) -> Self {
+ match native {
+ nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown,
+ nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated,
+ nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs,
+ nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee,
+ nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeChannelShutdownState) -> Self {
+ match native {
+ nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown,
+ nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated,
+ nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs,
+ nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee,
+ nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete,
+ }
+ }
+}
+/// Creates a copy of the ChannelShutdownState
+#[no_mangle]
+pub extern "C" fn ChannelShutdownState_clone(orig: &ChannelShutdownState) -> ChannelShutdownState {
+ orig.clone()
+}
+#[no_mangle]
+/// Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState
+pub extern "C" fn ChannelShutdownState_not_shutting_down() -> ChannelShutdownState {
+ ChannelShutdownState::NotShuttingDown}
+#[no_mangle]
+/// Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState
+pub extern "C" fn ChannelShutdownState_shutdown_initiated() -> ChannelShutdownState {
+ ChannelShutdownState::ShutdownInitiated}
+#[no_mangle]
+/// Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState
+pub extern "C" fn ChannelShutdownState_resolving_htlcs() -> ChannelShutdownState {
+ ChannelShutdownState::ResolvingHTLCs}
+#[no_mangle]
+/// Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState
+pub extern "C" fn ChannelShutdownState_negotiating_closing_fee() -> ChannelShutdownState {
+ ChannelShutdownState::NegotiatingClosingFee}
+#[no_mangle]
+/// Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState
+pub extern "C" fn ChannelShutdownState_shutdown_complete() -> ChannelShutdownState {
+ ChannelShutdownState::ShutdownComplete}
+/// Checks if two ChannelShutdownStates contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn ChannelShutdownState_eq(a: &ChannelShutdownState, b: &ChannelShutdownState) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
+/// Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments.
+/// These include payments that have yet to find a successful path, or have unresolved HTLCs.
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum RecentPaymentDetails {
+ /// When a payment is still being sent and awaiting successful delivery.
+ Pending {
+ /// Hash of the payment that is currently being sent but has yet to be fulfilled or
+ /// abandoned.
+ payment_hash: crate::c_types::ThirtyTwoBytes,
+ /// Total amount (in msat, excluding fees) across all paths for this payment,
+ /// not just the amount currently inflight.
+ total_msat: u64,
+ },
+ /// When a pending payment is fulfilled, we continue tracking it until all pending HTLCs have
+ /// been resolved. Upon receiving [`Event::PaymentSent`], we delay for a few minutes before the
+ /// payment is removed from tracking.
+ Fulfilled {
+ /// Hash of the payment that was claimed. `None` for serializations of [`ChannelManager`]
+ /// made before LDK version 0.0.104.
+ payment_hash: crate::c_types::derived::COption_PaymentHashZ,
+ },
+ /// After a payment's retries are exhausted per the provided [`Retry`], or it is explicitly
+ /// abandoned via [`ChannelManager::abandon_payment`], it is marked as abandoned until all
+ /// pending HTLCs for this payment resolve and an [`Event::PaymentFailed`] is generated.
+ Abandoned {
+ /// Hash of the payment that we have given up trying to send.
+ payment_hash: crate::c_types::ThirtyTwoBytes,