+pub struct UnsignedNodeAnnouncement {
+ /// 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 nativeUnsignedNodeAnnouncement,
+ /// 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 UnsignedNodeAnnouncement {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
+}
+#[allow(unused)]
+impl UnsignedNodeAnnouncement {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
+ 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 nativeUnsignedNodeAnnouncement {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The advertised features
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
+ crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false }
+}
+/// The advertised features
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// A strictly monotonic announcement counter, with gaps allowed
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
+ *inner_val
+}
+/// A strictly monotonic announcement counter, with gaps allowed
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
+}
+/// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
+/// to this node).
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
+ crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
+}
+/// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
+/// to this node).
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// An RGB color for UI purposes
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
+ inner_val
+}
+/// An RGB color for UI purposes
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
+}
+/// An alias, for UI purposes.
+///
+/// This should be sanitized before use. There is no guarantee of uniqueness.
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
+ crate::lightning::routing::gossip::NodeAlias { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeAlias<>) as *mut _) }, is_owned: false }
+}
+/// An alias, for UI purposes.
+///
+/// This should be sanitized before use. There is no guarantee of uniqueness.
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// List of addresses on which this node is reachable
+///
+/// Returns a copy of the field.
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
+ let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
+ let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); };
+ local_inner_val.into()
+}
+/// List of addresses on which this node is reachable
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
+}
+impl Clone for UnsignedNodeAnnouncement {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeUnsignedNodeAnnouncement>::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 UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the UnsignedNodeAnnouncement
+pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a UnsignedNodeAnnouncement object
+pub extern "C" fn UnsignedNodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedNodeAnnouncement }).into()}
+/// Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement.
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_hash(o: &UnsignedNodeAnnouncement) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two UnsignedNodeAnnouncements 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 UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> 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 }
+}
+
+use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
+pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
+
+/// A [`node_announcement`] message to be sent to or received from a peer.
+///
+/// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
+#[must_use]
+#[repr(C)]
+pub struct NodeAnnouncement {
+ /// 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 nativeNodeAnnouncement,
+ /// 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 NodeAnnouncement {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
+}
+#[allow(unused)]
+impl NodeAnnouncement {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
+ 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 nativeNodeAnnouncement {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The signature by the node key
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
+ crate::c_types::ECDSASignature::from_rust(&inner_val)
+}
+/// The signature by the node key
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
+}
+/// The actual content of the announcement
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
+ crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedNodeAnnouncement<>) as *mut _) }, is_owned: false }
+}
+/// The actual content of the announcement
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// Constructs a new NodeAnnouncement given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
+ NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
+ signature: signature_arg.into_rust(),
+ contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
+ }), is_owned: true }
+}
+impl Clone for NodeAnnouncement {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeNodeAnnouncement>::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 NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncement)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the NodeAnnouncement
+pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a NodeAnnouncement object
+pub extern "C" fn NodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::NodeAnnouncement }).into()}
+/// Generates a non-cryptographic 64-bit hash of the NodeAnnouncement.
+#[no_mangle]
+pub extern "C" fn NodeAnnouncement_hash(o: &NodeAnnouncement) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two NodeAnnouncements 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 NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> 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 }
+}
+
+use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
+pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
+
+/// The unsigned part of a [`channel_announcement`] message.
+///
+/// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
+#[must_use]
+#[repr(C)]
+pub struct UnsignedChannelAnnouncement {
+ /// 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 nativeUnsignedChannelAnnouncement,
+ /// 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 UnsignedChannelAnnouncement {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
+}
+#[allow(unused)]
+impl UnsignedChannelAnnouncement {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
+ 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 nativeUnsignedChannelAnnouncement {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The advertised channel features
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
+ crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false }
+}
+/// The advertised channel features
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The genesis hash of the blockchain where the channel is to be opened
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
+ inner_val.as_ref()
+}
+/// The genesis hash of the blockchain where the channel is to be opened
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
+}
+/// The short channel ID
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
+ *inner_val
+}
+/// The short channel ID
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
+}
+/// One of the two `node_id`s which are endpoints of this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
+ crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
+}
+/// One of the two `node_id`s which are endpoints of this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The other of the two `node_id`s which are endpoints of this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
+ crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
+}
+/// The other of the two `node_id`s which are endpoints of this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The funding key for the first node
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
+ crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
+}
+/// The funding key for the first node
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The funding key for the second node
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
+ crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
+}
+/// The funding key for the second node
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// Excess data which was signed as a part of the message which we do not (yet) understand how
+/// to decode.
+///
+/// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
+///
+/// Returns a copy of the field.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
+ let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
+ let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
+ local_inner_val.into()
+}
+/// Excess data which was signed as a part of the message which we do not (yet) understand how
+/// to decode.
+///
+/// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
+}
+/// Constructs a new UnsignedChannelAnnouncement given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_id_1_arg: crate::lightning::routing::gossip::NodeId, mut node_id_2_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_1_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_2_arg: crate::lightning::routing::gossip::NodeId, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelAnnouncement {
+ let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
+ UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
+ features: *unsafe { Box::from_raw(features_arg.take_inner()) },
+ chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
+ short_channel_id: short_channel_id_arg,
+ node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
+ node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
+ bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
+ bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
+ excess_data: local_excess_data_arg,
+ }), is_owned: true }
+}
+impl Clone for UnsignedChannelAnnouncement {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeUnsignedChannelAnnouncement>::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 UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the UnsignedChannelAnnouncement
+pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a UnsignedChannelAnnouncement object
+pub extern "C" fn UnsignedChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelAnnouncement }).into()}
+/// Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_hash(o: &UnsignedChannelAnnouncement) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two UnsignedChannelAnnouncements 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 UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> 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 }
+}
+
+use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
+pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
+
+/// A [`channel_announcement`] message to be sent to or received from a peer.
+///
+/// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
+#[must_use]
+#[repr(C)]
+pub struct ChannelAnnouncement {
+ /// 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 nativeChannelAnnouncement,
+ /// 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 ChannelAnnouncement {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
+}
+#[allow(unused)]
+impl ChannelAnnouncement {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
+ 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 nativeChannelAnnouncement {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// Authentication of the announcement by the first public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
+ crate::c_types::ECDSASignature::from_rust(&inner_val)
+}
+/// Authentication of the announcement by the first public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
+}
+/// Authentication of the announcement by the second public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
+ crate::c_types::ECDSASignature::from_rust(&inner_val)
+}
+/// Authentication of the announcement by the second public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
+}
+/// Proof of funding UTXO ownership by the first public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
+ crate::c_types::ECDSASignature::from_rust(&inner_val)
+}
+/// Proof of funding UTXO ownership by the first public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
+}
+/// Proof of funding UTXO ownership by the second public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
+ crate::c_types::ECDSASignature::from_rust(&inner_val)
+}
+/// Proof of funding UTXO ownership by the second public node
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
+}
+/// The actual announcement
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
+ crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }
+}
+/// The actual announcement
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// Constructs a new ChannelAnnouncement given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_types::ECDSASignature, mut node_signature_2_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_1_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_2_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
+ ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
+ node_signature_1: node_signature_1_arg.into_rust(),
+ node_signature_2: node_signature_2_arg.into_rust(),
+ bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
+ bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
+ contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
+ }), is_owned: true }
+}
+impl Clone for ChannelAnnouncement {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeChannelAnnouncement>::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 ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelAnnouncement)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the ChannelAnnouncement
+pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a ChannelAnnouncement object
+pub extern "C" fn ChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelAnnouncement }).into()}
+/// Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement.
+#[no_mangle]
+pub extern "C" fn ChannelAnnouncement_hash(o: &ChannelAnnouncement) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two ChannelAnnouncements 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 ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> 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 }
+}
+
+use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
+pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
+
+/// The unsigned part of a [`channel_update`] message.
+///
+/// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
+#[must_use]
+#[repr(C)]
+pub struct UnsignedChannelUpdate {
+ /// 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 nativeUnsignedChannelUpdate,
+ /// 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 UnsignedChannelUpdate {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
+}
+#[allow(unused)]
+impl UnsignedChannelUpdate {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
+ 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 nativeUnsignedChannelUpdate {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The genesis hash of the blockchain where the channel is to be opened
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
+ inner_val.as_ref()
+}
+/// The genesis hash of the blockchain where the channel is to be opened
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
+}
+/// The short channel ID
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
+ *inner_val
+}
+/// The short channel ID
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
+}
+/// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
+ *inner_val
+}
+/// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
+}
+/// Channel flags
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
+ *inner_val
+}
+/// Channel flags
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
+}
+/// The number of blocks such that if:
+/// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
+/// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
+/// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
+/// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
+/// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
+/// forwarding. Note that the HTLC sender is the one who originally sets this value when
+/// constructing the route.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
+ *inner_val
+}
+/// The number of blocks such that if:
+/// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
+/// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
+/// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
+/// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
+/// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
+/// forwarding. Note that the HTLC sender is the one who originally sets this value when
+/// constructing the route.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
+}
+/// The minimum HTLC size incoming to sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
+ *inner_val
+}
+/// The minimum HTLC size incoming to sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
+}
+/// The maximum HTLC value incoming to sender, in milli-satoshi.
+///
+/// This used to be optional.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
+ *inner_val
+}
+/// The maximum HTLC value incoming to sender, in milli-satoshi.
+///
+/// This used to be optional.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
+}
+/// The base HTLC fee charged by sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
+ *inner_val
+}
+/// The base HTLC fee charged by sender, in milli-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
+}
+/// The amount to fee multiplier, in micro-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
+ *inner_val
+}
+/// The amount to fee multiplier, in micro-satoshi
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
+}
+/// Excess data which was signed as a part of the message which we do not (yet) understand how
+/// to decode.
+///
+/// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
+///
+/// Returns a copy of the field.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
+ let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
+ let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
+ local_inner_val.into()
+}
+/// Excess data which was signed as a part of the message which we do not (yet) understand how
+/// to decode.
+///
+/// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
+}
+/// Constructs a new UnsignedChannelUpdate given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut timestamp_arg: u32, mut flags_arg: u8, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelUpdate {
+ let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
+ UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
+ chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
+ short_channel_id: short_channel_id_arg,
+ timestamp: timestamp_arg,
+ flags: flags_arg,
+ cltv_expiry_delta: cltv_expiry_delta_arg,
+ htlc_minimum_msat: htlc_minimum_msat_arg,
+ htlc_maximum_msat: htlc_maximum_msat_arg,
+ fee_base_msat: fee_base_msat_arg,
+ fee_proportional_millionths: fee_proportional_millionths_arg,
+ excess_data: local_excess_data_arg,
+ }), is_owned: true }
+}
+impl Clone for UnsignedChannelUpdate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeUnsignedChannelUpdate>::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 UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the UnsignedChannelUpdate
+pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a UnsignedChannelUpdate object
+pub extern "C" fn UnsignedChannelUpdate_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelUpdate }).into()}
+/// Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate.
+#[no_mangle]
+pub extern "C" fn UnsignedChannelUpdate_hash(o: &UnsignedChannelUpdate) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two UnsignedChannelUpdates 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 UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> 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 }
+}
+
+use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
+pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
+
+/// A [`channel_update`] message to be sent to or received from a peer.
+///
+/// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
+#[must_use]
+#[repr(C)]
+pub struct ChannelUpdate {
+ /// 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 nativeChannelUpdate,
+ /// 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 ChannelUpdate {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
+}
+#[allow(unused)]
+impl ChannelUpdate {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
+ 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 nativeChannelUpdate {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// A signature of the channel update
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
+ crate::c_types::ECDSASignature::from_rust(&inner_val)
+}
+/// A signature of the channel update
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
+}
+/// The actual channel update
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
+ crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedChannelUpdate<>) as *mut _) }, is_owned: false }
+}
+/// The actual channel update
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// Constructs a new ChannelUpdate given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
+ ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
+ signature: signature_arg.into_rust(),
+ contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
+ }), is_owned: true }
+}
+impl Clone for ChannelUpdate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeChannelUpdate>::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 ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelUpdate)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the ChannelUpdate
+pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a ChannelUpdate object
+pub extern "C" fn ChannelUpdate_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelUpdate }).into()}
+/// Generates a non-cryptographic 64-bit hash of the ChannelUpdate.
+#[no_mangle]
+pub extern "C" fn ChannelUpdate_hash(o: &ChannelUpdate) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two ChannelUpdates 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 ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> 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 }
+}
+
+use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
+pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
+
+/// A [`query_channel_range`] message is used to query a peer for channel
+/// UTXOs in a range of blocks. The recipient of a query makes a best
+/// effort to reply to the query using one or more [`ReplyChannelRange`]
+/// messages.
+///
+/// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
+#[must_use]
+#[repr(C)]
+pub struct QueryChannelRange {
+ /// 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 nativeQueryChannelRange,
+ /// 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 QueryChannelRange {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
+}
+#[allow(unused)]
+impl QueryChannelRange {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
+ 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 nativeQueryChannelRange {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The genesis hash of the blockchain being queried
+#[no_mangle]
+pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
+ inner_val.as_ref()
+}
+/// The genesis hash of the blockchain being queried
+#[no_mangle]
+pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
+}
+/// The height of the first block for the channel UTXOs being queried
+#[no_mangle]
+pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
+ *inner_val
+}
+/// The height of the first block for the channel UTXOs being queried
+#[no_mangle]
+pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
+}
+/// The number of blocks to include in the query results
+#[no_mangle]
+pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
+ *inner_val
+}
+/// The number of blocks to include in the query results
+#[no_mangle]
+pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
+}
+/// Constructs a new QueryChannelRange given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32) -> QueryChannelRange {
+ QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
+ chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
+ first_blocknum: first_blocknum_arg,
+ number_of_blocks: number_of_blocks_arg,
+ }), is_owned: true }
+}
+impl Clone for QueryChannelRange {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeQueryChannelRange>::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 QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryChannelRange)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the QueryChannelRange
+pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a QueryChannelRange object
+pub extern "C" fn QueryChannelRange_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryChannelRange }).into()}
+/// Generates a non-cryptographic 64-bit hash of the QueryChannelRange.
+#[no_mangle]
+pub extern "C" fn QueryChannelRange_hash(o: &QueryChannelRange) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two QueryChannelRanges 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 QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> 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 }
+}
+
+use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
+pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
+
+/// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
+/// message.
+///
+/// Multiple `reply_channel_range` messages can be sent in reply
+/// to a single [`QueryChannelRange`] message. The query recipient makes a
+/// best effort to respond based on their local network view which may
+/// not be a perfect view of the network. The `short_channel_id`s in the
+/// reply are encoded. We only support `encoding_type=0` uncompressed
+/// serialization and do not support `encoding_type=1` zlib serialization.
+///
+/// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
+#[must_use]
+#[repr(C)]
+pub struct ReplyChannelRange {
+ /// 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 nativeReplyChannelRange,
+ /// 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 ReplyChannelRange {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
+}
+#[allow(unused)]
+impl ReplyChannelRange {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
+ 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 nativeReplyChannelRange {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The genesis hash of the blockchain being queried
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
+ inner_val.as_ref()
+}
+/// The genesis hash of the blockchain being queried
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
+}
+/// The height of the first block in the range of the reply
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
+ *inner_val
+}
+/// The height of the first block in the range of the reply
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
+}
+/// The number of blocks included in the range of the reply
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
+ *inner_val
+}
+/// The number of blocks included in the range of the reply
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
+}
+/// True when this is the final reply for a query
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
+ *inner_val
+}
+/// True when this is the final reply for a query
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
+}
+/// The `short_channel_id`s in the channel range
+///
+/// Returns a copy of the field.
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
+ let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
+ let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
+ local_inner_val.into()
+}
+/// The `short_channel_id`s in the channel range
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
+}
+/// Constructs a new ReplyChannelRange given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut sync_complete_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange {
+ let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); };
+ ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
+ chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
+ first_blocknum: first_blocknum_arg,
+ number_of_blocks: number_of_blocks_arg,
+ sync_complete: sync_complete_arg,
+ short_channel_ids: local_short_channel_ids_arg,
+ }), is_owned: true }
+}
+impl Clone for ReplyChannelRange {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeReplyChannelRange>::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 ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyChannelRange)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the ReplyChannelRange
+pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a ReplyChannelRange object
+pub extern "C" fn ReplyChannelRange_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyChannelRange }).into()}
+/// Generates a non-cryptographic 64-bit hash of the ReplyChannelRange.
+#[no_mangle]
+pub extern "C" fn ReplyChannelRange_hash(o: &ReplyChannelRange) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two ReplyChannelRanges 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 ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> 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 }
+}
+
+use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
+pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
+
+/// A [`query_short_channel_ids`] message is used to query a peer for
+/// routing gossip messages related to one or more `short_channel_id`s.
+///
+/// The query recipient will reply with the latest, if available,
+/// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
+/// it maintains for the requested `short_channel_id`s followed by a
+/// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
+/// this query are encoded. We only support `encoding_type=0` uncompressed
+/// serialization and do not support `encoding_type=1` zlib serialization.
+///
+/// [`query_short_channel_ids`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
+#[must_use]
+#[repr(C)]
+pub struct QueryShortChannelIds {
+ /// 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 nativeQueryShortChannelIds,
+ /// 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 QueryShortChannelIds {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
+}
+#[allow(unused)]
+impl QueryShortChannelIds {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
+ 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 nativeQueryShortChannelIds {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The genesis hash of the blockchain being queried
+#[no_mangle]
+pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
+ inner_val.as_ref()
+}
+/// The genesis hash of the blockchain being queried
+#[no_mangle]
+pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
+}
+/// The short_channel_ids that are being queried
+///
+/// Returns a copy of the field.
+#[no_mangle]
+pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
+ let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
+ let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
+ local_inner_val.into()
+}
+/// The short_channel_ids that are being queried
+#[no_mangle]
+pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
+}
+/// Constructs a new QueryShortChannelIds given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> QueryShortChannelIds {
+ let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); };
+ QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
+ chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
+ short_channel_ids: local_short_channel_ids_arg,
+ }), is_owned: true }
+}
+impl Clone for QueryShortChannelIds {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeQueryShortChannelIds>::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 QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryShortChannelIds)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the QueryShortChannelIds
+pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a QueryShortChannelIds object
+pub extern "C" fn QueryShortChannelIds_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryShortChannelIds }).into()}
+/// Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds.
+#[no_mangle]
+pub extern "C" fn QueryShortChannelIds_hash(o: &QueryShortChannelIds) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two QueryShortChannelIdss 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 QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> 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 }
+}
+
+use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
+pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
+
+/// A [`reply_short_channel_ids_end`] message is sent as a reply to a
+/// message. The query recipient makes a best
+/// effort to respond based on their local network view which may not be
+/// a perfect view of the network.
+///
+/// [`reply_short_channel_ids_end`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
+#[must_use]
+#[repr(C)]
+pub struct ReplyShortChannelIdsEnd {
+ /// 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 nativeReplyShortChannelIdsEnd,
+ /// 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 ReplyShortChannelIdsEnd {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
+}
+#[allow(unused)]
+impl ReplyShortChannelIdsEnd {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
+ 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 nativeReplyShortChannelIdsEnd {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The genesis hash of the blockchain that was queried
+#[no_mangle]
+pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
+ inner_val.as_ref()
+}
+/// The genesis hash of the blockchain that was queried
+#[no_mangle]
+pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
+}
+/// Indicates if the query recipient maintains up-to-date channel
+/// information for the `chain_hash`
+#[no_mangle]
+pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
+ *inner_val
+}
+/// Indicates if the query recipient maintains up-to-date channel
+/// information for the `chain_hash`
+#[no_mangle]
+pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
+}
+/// Constructs a new ReplyShortChannelIdsEnd given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
+ ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
+ chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
+ full_information: full_information_arg,
+ }), is_owned: true }
+}
+impl Clone for ReplyShortChannelIdsEnd {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeReplyShortChannelIdsEnd>::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 ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the ReplyShortChannelIdsEnd
+pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a ReplyShortChannelIdsEnd object
+pub extern "C" fn ReplyShortChannelIdsEnd_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyShortChannelIdsEnd }).into()}
+/// Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd.
+#[no_mangle]
+pub extern "C" fn ReplyShortChannelIdsEnd_hash(o: &ReplyShortChannelIdsEnd) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two ReplyShortChannelIdsEnds 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 ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> 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 }
+}
+
+use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
+pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
+
+/// A [`gossip_timestamp_filter`] message is used by a node to request
+/// gossip relay for messages in the requested time range when the
+/// `gossip_queries` feature has been negotiated.
+///
+/// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
+#[must_use]
+#[repr(C)]
+pub struct GossipTimestampFilter {
+ /// 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 nativeGossipTimestampFilter,
+ /// 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 GossipTimestampFilter {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
+}
+#[allow(unused)]
+impl GossipTimestampFilter {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
+ 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 nativeGossipTimestampFilter {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The genesis hash of the blockchain for channel and node information
+#[no_mangle]
+pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
+ inner_val.as_ref()
+}
+/// The genesis hash of the blockchain for channel and node information
+#[no_mangle]
+pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
+}
+/// The starting unix timestamp
+#[no_mangle]
+pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
+ *inner_val
+}
+/// The starting unix timestamp
+#[no_mangle]
+pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
+}
+/// The range of information in seconds
+#[no_mangle]
+pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
+ *inner_val
+}
+/// The range of information in seconds
+#[no_mangle]
+pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
+}
+/// Constructs a new GossipTimestampFilter given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_timestamp_arg: u32, mut timestamp_range_arg: u32) -> GossipTimestampFilter {
+ GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
+ chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
+ first_timestamp: first_timestamp_arg,
+ timestamp_range: timestamp_range_arg,
+ }), is_owned: true }
+}
+impl Clone for GossipTimestampFilter {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeGossipTimestampFilter>::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 GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeGossipTimestampFilter)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the GossipTimestampFilter
+pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a GossipTimestampFilter object
+pub extern "C" fn GossipTimestampFilter_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::GossipTimestampFilter }).into()}
+/// Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter.
+#[no_mangle]
+pub extern "C" fn GossipTimestampFilter_hash(o: &GossipTimestampFilter) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two GossipTimestampFilters 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 GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> 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 }
+}
+/// Used to put an error message in a [`LightningError`].
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum ErrorAction {
+ /// The peer took some action which made us think they were useless. Disconnect them.
+ DisconnectPeer {
+ /// An error message which we should make an effort to send before we disconnect.
+ ///
+ /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ msg: crate::lightning::ln::msgs::ErrorMessage,
+ },
+ /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
+ DisconnectPeerWithWarning {
+ /// A warning message which we should make an effort to send before we disconnect.
+ msg: crate::lightning::ln::msgs::WarningMessage,
+ },
+ /// The peer did something harmless that we weren't able to process, just log and ignore
+ IgnoreError,
+ /// The peer did something harmless that we weren't able to meaningfully process.
+ /// If the error is logged, log it at the given level.
+ IgnoreAndLog(
+ crate::lightning::util::logger::Level),
+ /// The peer provided us with a gossip message which we'd already seen. In most cases this
+ /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
+ /// our own channel announcements.
+ IgnoreDuplicateGossip,
+ /// The peer did something incorrect. Tell them.
+ SendErrorMessage {
+ /// The message to send.
+ msg: crate::lightning::ln::msgs::ErrorMessage,
+ },
+ /// The peer did something incorrect. Tell them without closing any channels.
+ SendWarningMessage {
+ /// The message to send.
+ msg: crate::lightning::ln::msgs::WarningMessage,
+ /// The peer may have done something harmless that we weren't able to meaningfully process,
+ /// though we should still tell them about it.
+ /// If this event is logged, log it at the given level.
+ log_level: crate::lightning::util::logger::Level,
+ },
+}
+use lightning::ln::msgs::ErrorAction as ErrorActionImport;
+pub(crate) type nativeErrorAction = ErrorActionImport;
+
+impl ErrorAction {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeErrorAction {
+ match self {
+ ErrorAction::DisconnectPeer {ref msg, } => {
+ let mut msg_nonref = Clone::clone(msg);
+ let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
+ nativeErrorAction::DisconnectPeer {
+ msg: local_msg_nonref,
+ }
+ },
+ ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
+ let mut msg_nonref = Clone::clone(msg);
+ nativeErrorAction::DisconnectPeerWithWarning {
+ msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
+ }
+ },
+ ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
+ ErrorAction::IgnoreAndLog (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ nativeErrorAction::IgnoreAndLog (
+ a_nonref.into_native(),
+ )
+ },
+ ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
+ ErrorAction::SendErrorMessage {ref msg, } => {
+ let mut msg_nonref = Clone::clone(msg);
+ nativeErrorAction::SendErrorMessage {
+ msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
+ }
+ },
+ ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
+ let mut msg_nonref = Clone::clone(msg);
+ let mut log_level_nonref = Clone::clone(log_level);
+ nativeErrorAction::SendWarningMessage {
+ msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
+ log_level: log_level_nonref.into_native(),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeErrorAction {
+ match self {
+ ErrorAction::DisconnectPeer {mut msg, } => {
+ let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
+ nativeErrorAction::DisconnectPeer {
+ msg: local_msg,
+ }
+ },
+ ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
+ nativeErrorAction::DisconnectPeerWithWarning {
+ msg: *unsafe { Box::from_raw(msg.take_inner()) },
+ }
+ },
+ ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
+ ErrorAction::IgnoreAndLog (mut a, ) => {
+ nativeErrorAction::IgnoreAndLog (
+ a.into_native(),
+ )
+ },
+ ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
+ ErrorAction::SendErrorMessage {mut msg, } => {
+ nativeErrorAction::SendErrorMessage {
+ msg: *unsafe { Box::from_raw(msg.take_inner()) },
+ }
+ },
+ ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
+ nativeErrorAction::SendWarningMessage {
+ msg: *unsafe { Box::from_raw(msg.take_inner()) },
+ log_level: log_level.into_native(),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &ErrorActionImport) -> Self {
+ let native = unsafe { &*(native as *const _ as *const c_void as *const nativeErrorAction) };
+ match native {
+ nativeErrorAction::DisconnectPeer {ref msg, } => {
+ let mut msg_nonref = Clone::clone(msg);
+ let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true };
+ ErrorAction::DisconnectPeer {
+ msg: local_msg_nonref,
+ }
+ },
+ nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
+ let mut msg_nonref = Clone::clone(msg);
+ ErrorAction::DisconnectPeerWithWarning {
+ msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+ }
+ },
+ nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
+ nativeErrorAction::IgnoreAndLog (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ ErrorAction::IgnoreAndLog (
+ crate::lightning::util::logger::Level::native_into(a_nonref),
+ )
+ },
+ nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
+ nativeErrorAction::SendErrorMessage {ref msg, } => {
+ let mut msg_nonref = Clone::clone(msg);
+ ErrorAction::SendErrorMessage {
+ msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+ }
+ },
+ nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
+ let mut msg_nonref = Clone::clone(msg);
+ let mut log_level_nonref = Clone::clone(log_level);
+ ErrorAction::SendWarningMessage {
+ msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+ log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeErrorAction) -> Self {
+ match native {
+ nativeErrorAction::DisconnectPeer {mut msg, } => {
+ let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true };
+ ErrorAction::DisconnectPeer {
+ msg: local_msg,
+ }
+ },
+ nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
+ ErrorAction::DisconnectPeerWithWarning {
+ msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
+ }
+ },
+ nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
+ nativeErrorAction::IgnoreAndLog (mut a, ) => {
+ ErrorAction::IgnoreAndLog (
+ crate::lightning::util::logger::Level::native_into(a),
+ )
+ },
+ nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
+ nativeErrorAction::SendErrorMessage {mut msg, } => {
+ ErrorAction::SendErrorMessage {
+ msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
+ }
+ },
+ nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
+ ErrorAction::SendWarningMessage {
+ msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
+ log_level: crate::lightning::util::logger::Level::native_into(log_level),
+ }
+ },
+ }
+ }
+}
+/// Frees any resources used by the ErrorAction
+#[no_mangle]
+pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
+/// Creates a copy of the ErrorAction
+#[no_mangle]
+pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
+ 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 ErrorAction_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ErrorAction)).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 ErrorAction_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut ErrorAction) };
+}
+#[no_mangle]
+/// Utility method to constructs a new DisconnectPeer-variant ErrorAction
+pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
+ ErrorAction::DisconnectPeer {
+ msg,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
+pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
+ ErrorAction::DisconnectPeerWithWarning {
+ msg,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new IgnoreError-variant ErrorAction
+pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
+ ErrorAction::IgnoreError}
+#[no_mangle]
+/// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
+pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
+ ErrorAction::IgnoreAndLog(a, )
+}
+#[no_mangle]
+/// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
+pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
+ ErrorAction::IgnoreDuplicateGossip}
+#[no_mangle]
+/// Utility method to constructs a new SendErrorMessage-variant ErrorAction
+pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
+ ErrorAction::SendErrorMessage {
+ msg,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new SendWarningMessage-variant ErrorAction
+pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
+ ErrorAction::SendWarningMessage {
+ msg,
+ log_level,
+ }
+}
+/// Get a string which allows debug introspection of a ErrorAction object
+pub extern "C" fn ErrorAction_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorAction }).into()}
+/// Generates a non-cryptographic 64-bit hash of the ErrorAction.
+#[no_mangle]
+pub extern "C" fn ErrorAction_hash(o: &ErrorAction) -> u64 {
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(&o.to_native(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+
+use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
+pub(crate) type nativeLightningError = nativeLightningErrorImport;
+
+/// An Err type for failure to process messages.
+#[must_use]
+#[repr(C)]
+pub struct LightningError {
+ /// 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 nativeLightningError,
+ /// 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 LightningError {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn LightningError_free(this_obj: LightningError) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
+}
+#[allow(unused)]
+impl LightningError {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
+ 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 nativeLightningError {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// A human-readable message describing the error
+#[no_mangle]
+pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
+ inner_val.as_str().into()
+}
+/// A human-readable message describing the error
+#[no_mangle]
+pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
+}
+/// The action which should be taken against the offending peer.
+#[no_mangle]
+pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
+ crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
+}
+/// The action which should be taken against the offending peer.
+#[no_mangle]
+pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
+}
+/// Constructs a new LightningError given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
+ LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
+ err: err_arg.into_string(),
+ action: action_arg.into_native(),
+ }), is_owned: true }
+}
+impl Clone for LightningError {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeLightningError>::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 LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLightningError)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the LightningError
+pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a LightningError object
+pub extern "C" fn LightningError_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::LightningError }).into()}
+
+use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
+pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
+
+/// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
+/// transaction updates if they were pending.
+#[must_use]
+#[repr(C)]
+pub struct CommitmentUpdate {
+ /// 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 nativeCommitmentUpdate,
+ /// 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 CommitmentUpdate {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
+}
+#[allow(unused)]
+impl CommitmentUpdate {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
+ 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 nativeCommitmentUpdate {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// `update_add_htlc` messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
+ let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false } }); };
+ local_inner_val.into()
+}
+/// `update_add_htlc` messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
+}
+/// `update_fulfill_htlc` messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
+ let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false } }); };
+ local_inner_val.into()
+}
+/// `update_fulfill_htlc` messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
+}
+/// `update_fail_htlc` messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
+ let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false } }); };
+ local_inner_val.into()
+}
+/// `update_fail_htlc` messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
+}
+/// `update_fail_malformed_htlc` messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
+ let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false } }); };
+ local_inner_val.into()
+}
+/// `update_fail_malformed_htlc` messages which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
+}
+/// An `update_fee` message which should be sent
+///
+/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
+ let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::UpdateFee<>) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// An `update_fee` message which should be sent
+///
+/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
+}
+/// A `commitment_signed` message which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
+ crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false }
+}
+/// A `commitment_signed` message which should be sent
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// Constructs a new CommitmentUpdate given each field
+///
+/// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[must_use]
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_new(mut update_add_htlcs_arg: crate::c_types::derived::CVec_UpdateAddHTLCZ, mut update_fulfill_htlcs_arg: crate::c_types::derived::CVec_UpdateFulfillHTLCZ, mut update_fail_htlcs_arg: crate::c_types::derived::CVec_UpdateFailHTLCZ, mut update_fail_malformed_htlcs_arg: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ, mut update_fee_arg: crate::lightning::ln::msgs::UpdateFee, mut commitment_signed_arg: crate::lightning::ln::msgs::CommitmentSigned) -> CommitmentUpdate {
+ let mut local_update_add_htlcs_arg = Vec::new(); for mut item in update_add_htlcs_arg.into_rust().drain(..) { local_update_add_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut local_update_fulfill_htlcs_arg = Vec::new(); for mut item in update_fulfill_htlcs_arg.into_rust().drain(..) { local_update_fulfill_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut local_update_fail_htlcs_arg = Vec::new(); for mut item in update_fail_htlcs_arg.into_rust().drain(..) { local_update_fail_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut local_update_fail_malformed_htlcs_arg = Vec::new(); for mut item in update_fail_malformed_htlcs_arg.into_rust().drain(..) { local_update_fail_malformed_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_inner()) } }) };
+ CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
+ update_add_htlcs: local_update_add_htlcs_arg,
+ update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
+ update_fail_htlcs: local_update_fail_htlcs_arg,
+ update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
+ update_fee: local_update_fee_arg,
+ commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
+ }), is_owned: true }
+}
+impl Clone for CommitmentUpdate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeCommitmentUpdate>::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 CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentUpdate)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the CommitmentUpdate
+pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a CommitmentUpdate object
+pub extern "C" fn CommitmentUpdate_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentUpdate }).into()}
+/// Generates a non-cryptographic 64-bit hash of the CommitmentUpdate.
+#[no_mangle]
+pub extern "C" fn CommitmentUpdate_hash(o: &CommitmentUpdate) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two CommitmentUpdates 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 CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> 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 }
+}
+/// A trait to describe an object which can receive channel messages.
+///
+/// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
+/// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
+#[repr(C)]
+pub struct ChannelMessageHandler {
+ /// An opaque pointer which is passed to your function implementations as an argument.
+ /// This has no meaning in the LDK, and can be NULL or any other value.