+
+use lightning::events::ClaimedHTLC as nativeClaimedHTLCImport;
+pub(crate) type nativeClaimedHTLC = nativeClaimedHTLCImport;
+
+/// Information about an HTLC that is part of a payment that can be claimed.
+#[must_use]
+#[repr(C)]
+pub struct ClaimedHTLC {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeClaimedHTLC,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for ClaimedHTLC {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeClaimedHTLC>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ClaimedHTLC, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_free(this_obj: ClaimedHTLC) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ClaimedHTLC_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClaimedHTLC) };
+}
+#[allow(unused)]
+impl ClaimedHTLC {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeClaimedHTLC {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClaimedHTLC {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeClaimedHTLC {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The `channel_id` of the channel over which the HTLC was received.
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_get_channel_id(this_ptr: &ClaimedHTLC) -> *const [u8; 32] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
+ &inner_val.0
+}
+/// The `channel_id` of the channel over which the HTLC was received.
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_set_channel_id(this_ptr: &mut ClaimedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
+}
+/// The `user_channel_id` of the channel over which the HTLC was received. This is the value
+/// passed in to [`ChannelManager::create_channel`] for outbound channels, or to
+/// [`ChannelManager::accept_inbound_channel`] for inbound channels if
+/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
+/// `user_channel_id` will be randomized for an inbound channel.
+///
+/// This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
+/// should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
+/// was not actually claimed until after upgrading.)
+///
+/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_get_user_channel_id(this_ptr: &ClaimedHTLC) -> crate::c_types::U128 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().user_channel_id;
+ inner_val.into()
+}
+/// The `user_channel_id` of the channel over which the HTLC was received. This is the value
+/// passed in to [`ChannelManager::create_channel`] for outbound channels, or to
+/// [`ChannelManager::accept_inbound_channel`] for inbound channels if
+/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
+/// `user_channel_id` will be randomized for an inbound channel.
+///
+/// This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
+/// should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
+/// was not actually claimed until after upgrading.)
+///
+/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_set_user_channel_id(this_ptr: &mut ClaimedHTLC, mut val: crate::c_types::U128) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into();
+}
+/// The block height at which this HTLC expires.
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_get_cltv_expiry(this_ptr: &ClaimedHTLC) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
+ *inner_val
+}
+/// The block height at which this HTLC expires.
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_set_cltv_expiry(this_ptr: &mut ClaimedHTLC, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
+}
+/// The amount (in msats) of this part of an MPP.
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_get_value_msat(this_ptr: &ClaimedHTLC) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().value_msat;
+ *inner_val
+}
+/// The amount (in msats) of this part of an MPP.
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_set_value_msat(this_ptr: &mut ClaimedHTLC, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.value_msat = val;
+}
+/// Constructs a new ClaimedHTLC given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut user_channel_id_arg: crate::c_types::U128, mut cltv_expiry_arg: u32, mut value_msat_arg: u64) -> ClaimedHTLC {
+ ClaimedHTLC { inner: ObjOps::heap_alloc(nativeClaimedHTLC {
+ channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
+ user_channel_id: user_channel_id_arg.into(),
+ cltv_expiry: cltv_expiry_arg,
+ value_msat: value_msat_arg,
+ }), is_owned: true }
+}
+impl Clone for ClaimedHTLC {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeClaimedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ClaimedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClaimedHTLC)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the ClaimedHTLC
+pub extern "C" fn ClaimedHTLC_clone(orig: &ClaimedHTLC) -> ClaimedHTLC {
+ orig.clone()
+}
+/// Checks if two ClaimedHTLCs contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+/// Two objects with NULL inner values will be considered "equal" here.
+#[no_mangle]
+pub extern "C" fn ClaimedHTLC_eq(a: &ClaimedHTLC, b: &ClaimedHTLC) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if a.get_native_ref() == b.get_native_ref() { true } else { false }
+}
+#[no_mangle]
+/// Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read
+pub extern "C" fn ClaimedHTLC_write(obj: &crate::lightning::events::ClaimedHTLC) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn ClaimedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClaimedHTLC) })
+}
+#[no_mangle]
+/// Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write
+pub extern "C" fn ClaimedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClaimedHTLCDecodeErrorZ {
+ let res: Result<lightning::events::ClaimedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::ClaimedHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
+ local_res
+}