+ 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()
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelShutdownState_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ChannelShutdownState)).clone() })) as *mut c_void
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelShutdownState_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut ChannelShutdownState) };
+}
+#[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 an invoice was requested and thus a payment has not yet been sent.
+ AwaitingInvoice {
+ /// A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
+ /// a payment and ensure idempotency in LDK.
+ payment_id: crate::c_types::ThirtyTwoBytes,
+ },
+ /// When a payment is still being sent and awaiting successful delivery.
+ Pending {
+ /// A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
+ /// a payment and ensure idempotency in LDK.
+ payment_id: crate::c_types::ThirtyTwoBytes,
+ /// 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 {
+ /// A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
+ /// a payment and ensure idempotency in LDK.
+ payment_id: crate::c_types::ThirtyTwoBytes,
+ /// 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_ThirtyTwoBytesZ,
+ },
+ /// 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 {
+ /// A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
+ /// a payment and ensure idempotency in LDK.
+ payment_id: crate::c_types::ThirtyTwoBytes,
+ /// Hash of the payment that we have given up trying to send.
+ payment_hash: crate::c_types::ThirtyTwoBytes,
+ },
+}
+use lightning::ln::channelmanager::RecentPaymentDetails as RecentPaymentDetailsImport;
+pub(crate) type nativeRecentPaymentDetails = RecentPaymentDetailsImport;
+
+impl RecentPaymentDetails {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeRecentPaymentDetails {
+ match self {
+ RecentPaymentDetails::AwaitingInvoice {ref payment_id, } => {
+ let mut payment_id_nonref = Clone::clone(payment_id);
+ nativeRecentPaymentDetails::AwaitingInvoice {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
+ }
+ },
+ RecentPaymentDetails::Pending {ref payment_id, ref payment_hash, ref total_msat, } => {
+ let mut payment_id_nonref = Clone::clone(payment_id);
+ let mut payment_hash_nonref = Clone::clone(payment_hash);
+ let mut total_msat_nonref = Clone::clone(total_msat);
+ nativeRecentPaymentDetails::Pending {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
+ total_msat: total_msat_nonref,
+ }
+ },
+ RecentPaymentDetails::Fulfilled {ref payment_id, ref payment_hash, } => {
+ let mut payment_id_nonref = Clone::clone(payment_id);
+ let mut payment_hash_nonref = Clone::clone(payment_hash);
+ let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} };
+ nativeRecentPaymentDetails::Fulfilled {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
+ payment_hash: local_payment_hash_nonref,
+ }
+ },
+ RecentPaymentDetails::Abandoned {ref payment_id, ref payment_hash, } => {
+ let mut payment_id_nonref = Clone::clone(payment_id);
+ let mut payment_hash_nonref = Clone::clone(payment_hash);
+ nativeRecentPaymentDetails::Abandoned {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeRecentPaymentDetails {
+ match self {
+ RecentPaymentDetails::AwaitingInvoice {mut payment_id, } => {
+ nativeRecentPaymentDetails::AwaitingInvoice {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
+ }
+ },
+ RecentPaymentDetails::Pending {mut payment_id, mut payment_hash, mut total_msat, } => {
+ nativeRecentPaymentDetails::Pending {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
+ total_msat: total_msat,
+ }
+ },
+ RecentPaymentDetails::Fulfilled {mut payment_id, mut payment_hash, } => {
+ let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} };
+ nativeRecentPaymentDetails::Fulfilled {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
+ payment_hash: local_payment_hash,
+ }
+ },
+ RecentPaymentDetails::Abandoned {mut payment_id, mut payment_hash, } => {
+ nativeRecentPaymentDetails::Abandoned {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeRecentPaymentDetails) -> Self {
+ match native {
+ nativeRecentPaymentDetails::AwaitingInvoice {ref payment_id, } => {
+ let mut payment_id_nonref = Clone::clone(payment_id);
+ RecentPaymentDetails::AwaitingInvoice {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
+ }
+ },
+ nativeRecentPaymentDetails::Pending {ref payment_id, ref payment_hash, ref total_msat, } => {
+ let mut payment_id_nonref = Clone::clone(payment_id);
+ let mut payment_hash_nonref = Clone::clone(payment_hash);
+ let mut total_msat_nonref = Clone::clone(total_msat);
+ RecentPaymentDetails::Pending {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
+ total_msat: total_msat_nonref,
+ }
+ },
+ nativeRecentPaymentDetails::Fulfilled {ref payment_id, ref payment_hash, } => {
+ let mut payment_id_nonref = Clone::clone(payment_id);
+ let mut payment_hash_nonref = Clone::clone(payment_hash);
+ let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.unwrap().0 } }) };
+ RecentPaymentDetails::Fulfilled {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
+ payment_hash: local_payment_hash_nonref,
+ }
+ },
+ nativeRecentPaymentDetails::Abandoned {ref payment_id, ref payment_hash, } => {
+ let mut payment_id_nonref = Clone::clone(payment_id);
+ let mut payment_hash_nonref = Clone::clone(payment_hash);
+ RecentPaymentDetails::Abandoned {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeRecentPaymentDetails) -> Self {
+ match native {
+ nativeRecentPaymentDetails::AwaitingInvoice {mut payment_id, } => {
+ RecentPaymentDetails::AwaitingInvoice {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
+ }
+ },
+ nativeRecentPaymentDetails::Pending {mut payment_id, mut payment_hash, mut total_msat, } => {
+ RecentPaymentDetails::Pending {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
+ total_msat: total_msat,
+ }
+ },
+ nativeRecentPaymentDetails::Fulfilled {mut payment_id, mut payment_hash, } => {
+ let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash.unwrap().0 } }) };
+ RecentPaymentDetails::Fulfilled {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
+ payment_hash: local_payment_hash,
+ }
+ },
+ nativeRecentPaymentDetails::Abandoned {mut payment_id, mut payment_hash, } => {
+ RecentPaymentDetails::Abandoned {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
+ }