Pin compiler_builtins to 0.1.109 when building std
[ldk-c-bindings] / lightning-c-bindings / src / lightning / ln / msgs.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Wire messages, traits representing wire message handlers, and a few error types live here.
10 //!
11 //! For a normal node you probably don't need to use anything here, however, if you wish to split a
12 //! node into an internet-facing route/message socket handling daemon and a separate daemon (or
13 //! server entirely) which handles only channel-related messages you may wish to implement
14 //! [`ChannelMessageHandler`] yourself and use it to re-serialize messages and pass them across
15 //! daemons/servers.
16 //!
17 //! Note that if you go with such an architecture (instead of passing raw socket events to a
18 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
19 //! source `node_id` of the message, however this does allow you to significantly reduce bandwidth
20 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
21 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
22 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
23 //! raw socket events into your non-internet-facing system and then send routing events back to
24 //! track the network on the less-secure system.
25
26 use alloc::str::FromStr;
27 use alloc::string::String;
28 use core::ffi::c_void;
29 use core::convert::Infallible;
30 use bitcoin::hashes::Hash;
31 use crate::c_types::*;
32 #[cfg(feature="no-std")]
33 use alloc::{vec::Vec, boxed::Box};
34
35 /// An error in decoding a message or struct.
36 #[derive(Clone)]
37 #[must_use]
38 #[repr(C)]
39 pub enum DecodeError {
40         /// A version byte specified something we don't know how to handle.
41         ///
42         /// Includes unknown realm byte in an onion hop data packet.
43         UnknownVersion,
44         /// Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type)
45         UnknownRequiredFeature,
46         /// Value was invalid.
47         ///
48         /// For example, a byte which was supposed to be a bool was something other than a 0
49         /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
50         /// syntactically incorrect, etc.
51         InvalidValue,
52         /// The buffer to be read was too short.
53         ShortRead,
54         /// A length descriptor in the packet didn't describe the later data correctly.
55         BadLengthDescriptor,
56         /// Error from [`std::io`].
57         Io(
58                 crate::c_types::IOError),
59         /// The message included zlib-compressed values, which we don't support.
60         UnsupportedCompression,
61         /// Value is validly encoded but is dangerous to use.
62         ///
63         /// This is used for things like [`ChannelManager`] deserialization where we want to ensure
64         /// that we don't use a [`ChannelManager`] which is in out of sync with the [`ChannelMonitor`].
65         /// This indicates that there is a critical implementation flaw in the storage implementation
66         /// and it's unsafe to continue.
67         ///
68         /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
69         /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
70         DangerousValue,
71 }
72 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
73 pub(crate) type nativeDecodeError = DecodeErrorImport;
74
75 impl DecodeError {
76         #[allow(unused)]
77         pub(crate) fn to_native(&self) -> nativeDecodeError {
78                 match self {
79                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
80                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
81                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
82                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
83                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
84                         DecodeError::Io (ref a, ) => {
85                                 let mut a_nonref = Clone::clone(a);
86                                 nativeDecodeError::Io (
87                                         a_nonref.to_rust_kind(),
88                                 )
89                         },
90                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
91                         DecodeError::DangerousValue => nativeDecodeError::DangerousValue,
92                 }
93         }
94         #[allow(unused)]
95         pub(crate) fn into_native(self) -> nativeDecodeError {
96                 match self {
97                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
98                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
99                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
100                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
101                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
102                         DecodeError::Io (mut a, ) => {
103                                 nativeDecodeError::Io (
104                                         a.to_rust_kind(),
105                                 )
106                         },
107                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
108                         DecodeError::DangerousValue => nativeDecodeError::DangerousValue,
109                 }
110         }
111         #[allow(unused)]
112         pub(crate) fn from_native(native: &DecodeErrorImport) -> Self {
113                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeDecodeError) };
114                 match native {
115                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
116                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
117                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
118                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
119                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
120                         nativeDecodeError::Io (ref a, ) => {
121                                 let mut a_nonref = Clone::clone(a);
122                                 DecodeError::Io (
123                                         crate::c_types::IOError::from_rust_kind(a_nonref),
124                                 )
125                         },
126                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
127                         nativeDecodeError::DangerousValue => DecodeError::DangerousValue,
128                 }
129         }
130         #[allow(unused)]
131         pub(crate) fn native_into(native: nativeDecodeError) -> Self {
132                 match native {
133                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
134                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
135                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
136                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
137                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
138                         nativeDecodeError::Io (mut a, ) => {
139                                 DecodeError::Io (
140                                         crate::c_types::IOError::from_rust_kind(a),
141                                 )
142                         },
143                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
144                         nativeDecodeError::DangerousValue => DecodeError::DangerousValue,
145                 }
146         }
147 }
148 /// Frees any resources used by the DecodeError
149 #[no_mangle]
150 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
151 /// Creates a copy of the DecodeError
152 #[no_mangle]
153 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
154         orig.clone()
155 }
156 #[allow(unused)]
157 /// Used only if an object of this type is returned as a trait impl by a method
158 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
159         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const DecodeError)).clone() })) as *mut c_void
160 }
161 #[allow(unused)]
162 /// Used only if an object of this type is returned as a trait impl by a method
163 pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
164         let _ = unsafe { Box::from_raw(this_ptr as *mut DecodeError) };
165 }
166 #[no_mangle]
167 /// Utility method to constructs a new UnknownVersion-variant DecodeError
168 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
169         DecodeError::UnknownVersion}
170 #[no_mangle]
171 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
172 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
173         DecodeError::UnknownRequiredFeature}
174 #[no_mangle]
175 /// Utility method to constructs a new InvalidValue-variant DecodeError
176 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
177         DecodeError::InvalidValue}
178 #[no_mangle]
179 /// Utility method to constructs a new ShortRead-variant DecodeError
180 pub extern "C" fn DecodeError_short_read() -> DecodeError {
181         DecodeError::ShortRead}
182 #[no_mangle]
183 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
184 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
185         DecodeError::BadLengthDescriptor}
186 #[no_mangle]
187 /// Utility method to constructs a new Io-variant DecodeError
188 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
189         DecodeError::Io(a, )
190 }
191 #[no_mangle]
192 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
193 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
194         DecodeError::UnsupportedCompression}
195 #[no_mangle]
196 /// Utility method to constructs a new DangerousValue-variant DecodeError
197 pub extern "C" fn DecodeError_dangerous_value() -> DecodeError {
198         DecodeError::DangerousValue}
199 /// Get a string which allows debug introspection of a DecodeError object
200 pub extern "C" fn DecodeError_debug_str_void(o: *const c_void) -> Str {
201         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::DecodeError }).into()}
202 /// Generates a non-cryptographic 64-bit hash of the DecodeError.
203 #[no_mangle]
204 pub extern "C" fn DecodeError_hash(o: &DecodeError) -> u64 {
205         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
206         #[allow(deprecated)]
207         let mut hasher = core::hash::SipHasher::new();
208         core::hash::Hash::hash(&o.to_native(), &mut hasher);
209         core::hash::Hasher::finish(&hasher)
210 }
211 /// Checks if two DecodeErrors contain equal inner contents.
212 /// This ignores pointers and is_owned flags and looks at the values in fields.
213 #[no_mangle]
214 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
215         if &a.to_native() == &b.to_native() { true } else { false }
216 }
217
218 use lightning::ln::msgs::Init as nativeInitImport;
219 pub(crate) type nativeInit = nativeInitImport;
220
221 /// An [`init`] message to be sent to or received from a peer.
222 ///
223 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
224 #[must_use]
225 #[repr(C)]
226 pub struct Init {
227         /// A pointer to the opaque Rust object.
228
229         /// Nearly everywhere, inner must be non-null, however in places where
230         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
231         pub inner: *mut nativeInit,
232         /// Indicates that this is the only struct which contains the same pointer.
233
234         /// Rust functions which take ownership of an object provided via an argument require
235         /// this to be true and invalidate the object pointed to by inner.
236         pub is_owned: bool,
237 }
238
239 impl Drop for Init {
240         fn drop(&mut self) {
241                 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
242                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
243                 }
244         }
245 }
246 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
247 #[no_mangle]
248 pub extern "C" fn Init_free(this_obj: Init) { }
249 #[allow(unused)]
250 /// Used only if an object of this type is returned as a trait impl by a method
251 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
252         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
253 }
254 #[allow(unused)]
255 impl Init {
256         pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
257                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
258         }
259         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
260                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
261         }
262         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
263         pub(crate) fn take_inner(mut self) -> *mut nativeInit {
264                 assert!(self.is_owned);
265                 let ret = ObjOps::untweak_ptr(self.inner);
266                 self.inner = core::ptr::null_mut();
267                 ret
268         }
269 }
270 /// The relevant features which the sender supports.
271 #[no_mangle]
272 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
273         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
274         crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }
275 }
276 /// The relevant features which the sender supports.
277 #[no_mangle]
278 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
279         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
280 }
281 /// Indicates chains the sender is interested in.
282 ///
283 /// If there are no common chains, the connection will be closed.
284 ///
285 /// Returns a copy of the field.
286 #[no_mangle]
287 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
288         let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
289         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); }; local_inner_val_0.into() }) };
290         local_inner_val
291 }
292 /// Indicates chains the sender is interested in.
293 ///
294 /// If there are no common chains, the connection will be closed.
295 #[no_mangle]
296 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ) {
297         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_val_0 }})} };
298         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
299 }
300 /// The receipient's network address.
301 ///
302 /// This adds the option to report a remote IP address back to a connecting peer using the init
303 /// message. A node can decide to use that information to discover a potential update to its
304 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
305 /// the new address.
306 #[no_mangle]
307 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_SocketAddressZ {
308         let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
309         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_SocketAddressZ::None } else { crate::c_types::derived::COption_SocketAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::msgs::SocketAddress::native_into((*inner_val.as_ref().unwrap()).clone()) }) };
310         local_inner_val
311 }
312 /// The receipient's network address.
313 ///
314 /// This adds the option to report a remote IP address back to a connecting peer using the init
315 /// message. A node can decide to use that information to discover a potential update to its
316 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
317 /// the new address.
318 #[no_mangle]
319 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_SocketAddressZ) {
320         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
321         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
322 }
323 /// Constructs a new Init given each field
324 #[must_use]
325 #[no_mangle]
326 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ, mut remote_network_address_arg: crate::c_types::derived::COption_SocketAddressZ) -> Init {
327         let mut local_networks_arg = { /*networks_arg*/ let networks_arg_opt = networks_arg; if networks_arg_opt.is_none() { None } else { Some({ { let mut local_networks_arg_0 = Vec::new(); for mut item in { networks_arg_opt.take() }.into_rust().drain(..) { local_networks_arg_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_networks_arg_0 }})} };
328         let mut local_remote_network_address_arg = { /*remote_network_address_arg*/ let remote_network_address_arg_opt = remote_network_address_arg; if remote_network_address_arg_opt.is_none() { None } else { Some({ { { remote_network_address_arg_opt.take() }.into_native() }})} };
329         Init { inner: ObjOps::heap_alloc(nativeInit {
330                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
331                 networks: local_networks_arg,
332                 remote_network_address: local_remote_network_address_arg,
333         }), is_owned: true }
334 }
335 impl Clone for Init {
336         fn clone(&self) -> Self {
337                 Self {
338                         inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
339                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
340                         is_owned: true,
341                 }
342         }
343 }
344 #[allow(unused)]
345 /// Used only if an object of this type is returned as a trait impl by a method
346 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
347         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInit)).clone() })) as *mut c_void
348 }
349 #[no_mangle]
350 /// Creates a copy of the Init
351 pub extern "C" fn Init_clone(orig: &Init) -> Init {
352         orig.clone()
353 }
354 /// Get a string which allows debug introspection of a Init object
355 pub extern "C" fn Init_debug_str_void(o: *const c_void) -> Str {
356         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Init }).into()}
357 /// Generates a non-cryptographic 64-bit hash of the Init.
358 #[no_mangle]
359 pub extern "C" fn Init_hash(o: &Init) -> u64 {
360         if o.inner.is_null() { return 0; }
361         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
362         #[allow(deprecated)]
363         let mut hasher = core::hash::SipHasher::new();
364         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
365         core::hash::Hasher::finish(&hasher)
366 }
367 /// Checks if two Inits contain equal inner contents.
368 /// This ignores pointers and is_owned flags and looks at the values in fields.
369 /// Two objects with NULL inner values will be considered "equal" here.
370 #[no_mangle]
371 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
372         if a.inner == b.inner { return true; }
373         if a.inner.is_null() || b.inner.is_null() { return false; }
374         if a.get_native_ref() == b.get_native_ref() { true } else { false }
375 }
376
377 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
378 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
379
380 /// An [`error`] message to be sent to or received from a peer.
381 ///
382 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
383 #[must_use]
384 #[repr(C)]
385 pub struct ErrorMessage {
386         /// A pointer to the opaque Rust object.
387
388         /// Nearly everywhere, inner must be non-null, however in places where
389         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
390         pub inner: *mut nativeErrorMessage,
391         /// Indicates that this is the only struct which contains the same pointer.
392
393         /// Rust functions which take ownership of an object provided via an argument require
394         /// this to be true and invalidate the object pointed to by inner.
395         pub is_owned: bool,
396 }
397
398 impl Drop for ErrorMessage {
399         fn drop(&mut self) {
400                 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
401                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
402                 }
403         }
404 }
405 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
406 #[no_mangle]
407 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
408 #[allow(unused)]
409 /// Used only if an object of this type is returned as a trait impl by a method
410 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
411         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
412 }
413 #[allow(unused)]
414 impl ErrorMessage {
415         pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
416                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
417         }
418         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
419                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
420         }
421         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
422         pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
423                 assert!(self.is_owned);
424                 let ret = ObjOps::untweak_ptr(self.inner);
425                 self.inner = core::ptr::null_mut();
426                 ret
427         }
428 }
429 /// The channel ID involved in the error.
430 ///
431 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
432 /// with the sending peer should be closed.
433 #[no_mangle]
434 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> crate::lightning::ln::types::ChannelId {
435         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
436         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
437 }
438 /// The channel ID involved in the error.
439 ///
440 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
441 /// with the sending peer should be closed.
442 #[no_mangle]
443 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::lightning::ln::types::ChannelId) {
444         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
445 }
446 /// A possibly human-readable error description.
447 ///
448 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
449 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
450 /// the terminal emulator or the logging subsystem.
451 #[no_mangle]
452 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
453         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
454         inner_val.as_str().into()
455 }
456 /// A possibly human-readable error description.
457 ///
458 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
459 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
460 /// the terminal emulator or the logging subsystem.
461 #[no_mangle]
462 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
463         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
464 }
465 /// Constructs a new ErrorMessage given each field
466 #[must_use]
467 #[no_mangle]
468 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::Str) -> ErrorMessage {
469         ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
470                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
471                 data: data_arg.into_string(),
472         }), is_owned: true }
473 }
474 impl Clone for ErrorMessage {
475         fn clone(&self) -> Self {
476                 Self {
477                         inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
478                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
479                         is_owned: true,
480                 }
481         }
482 }
483 #[allow(unused)]
484 /// Used only if an object of this type is returned as a trait impl by a method
485 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
486         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeErrorMessage)).clone() })) as *mut c_void
487 }
488 #[no_mangle]
489 /// Creates a copy of the ErrorMessage
490 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
491         orig.clone()
492 }
493 /// Get a string which allows debug introspection of a ErrorMessage object
494 pub extern "C" fn ErrorMessage_debug_str_void(o: *const c_void) -> Str {
495         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorMessage }).into()}
496 /// Generates a non-cryptographic 64-bit hash of the ErrorMessage.
497 #[no_mangle]
498 pub extern "C" fn ErrorMessage_hash(o: &ErrorMessage) -> u64 {
499         if o.inner.is_null() { return 0; }
500         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
501         #[allow(deprecated)]
502         let mut hasher = core::hash::SipHasher::new();
503         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
504         core::hash::Hasher::finish(&hasher)
505 }
506 /// Checks if two ErrorMessages contain equal inner contents.
507 /// This ignores pointers and is_owned flags and looks at the values in fields.
508 /// Two objects with NULL inner values will be considered "equal" here.
509 #[no_mangle]
510 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
511         if a.inner == b.inner { return true; }
512         if a.inner.is_null() || b.inner.is_null() { return false; }
513         if a.get_native_ref() == b.get_native_ref() { true } else { false }
514 }
515
516 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
517 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
518
519 /// A [`warning`] message to be sent to or received from a peer.
520 ///
521 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
522 #[must_use]
523 #[repr(C)]
524 pub struct WarningMessage {
525         /// A pointer to the opaque Rust object.
526
527         /// Nearly everywhere, inner must be non-null, however in places where
528         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
529         pub inner: *mut nativeWarningMessage,
530         /// Indicates that this is the only struct which contains the same pointer.
531
532         /// Rust functions which take ownership of an object provided via an argument require
533         /// this to be true and invalidate the object pointed to by inner.
534         pub is_owned: bool,
535 }
536
537 impl Drop for WarningMessage {
538         fn drop(&mut self) {
539                 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
540                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
541                 }
542         }
543 }
544 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
545 #[no_mangle]
546 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
547 #[allow(unused)]
548 /// Used only if an object of this type is returned as a trait impl by a method
549 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
550         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
551 }
552 #[allow(unused)]
553 impl WarningMessage {
554         pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
555                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
556         }
557         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
558                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
559         }
560         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
561         pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
562                 assert!(self.is_owned);
563                 let ret = ObjOps::untweak_ptr(self.inner);
564                 self.inner = core::ptr::null_mut();
565                 ret
566         }
567 }
568 /// The channel ID involved in the warning.
569 ///
570 /// All-0s indicates a warning unrelated to a specific channel.
571 #[no_mangle]
572 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> crate::lightning::ln::types::ChannelId {
573         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
574         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
575 }
576 /// The channel ID involved in the warning.
577 ///
578 /// All-0s indicates a warning unrelated to a specific channel.
579 #[no_mangle]
580 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::lightning::ln::types::ChannelId) {
581         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
582 }
583 /// A possibly human-readable warning description.
584 ///
585 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
586 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
587 /// the terminal emulator or the logging subsystem.
588 #[no_mangle]
589 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
590         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
591         inner_val.as_str().into()
592 }
593 /// A possibly human-readable warning description.
594 ///
595 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
596 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
597 /// the terminal emulator or the logging subsystem.
598 #[no_mangle]
599 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
600         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
601 }
602 /// Constructs a new WarningMessage given each field
603 #[must_use]
604 #[no_mangle]
605 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::Str) -> WarningMessage {
606         WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
607                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
608                 data: data_arg.into_string(),
609         }), is_owned: true }
610 }
611 impl Clone for WarningMessage {
612         fn clone(&self) -> Self {
613                 Self {
614                         inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
615                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
616                         is_owned: true,
617                 }
618         }
619 }
620 #[allow(unused)]
621 /// Used only if an object of this type is returned as a trait impl by a method
622 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
623         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeWarningMessage)).clone() })) as *mut c_void
624 }
625 #[no_mangle]
626 /// Creates a copy of the WarningMessage
627 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
628         orig.clone()
629 }
630 /// Get a string which allows debug introspection of a WarningMessage object
631 pub extern "C" fn WarningMessage_debug_str_void(o: *const c_void) -> Str {
632         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::WarningMessage }).into()}
633 /// Generates a non-cryptographic 64-bit hash of the WarningMessage.
634 #[no_mangle]
635 pub extern "C" fn WarningMessage_hash(o: &WarningMessage) -> u64 {
636         if o.inner.is_null() { return 0; }
637         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
638         #[allow(deprecated)]
639         let mut hasher = core::hash::SipHasher::new();
640         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
641         core::hash::Hasher::finish(&hasher)
642 }
643 /// Checks if two WarningMessages contain equal inner contents.
644 /// This ignores pointers and is_owned flags and looks at the values in fields.
645 /// Two objects with NULL inner values will be considered "equal" here.
646 #[no_mangle]
647 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
648         if a.inner == b.inner { return true; }
649         if a.inner.is_null() || b.inner.is_null() { return false; }
650         if a.get_native_ref() == b.get_native_ref() { true } else { false }
651 }
652
653 use lightning::ln::msgs::Ping as nativePingImport;
654 pub(crate) type nativePing = nativePingImport;
655
656 /// A [`ping`] message to be sent to or received from a peer.
657 ///
658 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
659 #[must_use]
660 #[repr(C)]
661 pub struct Ping {
662         /// A pointer to the opaque Rust object.
663
664         /// Nearly everywhere, inner must be non-null, however in places where
665         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
666         pub inner: *mut nativePing,
667         /// Indicates that this is the only struct which contains the same pointer.
668
669         /// Rust functions which take ownership of an object provided via an argument require
670         /// this to be true and invalidate the object pointed to by inner.
671         pub is_owned: bool,
672 }
673
674 impl Drop for Ping {
675         fn drop(&mut self) {
676                 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
677                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
678                 }
679         }
680 }
681 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
682 #[no_mangle]
683 pub extern "C" fn Ping_free(this_obj: Ping) { }
684 #[allow(unused)]
685 /// Used only if an object of this type is returned as a trait impl by a method
686 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
687         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
688 }
689 #[allow(unused)]
690 impl Ping {
691         pub(crate) fn get_native_ref(&self) -> &'static nativePing {
692                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
693         }
694         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
695                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
696         }
697         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
698         pub(crate) fn take_inner(mut self) -> *mut nativePing {
699                 assert!(self.is_owned);
700                 let ret = ObjOps::untweak_ptr(self.inner);
701                 self.inner = core::ptr::null_mut();
702                 ret
703         }
704 }
705 /// The desired response length.
706 #[no_mangle]
707 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
708         let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
709         *inner_val
710 }
711 /// The desired response length.
712 #[no_mangle]
713 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
714         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
715 }
716 /// The ping packet size.
717 ///
718 /// This field is not sent on the wire. byteslen zeros are sent.
719 #[no_mangle]
720 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
721         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
722         *inner_val
723 }
724 /// The ping packet size.
725 ///
726 /// This field is not sent on the wire. byteslen zeros are sent.
727 #[no_mangle]
728 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
729         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
730 }
731 /// Constructs a new Ping given each field
732 #[must_use]
733 #[no_mangle]
734 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
735         Ping { inner: ObjOps::heap_alloc(nativePing {
736                 ponglen: ponglen_arg,
737                 byteslen: byteslen_arg,
738         }), is_owned: true }
739 }
740 impl Clone for Ping {
741         fn clone(&self) -> Self {
742                 Self {
743                         inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
744                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
745                         is_owned: true,
746                 }
747         }
748 }
749 #[allow(unused)]
750 /// Used only if an object of this type is returned as a trait impl by a method
751 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
752         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePing)).clone() })) as *mut c_void
753 }
754 #[no_mangle]
755 /// Creates a copy of the Ping
756 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
757         orig.clone()
758 }
759 /// Get a string which allows debug introspection of a Ping object
760 pub extern "C" fn Ping_debug_str_void(o: *const c_void) -> Str {
761         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Ping }).into()}
762 /// Generates a non-cryptographic 64-bit hash of the Ping.
763 #[no_mangle]
764 pub extern "C" fn Ping_hash(o: &Ping) -> u64 {
765         if o.inner.is_null() { return 0; }
766         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
767         #[allow(deprecated)]
768         let mut hasher = core::hash::SipHasher::new();
769         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
770         core::hash::Hasher::finish(&hasher)
771 }
772 /// Checks if two Pings contain equal inner contents.
773 /// This ignores pointers and is_owned flags and looks at the values in fields.
774 /// Two objects with NULL inner values will be considered "equal" here.
775 #[no_mangle]
776 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
777         if a.inner == b.inner { return true; }
778         if a.inner.is_null() || b.inner.is_null() { return false; }
779         if a.get_native_ref() == b.get_native_ref() { true } else { false }
780 }
781
782 use lightning::ln::msgs::Pong as nativePongImport;
783 pub(crate) type nativePong = nativePongImport;
784
785 /// A [`pong`] message to be sent to or received from a peer.
786 ///
787 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
788 #[must_use]
789 #[repr(C)]
790 pub struct Pong {
791         /// A pointer to the opaque Rust object.
792
793         /// Nearly everywhere, inner must be non-null, however in places where
794         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
795         pub inner: *mut nativePong,
796         /// Indicates that this is the only struct which contains the same pointer.
797
798         /// Rust functions which take ownership of an object provided via an argument require
799         /// this to be true and invalidate the object pointed to by inner.
800         pub is_owned: bool,
801 }
802
803 impl Drop for Pong {
804         fn drop(&mut self) {
805                 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
806                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
807                 }
808         }
809 }
810 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
811 #[no_mangle]
812 pub extern "C" fn Pong_free(this_obj: Pong) { }
813 #[allow(unused)]
814 /// Used only if an object of this type is returned as a trait impl by a method
815 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
816         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
817 }
818 #[allow(unused)]
819 impl Pong {
820         pub(crate) fn get_native_ref(&self) -> &'static nativePong {
821                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
822         }
823         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
824                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
825         }
826         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
827         pub(crate) fn take_inner(mut self) -> *mut nativePong {
828                 assert!(self.is_owned);
829                 let ret = ObjOps::untweak_ptr(self.inner);
830                 self.inner = core::ptr::null_mut();
831                 ret
832         }
833 }
834 /// The pong packet size.
835 ///
836 /// This field is not sent on the wire. byteslen zeros are sent.
837 #[no_mangle]
838 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
839         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
840         *inner_val
841 }
842 /// The pong packet size.
843 ///
844 /// This field is not sent on the wire. byteslen zeros are sent.
845 #[no_mangle]
846 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
847         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
848 }
849 /// Constructs a new Pong given each field
850 #[must_use]
851 #[no_mangle]
852 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
853         Pong { inner: ObjOps::heap_alloc(nativePong {
854                 byteslen: byteslen_arg,
855         }), is_owned: true }
856 }
857 impl Clone for Pong {
858         fn clone(&self) -> Self {
859                 Self {
860                         inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
861                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
862                         is_owned: true,
863                 }
864         }
865 }
866 #[allow(unused)]
867 /// Used only if an object of this type is returned as a trait impl by a method
868 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
869         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePong)).clone() })) as *mut c_void
870 }
871 #[no_mangle]
872 /// Creates a copy of the Pong
873 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
874         orig.clone()
875 }
876 /// Get a string which allows debug introspection of a Pong object
877 pub extern "C" fn Pong_debug_str_void(o: *const c_void) -> Str {
878         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Pong }).into()}
879 /// Generates a non-cryptographic 64-bit hash of the Pong.
880 #[no_mangle]
881 pub extern "C" fn Pong_hash(o: &Pong) -> u64 {
882         if o.inner.is_null() { return 0; }
883         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
884         #[allow(deprecated)]
885         let mut hasher = core::hash::SipHasher::new();
886         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
887         core::hash::Hasher::finish(&hasher)
888 }
889 /// Checks if two Pongs contain equal inner contents.
890 /// This ignores pointers and is_owned flags and looks at the values in fields.
891 /// Two objects with NULL inner values will be considered "equal" here.
892 #[no_mangle]
893 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
894         if a.inner == b.inner { return true; }
895         if a.inner.is_null() || b.inner.is_null() { return false; }
896         if a.get_native_ref() == b.get_native_ref() { true } else { false }
897 }
898
899 use lightning::ln::msgs::CommonOpenChannelFields as nativeCommonOpenChannelFieldsImport;
900 pub(crate) type nativeCommonOpenChannelFields = nativeCommonOpenChannelFieldsImport;
901
902 /// Contains fields that are both common to [`open_channel`] and `open_channel2` messages.
903 ///
904 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
905 #[must_use]
906 #[repr(C)]
907 pub struct CommonOpenChannelFields {
908         /// A pointer to the opaque Rust object.
909
910         /// Nearly everywhere, inner must be non-null, however in places where
911         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
912         pub inner: *mut nativeCommonOpenChannelFields,
913         /// Indicates that this is the only struct which contains the same pointer.
914
915         /// Rust functions which take ownership of an object provided via an argument require
916         /// this to be true and invalidate the object pointed to by inner.
917         pub is_owned: bool,
918 }
919
920 impl Drop for CommonOpenChannelFields {
921         fn drop(&mut self) {
922                 if self.is_owned && !<*mut nativeCommonOpenChannelFields>::is_null(self.inner) {
923                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
924                 }
925         }
926 }
927 /// Frees any resources used by the CommonOpenChannelFields, if is_owned is set and inner is non-NULL.
928 #[no_mangle]
929 pub extern "C" fn CommonOpenChannelFields_free(this_obj: CommonOpenChannelFields) { }
930 #[allow(unused)]
931 /// Used only if an object of this type is returned as a trait impl by a method
932 pub(crate) extern "C" fn CommonOpenChannelFields_free_void(this_ptr: *mut c_void) {
933         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommonOpenChannelFields) };
934 }
935 #[allow(unused)]
936 impl CommonOpenChannelFields {
937         pub(crate) fn get_native_ref(&self) -> &'static nativeCommonOpenChannelFields {
938                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
939         }
940         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommonOpenChannelFields {
941                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
942         }
943         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
944         pub(crate) fn take_inner(mut self) -> *mut nativeCommonOpenChannelFields {
945                 assert!(self.is_owned);
946                 let ret = ObjOps::untweak_ptr(self.inner);
947                 self.inner = core::ptr::null_mut();
948                 ret
949         }
950 }
951 /// The genesis hash of the blockchain where the channel is to be opened
952 #[no_mangle]
953 pub extern "C" fn CommonOpenChannelFields_get_chain_hash(this_ptr: &CommonOpenChannelFields) -> *const [u8; 32] {
954         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
955         inner_val.as_ref()
956 }
957 /// The genesis hash of the blockchain where the channel is to be opened
958 #[no_mangle]
959 pub extern "C" fn CommonOpenChannelFields_set_chain_hash(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::ThirtyTwoBytes) {
960         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
961 }
962 /// A temporary channel ID
963 /// For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
964 /// For V1 channels: a temporary channel ID, until the funding outpoint is announced
965 #[no_mangle]
966 pub extern "C" fn CommonOpenChannelFields_get_temporary_channel_id(this_ptr: &CommonOpenChannelFields) -> crate::lightning::ln::types::ChannelId {
967         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
968         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
969 }
970 /// A temporary channel ID
971 /// For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
972 /// For V1 channels: a temporary channel ID, until the funding outpoint is announced
973 #[no_mangle]
974 pub extern "C" fn CommonOpenChannelFields_set_temporary_channel_id(this_ptr: &mut CommonOpenChannelFields, mut val: crate::lightning::ln::types::ChannelId) {
975         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) };
976 }
977 /// For V1 channels: The channel value
978 /// For V2 channels: Part of the channel value contributed by the channel initiator
979 #[no_mangle]
980 pub extern "C" fn CommonOpenChannelFields_get_funding_satoshis(this_ptr: &CommonOpenChannelFields) -> u64 {
981         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
982         *inner_val
983 }
984 /// For V1 channels: The channel value
985 /// For V2 channels: Part of the channel value contributed by the channel initiator
986 #[no_mangle]
987 pub extern "C" fn CommonOpenChannelFields_set_funding_satoshis(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
988         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
989 }
990 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
991 /// omitted
992 #[no_mangle]
993 pub extern "C" fn CommonOpenChannelFields_get_dust_limit_satoshis(this_ptr: &CommonOpenChannelFields) -> u64 {
994         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
995         *inner_val
996 }
997 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
998 /// omitted
999 #[no_mangle]
1000 pub extern "C" fn CommonOpenChannelFields_set_dust_limit_satoshis(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
1001         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1002 }
1003 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1004 #[no_mangle]
1005 pub extern "C" fn CommonOpenChannelFields_get_max_htlc_value_in_flight_msat(this_ptr: &CommonOpenChannelFields) -> u64 {
1006         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1007         *inner_val
1008 }
1009 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1010 #[no_mangle]
1011 pub extern "C" fn CommonOpenChannelFields_set_max_htlc_value_in_flight_msat(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
1012         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1013 }
1014 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1015 #[no_mangle]
1016 pub extern "C" fn CommonOpenChannelFields_get_htlc_minimum_msat(this_ptr: &CommonOpenChannelFields) -> u64 {
1017         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1018         *inner_val
1019 }
1020 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1021 #[no_mangle]
1022 pub extern "C" fn CommonOpenChannelFields_set_htlc_minimum_msat(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
1023         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1024 }
1025 /// The feerate for the commitment transaction set by the channel initiator until updated by
1026 /// [`UpdateFee`]
1027 #[no_mangle]
1028 pub extern "C" fn CommonOpenChannelFields_get_commitment_feerate_sat_per_1000_weight(this_ptr: &CommonOpenChannelFields) -> u32 {
1029         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1030         *inner_val
1031 }
1032 /// The feerate for the commitment transaction set by the channel initiator until updated by
1033 /// [`UpdateFee`]
1034 #[no_mangle]
1035 pub extern "C" fn CommonOpenChannelFields_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut CommonOpenChannelFields, mut val: u32) {
1036         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1037 }
1038 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1039 /// broadcast a commitment transaction
1040 #[no_mangle]
1041 pub extern "C" fn CommonOpenChannelFields_get_to_self_delay(this_ptr: &CommonOpenChannelFields) -> u16 {
1042         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1043         *inner_val
1044 }
1045 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1046 /// broadcast a commitment transaction
1047 #[no_mangle]
1048 pub extern "C" fn CommonOpenChannelFields_set_to_self_delay(this_ptr: &mut CommonOpenChannelFields, mut val: u16) {
1049         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1050 }
1051 /// The maximum number of inbound HTLCs towards channel initiator
1052 #[no_mangle]
1053 pub extern "C" fn CommonOpenChannelFields_get_max_accepted_htlcs(this_ptr: &CommonOpenChannelFields) -> u16 {
1054         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1055         *inner_val
1056 }
1057 /// The maximum number of inbound HTLCs towards channel initiator
1058 #[no_mangle]
1059 pub extern "C" fn CommonOpenChannelFields_set_max_accepted_htlcs(this_ptr: &mut CommonOpenChannelFields, mut val: u16) {
1060         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1061 }
1062 /// The channel initiator's key controlling the funding transaction
1063 #[no_mangle]
1064 pub extern "C" fn CommonOpenChannelFields_get_funding_pubkey(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1065         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1066         crate::c_types::PublicKey::from_rust(&inner_val)
1067 }
1068 /// The channel initiator's key controlling the funding transaction
1069 #[no_mangle]
1070 pub extern "C" fn CommonOpenChannelFields_set_funding_pubkey(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1071         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1072 }
1073 /// Used to derive a revocation key for transactions broadcast by counterparty
1074 #[no_mangle]
1075 pub extern "C" fn CommonOpenChannelFields_get_revocation_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1076         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1077         crate::c_types::PublicKey::from_rust(&inner_val)
1078 }
1079 /// Used to derive a revocation key for transactions broadcast by counterparty
1080 #[no_mangle]
1081 pub extern "C" fn CommonOpenChannelFields_set_revocation_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1082         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1083 }
1084 /// A payment key to channel initiator for transactions broadcast by counterparty
1085 #[no_mangle]
1086 pub extern "C" fn CommonOpenChannelFields_get_payment_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1087         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1088         crate::c_types::PublicKey::from_rust(&inner_val)
1089 }
1090 /// A payment key to channel initiator for transactions broadcast by counterparty
1091 #[no_mangle]
1092 pub extern "C" fn CommonOpenChannelFields_set_payment_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1093         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1094 }
1095 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1096 /// initiator
1097 #[no_mangle]
1098 pub extern "C" fn CommonOpenChannelFields_get_delayed_payment_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1099         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1100         crate::c_types::PublicKey::from_rust(&inner_val)
1101 }
1102 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1103 /// initiator
1104 #[no_mangle]
1105 pub extern "C" fn CommonOpenChannelFields_set_delayed_payment_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1106         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1107 }
1108 /// Used to derive an HTLC payment key to channel initiator
1109 #[no_mangle]
1110 pub extern "C" fn CommonOpenChannelFields_get_htlc_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1111         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1112         crate::c_types::PublicKey::from_rust(&inner_val)
1113 }
1114 /// Used to derive an HTLC payment key to channel initiator
1115 #[no_mangle]
1116 pub extern "C" fn CommonOpenChannelFields_set_htlc_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1117         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1118 }
1119 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1120 #[no_mangle]
1121 pub extern "C" fn CommonOpenChannelFields_get_first_per_commitment_point(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1122         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1123         crate::c_types::PublicKey::from_rust(&inner_val)
1124 }
1125 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1126 #[no_mangle]
1127 pub extern "C" fn CommonOpenChannelFields_set_first_per_commitment_point(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1128         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1129 }
1130 /// The channel flags to be used
1131 #[no_mangle]
1132 pub extern "C" fn CommonOpenChannelFields_get_channel_flags(this_ptr: &CommonOpenChannelFields) -> u8 {
1133         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1134         *inner_val
1135 }
1136 /// The channel flags to be used
1137 #[no_mangle]
1138 pub extern "C" fn CommonOpenChannelFields_set_channel_flags(this_ptr: &mut CommonOpenChannelFields, mut val: u8) {
1139         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1140 }
1141 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1142 /// collaboratively close
1143 #[no_mangle]
1144 pub extern "C" fn CommonOpenChannelFields_get_shutdown_scriptpubkey(this_ptr: &CommonOpenChannelFields) -> crate::c_types::derived::COption_CVec_u8ZZ {
1145         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1146         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) };
1147         local_inner_val
1148 }
1149 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1150 /// collaboratively close
1151 #[no_mangle]
1152 pub extern "C" fn CommonOpenChannelFields_set_shutdown_scriptpubkey(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1153         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
1154         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1155 }
1156 /// The channel type that this channel will represent
1157 ///
1158 /// If this is `None`, we derive the channel type from the intersection of our
1159 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1160 ///
1161 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1162 #[no_mangle]
1163 pub extern "C" fn CommonOpenChannelFields_get_channel_type(this_ptr: &CommonOpenChannelFields) -> crate::lightning::ln::features::ChannelTypeFeatures {
1164         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1165         let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { 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::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1166         local_inner_val
1167 }
1168 /// The channel type that this channel will represent
1169 ///
1170 /// If this is `None`, we derive the channel type from the intersection of our
1171 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1172 ///
1173 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1174 #[no_mangle]
1175 pub extern "C" fn CommonOpenChannelFields_set_channel_type(this_ptr: &mut CommonOpenChannelFields, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1176         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1177         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1178 }
1179 /// Constructs a new CommonOpenChannelFields given each field
1180 ///
1181 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1182 #[must_use]
1183 #[no_mangle]
1184 pub extern "C" fn CommonOpenChannelFields_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> CommonOpenChannelFields {
1185         let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1186         let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1187         CommonOpenChannelFields { inner: ObjOps::heap_alloc(nativeCommonOpenChannelFields {
1188                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
1189                 temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) },
1190                 funding_satoshis: funding_satoshis_arg,
1191                 dust_limit_satoshis: dust_limit_satoshis_arg,
1192                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1193                 htlc_minimum_msat: htlc_minimum_msat_arg,
1194                 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1195                 to_self_delay: to_self_delay_arg,
1196                 max_accepted_htlcs: max_accepted_htlcs_arg,
1197                 funding_pubkey: funding_pubkey_arg.into_rust(),
1198                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1199                 payment_basepoint: payment_basepoint_arg.into_rust(),
1200                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1201                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1202                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1203                 channel_flags: channel_flags_arg,
1204                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1205                 channel_type: local_channel_type_arg,
1206         }), is_owned: true }
1207 }
1208 impl Clone for CommonOpenChannelFields {
1209         fn clone(&self) -> Self {
1210                 Self {
1211                         inner: if <*mut nativeCommonOpenChannelFields>::is_null(self.inner) { core::ptr::null_mut() } else {
1212                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1213                         is_owned: true,
1214                 }
1215         }
1216 }
1217 #[allow(unused)]
1218 /// Used only if an object of this type is returned as a trait impl by a method
1219 pub(crate) extern "C" fn CommonOpenChannelFields_clone_void(this_ptr: *const c_void) -> *mut c_void {
1220         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommonOpenChannelFields)).clone() })) as *mut c_void
1221 }
1222 #[no_mangle]
1223 /// Creates a copy of the CommonOpenChannelFields
1224 pub extern "C" fn CommonOpenChannelFields_clone(orig: &CommonOpenChannelFields) -> CommonOpenChannelFields {
1225         orig.clone()
1226 }
1227 /// Get a string which allows debug introspection of a CommonOpenChannelFields object
1228 pub extern "C" fn CommonOpenChannelFields_debug_str_void(o: *const c_void) -> Str {
1229         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommonOpenChannelFields }).into()}
1230 /// Generates a non-cryptographic 64-bit hash of the CommonOpenChannelFields.
1231 #[no_mangle]
1232 pub extern "C" fn CommonOpenChannelFields_hash(o: &CommonOpenChannelFields) -> u64 {
1233         if o.inner.is_null() { return 0; }
1234         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1235         #[allow(deprecated)]
1236         let mut hasher = core::hash::SipHasher::new();
1237         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1238         core::hash::Hasher::finish(&hasher)
1239 }
1240 /// Checks if two CommonOpenChannelFieldss contain equal inner contents.
1241 /// This ignores pointers and is_owned flags and looks at the values in fields.
1242 /// Two objects with NULL inner values will be considered "equal" here.
1243 #[no_mangle]
1244 pub extern "C" fn CommonOpenChannelFields_eq(a: &CommonOpenChannelFields, b: &CommonOpenChannelFields) -> bool {
1245         if a.inner == b.inner { return true; }
1246         if a.inner.is_null() || b.inner.is_null() { return false; }
1247         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1248 }
1249
1250 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
1251 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
1252
1253 /// An [`open_channel`] message to be sent to or received from a peer.
1254 ///
1255 /// Used in V1 channel establishment
1256 ///
1257 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
1258 #[must_use]
1259 #[repr(C)]
1260 pub struct OpenChannel {
1261         /// A pointer to the opaque Rust object.
1262
1263         /// Nearly everywhere, inner must be non-null, however in places where
1264         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1265         pub inner: *mut nativeOpenChannel,
1266         /// Indicates that this is the only struct which contains the same pointer.
1267
1268         /// Rust functions which take ownership of an object provided via an argument require
1269         /// this to be true and invalidate the object pointed to by inner.
1270         pub is_owned: bool,
1271 }
1272
1273 impl Drop for OpenChannel {
1274         fn drop(&mut self) {
1275                 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
1276                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1277                 }
1278         }
1279 }
1280 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
1281 #[no_mangle]
1282 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
1283 #[allow(unused)]
1284 /// Used only if an object of this type is returned as a trait impl by a method
1285 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
1286         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
1287 }
1288 #[allow(unused)]
1289 impl OpenChannel {
1290         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
1291                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1292         }
1293         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
1294                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1295         }
1296         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1297         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
1298                 assert!(self.is_owned);
1299                 let ret = ObjOps::untweak_ptr(self.inner);
1300                 self.inner = core::ptr::null_mut();
1301                 ret
1302         }
1303 }
1304 /// Common fields of `open_channel(2)`-like messages
1305 #[no_mangle]
1306 pub extern "C" fn OpenChannel_get_common_fields(this_ptr: &OpenChannel) -> crate::lightning::ln::msgs::CommonOpenChannelFields {
1307         let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
1308         crate::lightning::ln::msgs::CommonOpenChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonOpenChannelFields<>) as *mut _) }, is_owned: false }
1309 }
1310 /// Common fields of `open_channel(2)`-like messages
1311 #[no_mangle]
1312 pub extern "C" fn OpenChannel_set_common_fields(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::msgs::CommonOpenChannelFields) {
1313         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
1314 }
1315 /// The amount to push to the counterparty as part of the open, in milli-satoshi
1316 #[no_mangle]
1317 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
1318         let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
1319         *inner_val
1320 }
1321 /// The amount to push to the counterparty as part of the open, in milli-satoshi
1322 #[no_mangle]
1323 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
1324         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
1325 }
1326 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1327 #[no_mangle]
1328 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
1329         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1330         *inner_val
1331 }
1332 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1333 #[no_mangle]
1334 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
1335         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1336 }
1337 /// Constructs a new OpenChannel given each field
1338 #[must_use]
1339 #[no_mangle]
1340 pub extern "C" fn OpenChannel_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonOpenChannelFields, mut push_msat_arg: u64, mut channel_reserve_satoshis_arg: u64) -> OpenChannel {
1341         OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1342                 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
1343                 push_msat: push_msat_arg,
1344                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1345         }), is_owned: true }
1346 }
1347 impl Clone for OpenChannel {
1348         fn clone(&self) -> Self {
1349                 Self {
1350                         inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1351                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1352                         is_owned: true,
1353                 }
1354         }
1355 }
1356 #[allow(unused)]
1357 /// Used only if an object of this type is returned as a trait impl by a method
1358 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1359         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannel)).clone() })) as *mut c_void
1360 }
1361 #[no_mangle]
1362 /// Creates a copy of the OpenChannel
1363 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1364         orig.clone()
1365 }
1366 /// Get a string which allows debug introspection of a OpenChannel object
1367 pub extern "C" fn OpenChannel_debug_str_void(o: *const c_void) -> Str {
1368         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannel }).into()}
1369 /// Generates a non-cryptographic 64-bit hash of the OpenChannel.
1370 #[no_mangle]
1371 pub extern "C" fn OpenChannel_hash(o: &OpenChannel) -> u64 {
1372         if o.inner.is_null() { return 0; }
1373         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1374         #[allow(deprecated)]
1375         let mut hasher = core::hash::SipHasher::new();
1376         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1377         core::hash::Hasher::finish(&hasher)
1378 }
1379 /// Checks if two OpenChannels contain equal inner contents.
1380 /// This ignores pointers and is_owned flags and looks at the values in fields.
1381 /// Two objects with NULL inner values will be considered "equal" here.
1382 #[no_mangle]
1383 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1384         if a.inner == b.inner { return true; }
1385         if a.inner.is_null() || b.inner.is_null() { return false; }
1386         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1387 }
1388
1389 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1390 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1391
1392 /// An open_channel2 message to be sent by or received from the channel initiator.
1393 ///
1394 /// Used in V2 channel establishment
1395 ///
1396 #[must_use]
1397 #[repr(C)]
1398 pub struct OpenChannelV2 {
1399         /// A pointer to the opaque Rust object.
1400
1401         /// Nearly everywhere, inner must be non-null, however in places where
1402         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1403         pub inner: *mut nativeOpenChannelV2,
1404         /// Indicates that this is the only struct which contains the same pointer.
1405
1406         /// Rust functions which take ownership of an object provided via an argument require
1407         /// this to be true and invalidate the object pointed to by inner.
1408         pub is_owned: bool,
1409 }
1410
1411 impl Drop for OpenChannelV2 {
1412         fn drop(&mut self) {
1413                 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1414                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1415                 }
1416         }
1417 }
1418 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1419 #[no_mangle]
1420 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1421 #[allow(unused)]
1422 /// Used only if an object of this type is returned as a trait impl by a method
1423 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1424         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1425 }
1426 #[allow(unused)]
1427 impl OpenChannelV2 {
1428         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1429                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1430         }
1431         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1432                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1433         }
1434         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1435         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1436                 assert!(self.is_owned);
1437                 let ret = ObjOps::untweak_ptr(self.inner);
1438                 self.inner = core::ptr::null_mut();
1439                 ret
1440         }
1441 }
1442 /// Common fields of `open_channel(2)`-like messages
1443 #[no_mangle]
1444 pub extern "C" fn OpenChannelV2_get_common_fields(this_ptr: &OpenChannelV2) -> crate::lightning::ln::msgs::CommonOpenChannelFields {
1445         let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
1446         crate::lightning::ln::msgs::CommonOpenChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonOpenChannelFields<>) as *mut _) }, is_owned: false }
1447 }
1448 /// Common fields of `open_channel(2)`-like messages
1449 #[no_mangle]
1450 pub extern "C" fn OpenChannelV2_set_common_fields(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::msgs::CommonOpenChannelFields) {
1451         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
1452 }
1453 /// The feerate for the funding transaction set by the channel initiator
1454 #[no_mangle]
1455 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1456         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1457         *inner_val
1458 }
1459 /// The feerate for the funding transaction set by the channel initiator
1460 #[no_mangle]
1461 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1462         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1463 }
1464 /// The locktime for the funding transaction
1465 #[no_mangle]
1466 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1467         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1468         *inner_val
1469 }
1470 /// The locktime for the funding transaction
1471 #[no_mangle]
1472 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1473         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1474 }
1475 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1476 #[no_mangle]
1477 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1478         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1479         crate::c_types::PublicKey::from_rust(&inner_val)
1480 }
1481 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1482 #[no_mangle]
1483 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1484         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1485 }
1486 /// Optionally, a requirement that only confirmed inputs can be added
1487 #[no_mangle]
1488 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1489         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1490         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /*  { () /**/ } */ };
1491         local_inner_val
1492 }
1493 /// Optionally, a requirement that only confirmed inputs can be added
1494 #[no_mangle]
1495 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1496         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1497         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1498 }
1499 /// Constructs a new OpenChannelV2 given each field
1500 #[must_use]
1501 #[no_mangle]
1502 pub extern "C" fn OpenChannelV2_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonOpenChannelFields, mut funding_feerate_sat_per_1000_weight_arg: u32, mut locktime_arg: u32, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 {
1503         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1504         OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1505                 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
1506                 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1507                 locktime: locktime_arg,
1508                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1509                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1510         }), is_owned: true }
1511 }
1512 impl Clone for OpenChannelV2 {
1513         fn clone(&self) -> Self {
1514                 Self {
1515                         inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1516                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1517                         is_owned: true,
1518                 }
1519         }
1520 }
1521 #[allow(unused)]
1522 /// Used only if an object of this type is returned as a trait impl by a method
1523 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1524         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannelV2)).clone() })) as *mut c_void
1525 }
1526 #[no_mangle]
1527 /// Creates a copy of the OpenChannelV2
1528 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1529         orig.clone()
1530 }
1531 /// Get a string which allows debug introspection of a OpenChannelV2 object
1532 pub extern "C" fn OpenChannelV2_debug_str_void(o: *const c_void) -> Str {
1533         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannelV2 }).into()}
1534 /// Generates a non-cryptographic 64-bit hash of the OpenChannelV2.
1535 #[no_mangle]
1536 pub extern "C" fn OpenChannelV2_hash(o: &OpenChannelV2) -> u64 {
1537         if o.inner.is_null() { return 0; }
1538         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1539         #[allow(deprecated)]
1540         let mut hasher = core::hash::SipHasher::new();
1541         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1542         core::hash::Hasher::finish(&hasher)
1543 }
1544 /// Checks if two OpenChannelV2s contain equal inner contents.
1545 /// This ignores pointers and is_owned flags and looks at the values in fields.
1546 /// Two objects with NULL inner values will be considered "equal" here.
1547 #[no_mangle]
1548 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1549         if a.inner == b.inner { return true; }
1550         if a.inner.is_null() || b.inner.is_null() { return false; }
1551         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1552 }
1553
1554 use lightning::ln::msgs::CommonAcceptChannelFields as nativeCommonAcceptChannelFieldsImport;
1555 pub(crate) type nativeCommonAcceptChannelFields = nativeCommonAcceptChannelFieldsImport;
1556
1557 /// Contains fields that are both common to [`accept_channel`] and `accept_channel2` messages.
1558 ///
1559 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1560 #[must_use]
1561 #[repr(C)]
1562 pub struct CommonAcceptChannelFields {
1563         /// A pointer to the opaque Rust object.
1564
1565         /// Nearly everywhere, inner must be non-null, however in places where
1566         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1567         pub inner: *mut nativeCommonAcceptChannelFields,
1568         /// Indicates that this is the only struct which contains the same pointer.
1569
1570         /// Rust functions which take ownership of an object provided via an argument require
1571         /// this to be true and invalidate the object pointed to by inner.
1572         pub is_owned: bool,
1573 }
1574
1575 impl Drop for CommonAcceptChannelFields {
1576         fn drop(&mut self) {
1577                 if self.is_owned && !<*mut nativeCommonAcceptChannelFields>::is_null(self.inner) {
1578                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1579                 }
1580         }
1581 }
1582 /// Frees any resources used by the CommonAcceptChannelFields, if is_owned is set and inner is non-NULL.
1583 #[no_mangle]
1584 pub extern "C" fn CommonAcceptChannelFields_free(this_obj: CommonAcceptChannelFields) { }
1585 #[allow(unused)]
1586 /// Used only if an object of this type is returned as a trait impl by a method
1587 pub(crate) extern "C" fn CommonAcceptChannelFields_free_void(this_ptr: *mut c_void) {
1588         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommonAcceptChannelFields) };
1589 }
1590 #[allow(unused)]
1591 impl CommonAcceptChannelFields {
1592         pub(crate) fn get_native_ref(&self) -> &'static nativeCommonAcceptChannelFields {
1593                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1594         }
1595         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommonAcceptChannelFields {
1596                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1597         }
1598         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1599         pub(crate) fn take_inner(mut self) -> *mut nativeCommonAcceptChannelFields {
1600                 assert!(self.is_owned);
1601                 let ret = ObjOps::untweak_ptr(self.inner);
1602                 self.inner = core::ptr::null_mut();
1603                 ret
1604         }
1605 }
1606 /// The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message.
1607 #[no_mangle]
1608 pub extern "C" fn CommonAcceptChannelFields_get_temporary_channel_id(this_ptr: &CommonAcceptChannelFields) -> crate::lightning::ln::types::ChannelId {
1609         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1610         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
1611 }
1612 /// The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message.
1613 #[no_mangle]
1614 pub extern "C" fn CommonAcceptChannelFields_set_temporary_channel_id(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::lightning::ln::types::ChannelId) {
1615         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) };
1616 }
1617 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1618 /// omitted
1619 #[no_mangle]
1620 pub extern "C" fn CommonAcceptChannelFields_get_dust_limit_satoshis(this_ptr: &CommonAcceptChannelFields) -> u64 {
1621         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1622         *inner_val
1623 }
1624 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1625 /// omitted
1626 #[no_mangle]
1627 pub extern "C" fn CommonAcceptChannelFields_set_dust_limit_satoshis(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) {
1628         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1629 }
1630 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1631 #[no_mangle]
1632 pub extern "C" fn CommonAcceptChannelFields_get_max_htlc_value_in_flight_msat(this_ptr: &CommonAcceptChannelFields) -> u64 {
1633         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1634         *inner_val
1635 }
1636 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1637 #[no_mangle]
1638 pub extern "C" fn CommonAcceptChannelFields_set_max_htlc_value_in_flight_msat(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) {
1639         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1640 }
1641 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1642 #[no_mangle]
1643 pub extern "C" fn CommonAcceptChannelFields_get_htlc_minimum_msat(this_ptr: &CommonAcceptChannelFields) -> u64 {
1644         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1645         *inner_val
1646 }
1647 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1648 #[no_mangle]
1649 pub extern "C" fn CommonAcceptChannelFields_set_htlc_minimum_msat(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) {
1650         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1651 }
1652 /// Minimum depth of the funding transaction before the channel is considered open
1653 #[no_mangle]
1654 pub extern "C" fn CommonAcceptChannelFields_get_minimum_depth(this_ptr: &CommonAcceptChannelFields) -> u32 {
1655         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1656         *inner_val
1657 }
1658 /// Minimum depth of the funding transaction before the channel is considered open
1659 #[no_mangle]
1660 pub extern "C" fn CommonAcceptChannelFields_set_minimum_depth(this_ptr: &mut CommonAcceptChannelFields, mut val: u32) {
1661         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1662 }
1663 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1664 /// broadcast a commitment transaction
1665 #[no_mangle]
1666 pub extern "C" fn CommonAcceptChannelFields_get_to_self_delay(this_ptr: &CommonAcceptChannelFields) -> u16 {
1667         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1668         *inner_val
1669 }
1670 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1671 /// broadcast a commitment transaction
1672 #[no_mangle]
1673 pub extern "C" fn CommonAcceptChannelFields_set_to_self_delay(this_ptr: &mut CommonAcceptChannelFields, mut val: u16) {
1674         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1675 }
1676 /// The maximum number of inbound HTLCs towards channel acceptor
1677 #[no_mangle]
1678 pub extern "C" fn CommonAcceptChannelFields_get_max_accepted_htlcs(this_ptr: &CommonAcceptChannelFields) -> u16 {
1679         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1680         *inner_val
1681 }
1682 /// The maximum number of inbound HTLCs towards channel acceptor
1683 #[no_mangle]
1684 pub extern "C" fn CommonAcceptChannelFields_set_max_accepted_htlcs(this_ptr: &mut CommonAcceptChannelFields, mut val: u16) {
1685         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1686 }
1687 /// The channel acceptor's key controlling the funding transaction
1688 #[no_mangle]
1689 pub extern "C" fn CommonAcceptChannelFields_get_funding_pubkey(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1690         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1691         crate::c_types::PublicKey::from_rust(&inner_val)
1692 }
1693 /// The channel acceptor's key controlling the funding transaction
1694 #[no_mangle]
1695 pub extern "C" fn CommonAcceptChannelFields_set_funding_pubkey(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1696         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1697 }
1698 /// Used to derive a revocation key for transactions broadcast by counterparty
1699 #[no_mangle]
1700 pub extern "C" fn CommonAcceptChannelFields_get_revocation_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1701         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1702         crate::c_types::PublicKey::from_rust(&inner_val)
1703 }
1704 /// Used to derive a revocation key for transactions broadcast by counterparty
1705 #[no_mangle]
1706 pub extern "C" fn CommonAcceptChannelFields_set_revocation_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1707         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1708 }
1709 /// A payment key to channel acceptor for transactions broadcast by counterparty
1710 #[no_mangle]
1711 pub extern "C" fn CommonAcceptChannelFields_get_payment_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1712         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1713         crate::c_types::PublicKey::from_rust(&inner_val)
1714 }
1715 /// A payment key to channel acceptor for transactions broadcast by counterparty
1716 #[no_mangle]
1717 pub extern "C" fn CommonAcceptChannelFields_set_payment_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1718         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1719 }
1720 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
1721 /// acceptor
1722 #[no_mangle]
1723 pub extern "C" fn CommonAcceptChannelFields_get_delayed_payment_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1724         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1725         crate::c_types::PublicKey::from_rust(&inner_val)
1726 }
1727 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
1728 /// acceptor
1729 #[no_mangle]
1730 pub extern "C" fn CommonAcceptChannelFields_set_delayed_payment_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1731         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1732 }
1733 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
1734 #[no_mangle]
1735 pub extern "C" fn CommonAcceptChannelFields_get_htlc_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1736         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1737         crate::c_types::PublicKey::from_rust(&inner_val)
1738 }
1739 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
1740 #[no_mangle]
1741 pub extern "C" fn CommonAcceptChannelFields_set_htlc_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1742         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1743 }
1744 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
1745 #[no_mangle]
1746 pub extern "C" fn CommonAcceptChannelFields_get_first_per_commitment_point(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1747         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1748         crate::c_types::PublicKey::from_rust(&inner_val)
1749 }
1750 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
1751 #[no_mangle]
1752 pub extern "C" fn CommonAcceptChannelFields_set_first_per_commitment_point(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1753         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1754 }
1755 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
1756 /// collaboratively close
1757 #[no_mangle]
1758 pub extern "C" fn CommonAcceptChannelFields_get_shutdown_scriptpubkey(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::derived::COption_CVec_u8ZZ {
1759         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1760         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) };
1761         local_inner_val
1762 }
1763 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
1764 /// collaboratively close
1765 #[no_mangle]
1766 pub extern "C" fn CommonAcceptChannelFields_set_shutdown_scriptpubkey(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1767         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
1768         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1769 }
1770 /// The channel type that this channel will represent. If none is set, we derive the channel
1771 /// type from the intersection of our feature bits with our counterparty's feature bits from
1772 /// the Init message.
1773 ///
1774 /// This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s
1775 /// [`CommonOpenChannelFields::channel_type`].
1776 ///
1777 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1778 #[no_mangle]
1779 pub extern "C" fn CommonAcceptChannelFields_get_channel_type(this_ptr: &CommonAcceptChannelFields) -> crate::lightning::ln::features::ChannelTypeFeatures {
1780         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1781         let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { 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::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1782         local_inner_val
1783 }
1784 /// The channel type that this channel will represent. If none is set, we derive the channel
1785 /// type from the intersection of our feature bits with our counterparty's feature bits from
1786 /// the Init message.
1787 ///
1788 /// This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s
1789 /// [`CommonOpenChannelFields::channel_type`].
1790 ///
1791 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1792 #[no_mangle]
1793 pub extern "C" fn CommonAcceptChannelFields_set_channel_type(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1794         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1795         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1796 }
1797 /// Constructs a new CommonAcceptChannelFields given each field
1798 ///
1799 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1800 #[must_use]
1801 #[no_mangle]
1802 pub extern "C" fn CommonAcceptChannelFields_new(mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> CommonAcceptChannelFields {
1803         let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1804         let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1805         CommonAcceptChannelFields { inner: ObjOps::heap_alloc(nativeCommonAcceptChannelFields {
1806                 temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) },
1807                 dust_limit_satoshis: dust_limit_satoshis_arg,
1808                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1809                 htlc_minimum_msat: htlc_minimum_msat_arg,
1810                 minimum_depth: minimum_depth_arg,
1811                 to_self_delay: to_self_delay_arg,
1812                 max_accepted_htlcs: max_accepted_htlcs_arg,
1813                 funding_pubkey: funding_pubkey_arg.into_rust(),
1814                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1815                 payment_basepoint: payment_basepoint_arg.into_rust(),
1816                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1817                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1818                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1819                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1820                 channel_type: local_channel_type_arg,
1821         }), is_owned: true }
1822 }
1823 impl Clone for CommonAcceptChannelFields {
1824         fn clone(&self) -> Self {
1825                 Self {
1826                         inner: if <*mut nativeCommonAcceptChannelFields>::is_null(self.inner) { core::ptr::null_mut() } else {
1827                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1828                         is_owned: true,
1829                 }
1830         }
1831 }
1832 #[allow(unused)]
1833 /// Used only if an object of this type is returned as a trait impl by a method
1834 pub(crate) extern "C" fn CommonAcceptChannelFields_clone_void(this_ptr: *const c_void) -> *mut c_void {
1835         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommonAcceptChannelFields)).clone() })) as *mut c_void
1836 }
1837 #[no_mangle]
1838 /// Creates a copy of the CommonAcceptChannelFields
1839 pub extern "C" fn CommonAcceptChannelFields_clone(orig: &CommonAcceptChannelFields) -> CommonAcceptChannelFields {
1840         orig.clone()
1841 }
1842 /// Get a string which allows debug introspection of a CommonAcceptChannelFields object
1843 pub extern "C" fn CommonAcceptChannelFields_debug_str_void(o: *const c_void) -> Str {
1844         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommonAcceptChannelFields }).into()}
1845 /// Generates a non-cryptographic 64-bit hash of the CommonAcceptChannelFields.
1846 #[no_mangle]
1847 pub extern "C" fn CommonAcceptChannelFields_hash(o: &CommonAcceptChannelFields) -> u64 {
1848         if o.inner.is_null() { return 0; }
1849         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1850         #[allow(deprecated)]
1851         let mut hasher = core::hash::SipHasher::new();
1852         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1853         core::hash::Hasher::finish(&hasher)
1854 }
1855 /// Checks if two CommonAcceptChannelFieldss contain equal inner contents.
1856 /// This ignores pointers and is_owned flags and looks at the values in fields.
1857 /// Two objects with NULL inner values will be considered "equal" here.
1858 #[no_mangle]
1859 pub extern "C" fn CommonAcceptChannelFields_eq(a: &CommonAcceptChannelFields, b: &CommonAcceptChannelFields) -> bool {
1860         if a.inner == b.inner { return true; }
1861         if a.inner.is_null() || b.inner.is_null() { return false; }
1862         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1863 }
1864
1865 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1866 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1867
1868 /// An [`accept_channel`] message to be sent to or received from a peer.
1869 ///
1870 /// Used in V1 channel establishment
1871 ///
1872 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1873 #[must_use]
1874 #[repr(C)]
1875 pub struct AcceptChannel {
1876         /// A pointer to the opaque Rust object.
1877
1878         /// Nearly everywhere, inner must be non-null, however in places where
1879         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1880         pub inner: *mut nativeAcceptChannel,
1881         /// Indicates that this is the only struct which contains the same pointer.
1882
1883         /// Rust functions which take ownership of an object provided via an argument require
1884         /// this to be true and invalidate the object pointed to by inner.
1885         pub is_owned: bool,
1886 }
1887
1888 impl Drop for AcceptChannel {
1889         fn drop(&mut self) {
1890                 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1891                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1892                 }
1893         }
1894 }
1895 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1896 #[no_mangle]
1897 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1898 #[allow(unused)]
1899 /// Used only if an object of this type is returned as a trait impl by a method
1900 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1901         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1902 }
1903 #[allow(unused)]
1904 impl AcceptChannel {
1905         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1906                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1907         }
1908         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1909                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1910         }
1911         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1912         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1913                 assert!(self.is_owned);
1914                 let ret = ObjOps::untweak_ptr(self.inner);
1915                 self.inner = core::ptr::null_mut();
1916                 ret
1917         }
1918 }
1919 /// Common fields of `accept_channel(2)`-like messages
1920 #[no_mangle]
1921 pub extern "C" fn AcceptChannel_get_common_fields(this_ptr: &AcceptChannel) -> crate::lightning::ln::msgs::CommonAcceptChannelFields {
1922         let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
1923         crate::lightning::ln::msgs::CommonAcceptChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonAcceptChannelFields<>) as *mut _) }, is_owned: false }
1924 }
1925 /// Common fields of `accept_channel(2)`-like messages
1926 #[no_mangle]
1927 pub extern "C" fn AcceptChannel_set_common_fields(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::msgs::CommonAcceptChannelFields) {
1928         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
1929 }
1930 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1931 #[no_mangle]
1932 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1933         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1934         *inner_val
1935 }
1936 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1937 #[no_mangle]
1938 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1939         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1940 }
1941 /// Constructs a new AcceptChannel given each field
1942 #[must_use]
1943 #[no_mangle]
1944 pub extern "C" fn AcceptChannel_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonAcceptChannelFields, mut channel_reserve_satoshis_arg: u64) -> AcceptChannel {
1945         AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1946                 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
1947                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1948         }), is_owned: true }
1949 }
1950 impl Clone for AcceptChannel {
1951         fn clone(&self) -> Self {
1952                 Self {
1953                         inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1954                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1955                         is_owned: true,
1956                 }
1957         }
1958 }
1959 #[allow(unused)]
1960 /// Used only if an object of this type is returned as a trait impl by a method
1961 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1962         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannel)).clone() })) as *mut c_void
1963 }
1964 #[no_mangle]
1965 /// Creates a copy of the AcceptChannel
1966 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1967         orig.clone()
1968 }
1969 /// Get a string which allows debug introspection of a AcceptChannel object
1970 pub extern "C" fn AcceptChannel_debug_str_void(o: *const c_void) -> Str {
1971         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AcceptChannel }).into()}
1972 /// Generates a non-cryptographic 64-bit hash of the AcceptChannel.
1973 #[no_mangle]
1974 pub extern "C" fn AcceptChannel_hash(o: &AcceptChannel) -> u64 {
1975         if o.inner.is_null() { return 0; }
1976         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1977         #[allow(deprecated)]
1978         let mut hasher = core::hash::SipHasher::new();
1979         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1980         core::hash::Hasher::finish(&hasher)
1981 }
1982 /// Checks if two AcceptChannels contain equal inner contents.
1983 /// This ignores pointers and is_owned flags and looks at the values in fields.
1984 /// Two objects with NULL inner values will be considered "equal" here.
1985 #[no_mangle]
1986 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1987         if a.inner == b.inner { return true; }
1988         if a.inner.is_null() || b.inner.is_null() { return false; }
1989         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1990 }
1991
1992 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1993 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1994
1995 /// An accept_channel2 message to be sent by or received from the channel accepter.
1996 ///
1997 /// Used in V2 channel establishment
1998 ///
1999 #[must_use]
2000 #[repr(C)]
2001 pub struct AcceptChannelV2 {
2002         /// A pointer to the opaque Rust object.
2003
2004         /// Nearly everywhere, inner must be non-null, however in places where
2005         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2006         pub inner: *mut nativeAcceptChannelV2,
2007         /// Indicates that this is the only struct which contains the same pointer.
2008
2009         /// Rust functions which take ownership of an object provided via an argument require
2010         /// this to be true and invalidate the object pointed to by inner.
2011         pub is_owned: bool,
2012 }
2013
2014 impl Drop for AcceptChannelV2 {
2015         fn drop(&mut self) {
2016                 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
2017                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2018                 }
2019         }
2020 }
2021 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
2022 #[no_mangle]
2023 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
2024 #[allow(unused)]
2025 /// Used only if an object of this type is returned as a trait impl by a method
2026 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
2027         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
2028 }
2029 #[allow(unused)]
2030 impl AcceptChannelV2 {
2031         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
2032                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2033         }
2034         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
2035                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2036         }
2037         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2038         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
2039                 assert!(self.is_owned);
2040                 let ret = ObjOps::untweak_ptr(self.inner);
2041                 self.inner = core::ptr::null_mut();
2042                 ret
2043         }
2044 }
2045 /// Common fields of `accept_channel(2)`-like messages
2046 #[no_mangle]
2047 pub extern "C" fn AcceptChannelV2_get_common_fields(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::msgs::CommonAcceptChannelFields {
2048         let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
2049         crate::lightning::ln::msgs::CommonAcceptChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonAcceptChannelFields<>) as *mut _) }, is_owned: false }
2050 }
2051 /// Common fields of `accept_channel(2)`-like messages
2052 #[no_mangle]
2053 pub extern "C" fn AcceptChannelV2_set_common_fields(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::msgs::CommonAcceptChannelFields) {
2054         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
2055 }
2056 /// Part of the channel value contributed by the channel acceptor
2057 #[no_mangle]
2058 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
2059         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
2060         *inner_val
2061 }
2062 /// Part of the channel value contributed by the channel acceptor
2063 #[no_mangle]
2064 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2065         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
2066 }
2067 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2068 #[no_mangle]
2069 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2070         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2071         crate::c_types::PublicKey::from_rust(&inner_val)
2072 }
2073 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2074 #[no_mangle]
2075 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2076         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2077 }
2078 /// Optionally, a requirement that only confirmed inputs can be added
2079 #[no_mangle]
2080 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2081         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2082         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /*  { () /**/ } */ };
2083         local_inner_val
2084 }
2085 /// Optionally, a requirement that only confirmed inputs can be added
2086 #[no_mangle]
2087 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2088         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2089         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2090 }
2091 /// Constructs a new AcceptChannelV2 given each field
2092 #[must_use]
2093 #[no_mangle]
2094 pub extern "C" fn AcceptChannelV2_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonAcceptChannelFields, mut funding_satoshis_arg: u64, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 {
2095         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2096         AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2097                 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
2098                 funding_satoshis: funding_satoshis_arg,
2099                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2100                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2101         }), is_owned: true }
2102 }
2103 impl Clone for AcceptChannelV2 {
2104         fn clone(&self) -> Self {
2105                 Self {
2106                         inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2107                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2108                         is_owned: true,
2109                 }
2110         }
2111 }
2112 #[allow(unused)]
2113 /// Used only if an object of this type is returned as a trait impl by a method
2114 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2115         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannelV2)).clone() })) as *mut c_void
2116 }
2117 #[no_mangle]
2118 /// Creates a copy of the AcceptChannelV2
2119 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2120         orig.clone()
2121 }
2122 /// Get a string which allows debug introspection of a AcceptChannelV2 object
2123 pub extern "C" fn AcceptChannelV2_debug_str_void(o: *const c_void) -> Str {
2124         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AcceptChannelV2 }).into()}
2125 /// Generates a non-cryptographic 64-bit hash of the AcceptChannelV2.
2126 #[no_mangle]
2127 pub extern "C" fn AcceptChannelV2_hash(o: &AcceptChannelV2) -> u64 {
2128         if o.inner.is_null() { return 0; }
2129         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2130         #[allow(deprecated)]
2131         let mut hasher = core::hash::SipHasher::new();
2132         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2133         core::hash::Hasher::finish(&hasher)
2134 }
2135 /// Checks if two AcceptChannelV2s contain equal inner contents.
2136 /// This ignores pointers and is_owned flags and looks at the values in fields.
2137 /// Two objects with NULL inner values will be considered "equal" here.
2138 #[no_mangle]
2139 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2140         if a.inner == b.inner { return true; }
2141         if a.inner.is_null() || b.inner.is_null() { return false; }
2142         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2143 }
2144
2145 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2146 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2147
2148 /// A [`funding_created`] message to be sent to or received from a peer.
2149 ///
2150 /// Used in V1 channel establishment
2151 ///
2152 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2153 #[must_use]
2154 #[repr(C)]
2155 pub struct FundingCreated {
2156         /// A pointer to the opaque Rust object.
2157
2158         /// Nearly everywhere, inner must be non-null, however in places where
2159         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2160         pub inner: *mut nativeFundingCreated,
2161         /// Indicates that this is the only struct which contains the same pointer.
2162
2163         /// Rust functions which take ownership of an object provided via an argument require
2164         /// this to be true and invalidate the object pointed to by inner.
2165         pub is_owned: bool,
2166 }
2167
2168 impl Drop for FundingCreated {
2169         fn drop(&mut self) {
2170                 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2171                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2172                 }
2173         }
2174 }
2175 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2176 #[no_mangle]
2177 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2178 #[allow(unused)]
2179 /// Used only if an object of this type is returned as a trait impl by a method
2180 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2181         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2182 }
2183 #[allow(unused)]
2184 impl FundingCreated {
2185         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2186                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2187         }
2188         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2189                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2190         }
2191         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2192         pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2193                 assert!(self.is_owned);
2194                 let ret = ObjOps::untweak_ptr(self.inner);
2195                 self.inner = core::ptr::null_mut();
2196                 ret
2197         }
2198 }
2199 /// A temporary channel ID, until the funding is established
2200 #[no_mangle]
2201 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> crate::lightning::ln::types::ChannelId {
2202         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2203         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2204 }
2205 /// A temporary channel ID, until the funding is established
2206 #[no_mangle]
2207 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::lightning::ln::types::ChannelId) {
2208         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2209 }
2210 /// The funding transaction ID
2211 #[no_mangle]
2212 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2213         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2214         inner_val.as_ref()
2215 }
2216 /// The funding transaction ID
2217 #[no_mangle]
2218 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2219         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2220 }
2221 /// The specific output index funding this channel
2222 #[no_mangle]
2223 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2224         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2225         *inner_val
2226 }
2227 /// The specific output index funding this channel
2228 #[no_mangle]
2229 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2230         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2231 }
2232 /// The signature of the channel initiator (funder) on the initial commitment transaction
2233 #[no_mangle]
2234 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::ECDSASignature {
2235         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2236         crate::c_types::ECDSASignature::from_rust(&inner_val)
2237 }
2238 /// The signature of the channel initiator (funder) on the initial commitment transaction
2239 #[no_mangle]
2240 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::ECDSASignature) {
2241         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2242 }
2243 /// Constructs a new FundingCreated given each field
2244 #[must_use]
2245 #[no_mangle]
2246 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::ECDSASignature) -> FundingCreated {
2247         FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2248                 temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) },
2249                 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2250                 funding_output_index: funding_output_index_arg,
2251                 signature: signature_arg.into_rust(),
2252         }), is_owned: true }
2253 }
2254 impl Clone for FundingCreated {
2255         fn clone(&self) -> Self {
2256                 Self {
2257                         inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2258                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2259                         is_owned: true,
2260                 }
2261         }
2262 }
2263 #[allow(unused)]
2264 /// Used only if an object of this type is returned as a trait impl by a method
2265 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2266         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingCreated)).clone() })) as *mut c_void
2267 }
2268 #[no_mangle]
2269 /// Creates a copy of the FundingCreated
2270 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2271         orig.clone()
2272 }
2273 /// Get a string which allows debug introspection of a FundingCreated object
2274 pub extern "C" fn FundingCreated_debug_str_void(o: *const c_void) -> Str {
2275         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::FundingCreated }).into()}
2276 /// Generates a non-cryptographic 64-bit hash of the FundingCreated.
2277 #[no_mangle]
2278 pub extern "C" fn FundingCreated_hash(o: &FundingCreated) -> u64 {
2279         if o.inner.is_null() { return 0; }
2280         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2281         #[allow(deprecated)]
2282         let mut hasher = core::hash::SipHasher::new();
2283         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2284         core::hash::Hasher::finish(&hasher)
2285 }
2286 /// Checks if two FundingCreateds contain equal inner contents.
2287 /// This ignores pointers and is_owned flags and looks at the values in fields.
2288 /// Two objects with NULL inner values will be considered "equal" here.
2289 #[no_mangle]
2290 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2291         if a.inner == b.inner { return true; }
2292         if a.inner.is_null() || b.inner.is_null() { return false; }
2293         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2294 }
2295
2296 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2297 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2298
2299 /// A [`funding_signed`] message to be sent to or received from a peer.
2300 ///
2301 /// Used in V1 channel establishment
2302 ///
2303 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2304 #[must_use]
2305 #[repr(C)]
2306 pub struct FundingSigned {
2307         /// A pointer to the opaque Rust object.
2308
2309         /// Nearly everywhere, inner must be non-null, however in places where
2310         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2311         pub inner: *mut nativeFundingSigned,
2312         /// Indicates that this is the only struct which contains the same pointer.
2313
2314         /// Rust functions which take ownership of an object provided via an argument require
2315         /// this to be true and invalidate the object pointed to by inner.
2316         pub is_owned: bool,
2317 }
2318
2319 impl Drop for FundingSigned {
2320         fn drop(&mut self) {
2321                 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2322                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2323                 }
2324         }
2325 }
2326 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2327 #[no_mangle]
2328 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2329 #[allow(unused)]
2330 /// Used only if an object of this type is returned as a trait impl by a method
2331 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2332         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2333 }
2334 #[allow(unused)]
2335 impl FundingSigned {
2336         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2337                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2338         }
2339         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2340                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2341         }
2342         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2343         pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2344                 assert!(self.is_owned);
2345                 let ret = ObjOps::untweak_ptr(self.inner);
2346                 self.inner = core::ptr::null_mut();
2347                 ret
2348         }
2349 }
2350 /// The channel ID
2351 #[no_mangle]
2352 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> crate::lightning::ln::types::ChannelId {
2353         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2354         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2355 }
2356 /// The channel ID
2357 #[no_mangle]
2358 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::lightning::ln::types::ChannelId) {
2359         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2360 }
2361 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2362 #[no_mangle]
2363 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::ECDSASignature {
2364         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2365         crate::c_types::ECDSASignature::from_rust(&inner_val)
2366 }
2367 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2368 #[no_mangle]
2369 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::ECDSASignature) {
2370         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2371 }
2372 /// Constructs a new FundingSigned given each field
2373 #[must_use]
2374 #[no_mangle]
2375 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned {
2376         FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2377                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2378                 signature: signature_arg.into_rust(),
2379         }), is_owned: true }
2380 }
2381 impl Clone for FundingSigned {
2382         fn clone(&self) -> Self {
2383                 Self {
2384                         inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2385                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2386                         is_owned: true,
2387                 }
2388         }
2389 }
2390 #[allow(unused)]
2391 /// Used only if an object of this type is returned as a trait impl by a method
2392 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2393         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingSigned)).clone() })) as *mut c_void
2394 }
2395 #[no_mangle]
2396 /// Creates a copy of the FundingSigned
2397 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2398         orig.clone()
2399 }
2400 /// Get a string which allows debug introspection of a FundingSigned object
2401 pub extern "C" fn FundingSigned_debug_str_void(o: *const c_void) -> Str {
2402         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::FundingSigned }).into()}
2403 /// Generates a non-cryptographic 64-bit hash of the FundingSigned.
2404 #[no_mangle]
2405 pub extern "C" fn FundingSigned_hash(o: &FundingSigned) -> u64 {
2406         if o.inner.is_null() { return 0; }
2407         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2408         #[allow(deprecated)]
2409         let mut hasher = core::hash::SipHasher::new();
2410         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2411         core::hash::Hasher::finish(&hasher)
2412 }
2413 /// Checks if two FundingSigneds contain equal inner contents.
2414 /// This ignores pointers and is_owned flags and looks at the values in fields.
2415 /// Two objects with NULL inner values will be considered "equal" here.
2416 #[no_mangle]
2417 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2418         if a.inner == b.inner { return true; }
2419         if a.inner.is_null() || b.inner.is_null() { return false; }
2420         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2421 }
2422
2423 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2424 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2425
2426 /// A [`channel_ready`] message to be sent to or received from a peer.
2427 ///
2428 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2429 #[must_use]
2430 #[repr(C)]
2431 pub struct ChannelReady {
2432         /// A pointer to the opaque Rust object.
2433
2434         /// Nearly everywhere, inner must be non-null, however in places where
2435         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2436         pub inner: *mut nativeChannelReady,
2437         /// Indicates that this is the only struct which contains the same pointer.
2438
2439         /// Rust functions which take ownership of an object provided via an argument require
2440         /// this to be true and invalidate the object pointed to by inner.
2441         pub is_owned: bool,
2442 }
2443
2444 impl Drop for ChannelReady {
2445         fn drop(&mut self) {
2446                 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2447                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2448                 }
2449         }
2450 }
2451 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2452 #[no_mangle]
2453 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2454 #[allow(unused)]
2455 /// Used only if an object of this type is returned as a trait impl by a method
2456 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2457         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2458 }
2459 #[allow(unused)]
2460 impl ChannelReady {
2461         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2462                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2463         }
2464         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2465                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2466         }
2467         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2468         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2469                 assert!(self.is_owned);
2470                 let ret = ObjOps::untweak_ptr(self.inner);
2471                 self.inner = core::ptr::null_mut();
2472                 ret
2473         }
2474 }
2475 /// The channel ID
2476 #[no_mangle]
2477 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> crate::lightning::ln::types::ChannelId {
2478         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2479         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2480 }
2481 /// The channel ID
2482 #[no_mangle]
2483 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::lightning::ln::types::ChannelId) {
2484         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2485 }
2486 /// The per-commitment point of the second commitment transaction
2487 #[no_mangle]
2488 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2489         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2490         crate::c_types::PublicKey::from_rust(&inner_val)
2491 }
2492 /// The per-commitment point of the second commitment transaction
2493 #[no_mangle]
2494 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2495         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2496 }
2497 /// If set, provides a `short_channel_id` alias for this channel.
2498 ///
2499 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2500 /// messages' recipient.
2501 #[no_mangle]
2502 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2503         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2504         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
2505         local_inner_val
2506 }
2507 /// If set, provides a `short_channel_id` alias for this channel.
2508 ///
2509 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2510 /// messages' recipient.
2511 #[no_mangle]
2512 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2513         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2514         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2515 }
2516 /// Constructs a new ChannelReady given each field
2517 #[must_use]
2518 #[no_mangle]
2519 pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady {
2520         let mut local_short_channel_id_alias_arg = if short_channel_id_alias_arg.is_some() { Some( { short_channel_id_alias_arg.take() }) } else { None };
2521         ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2522                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2523                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2524                 short_channel_id_alias: local_short_channel_id_alias_arg,
2525         }), is_owned: true }
2526 }
2527 impl Clone for ChannelReady {
2528         fn clone(&self) -> Self {
2529                 Self {
2530                         inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2531                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2532                         is_owned: true,
2533                 }
2534         }
2535 }
2536 #[allow(unused)]
2537 /// Used only if an object of this type is returned as a trait impl by a method
2538 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2539         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReady)).clone() })) as *mut c_void
2540 }
2541 #[no_mangle]
2542 /// Creates a copy of the ChannelReady
2543 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2544         orig.clone()
2545 }
2546 /// Get a string which allows debug introspection of a ChannelReady object
2547 pub extern "C" fn ChannelReady_debug_str_void(o: *const c_void) -> Str {
2548         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelReady }).into()}
2549 /// Generates a non-cryptographic 64-bit hash of the ChannelReady.
2550 #[no_mangle]
2551 pub extern "C" fn ChannelReady_hash(o: &ChannelReady) -> u64 {
2552         if o.inner.is_null() { return 0; }
2553         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2554         #[allow(deprecated)]
2555         let mut hasher = core::hash::SipHasher::new();
2556         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2557         core::hash::Hasher::finish(&hasher)
2558 }
2559 /// Checks if two ChannelReadys contain equal inner contents.
2560 /// This ignores pointers and is_owned flags and looks at the values in fields.
2561 /// Two objects with NULL inner values will be considered "equal" here.
2562 #[no_mangle]
2563 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2564         if a.inner == b.inner { return true; }
2565         if a.inner.is_null() || b.inner.is_null() { return false; }
2566         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2567 }
2568
2569 use lightning::ln::msgs::Stfu as nativeStfuImport;
2570 pub(crate) type nativeStfu = nativeStfuImport;
2571
2572 /// An stfu (quiescence) message to be sent by or received from the stfu initiator.
2573 #[must_use]
2574 #[repr(C)]
2575 pub struct Stfu {
2576         /// A pointer to the opaque Rust object.
2577
2578         /// Nearly everywhere, inner must be non-null, however in places where
2579         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2580         pub inner: *mut nativeStfu,
2581         /// Indicates that this is the only struct which contains the same pointer.
2582
2583         /// Rust functions which take ownership of an object provided via an argument require
2584         /// this to be true and invalidate the object pointed to by inner.
2585         pub is_owned: bool,
2586 }
2587
2588 impl Drop for Stfu {
2589         fn drop(&mut self) {
2590                 if self.is_owned && !<*mut nativeStfu>::is_null(self.inner) {
2591                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2592                 }
2593         }
2594 }
2595 /// Frees any resources used by the Stfu, if is_owned is set and inner is non-NULL.
2596 #[no_mangle]
2597 pub extern "C" fn Stfu_free(this_obj: Stfu) { }
2598 #[allow(unused)]
2599 /// Used only if an object of this type is returned as a trait impl by a method
2600 pub(crate) extern "C" fn Stfu_free_void(this_ptr: *mut c_void) {
2601         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeStfu) };
2602 }
2603 #[allow(unused)]
2604 impl Stfu {
2605         pub(crate) fn get_native_ref(&self) -> &'static nativeStfu {
2606                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2607         }
2608         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeStfu {
2609                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2610         }
2611         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2612         pub(crate) fn take_inner(mut self) -> *mut nativeStfu {
2613                 assert!(self.is_owned);
2614                 let ret = ObjOps::untweak_ptr(self.inner);
2615                 self.inner = core::ptr::null_mut();
2616                 ret
2617         }
2618 }
2619 /// The channel ID where quiescence is intended
2620 #[no_mangle]
2621 pub extern "C" fn Stfu_get_channel_id(this_ptr: &Stfu) -> crate::lightning::ln::types::ChannelId {
2622         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2623         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2624 }
2625 /// The channel ID where quiescence is intended
2626 #[no_mangle]
2627 pub extern "C" fn Stfu_set_channel_id(this_ptr: &mut Stfu, mut val: crate::lightning::ln::types::ChannelId) {
2628         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2629 }
2630 /// Initiator flag, 1 if initiating, 0 if replying to an stfu.
2631 #[no_mangle]
2632 pub extern "C" fn Stfu_get_initiator(this_ptr: &Stfu) -> u8 {
2633         let mut inner_val = &mut this_ptr.get_native_mut_ref().initiator;
2634         *inner_val
2635 }
2636 /// Initiator flag, 1 if initiating, 0 if replying to an stfu.
2637 #[no_mangle]
2638 pub extern "C" fn Stfu_set_initiator(this_ptr: &mut Stfu, mut val: u8) {
2639         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.initiator = val;
2640 }
2641 /// Constructs a new Stfu given each field
2642 #[must_use]
2643 #[no_mangle]
2644 pub extern "C" fn Stfu_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut initiator_arg: u8) -> Stfu {
2645         Stfu { inner: ObjOps::heap_alloc(nativeStfu {
2646                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2647                 initiator: initiator_arg,
2648         }), is_owned: true }
2649 }
2650 impl Clone for Stfu {
2651         fn clone(&self) -> Self {
2652                 Self {
2653                         inner: if <*mut nativeStfu>::is_null(self.inner) { core::ptr::null_mut() } else {
2654                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2655                         is_owned: true,
2656                 }
2657         }
2658 }
2659 #[allow(unused)]
2660 /// Used only if an object of this type is returned as a trait impl by a method
2661 pub(crate) extern "C" fn Stfu_clone_void(this_ptr: *const c_void) -> *mut c_void {
2662         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeStfu)).clone() })) as *mut c_void
2663 }
2664 #[no_mangle]
2665 /// Creates a copy of the Stfu
2666 pub extern "C" fn Stfu_clone(orig: &Stfu) -> Stfu {
2667         orig.clone()
2668 }
2669 /// Get a string which allows debug introspection of a Stfu object
2670 pub extern "C" fn Stfu_debug_str_void(o: *const c_void) -> Str {
2671         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Stfu }).into()}
2672 /// Checks if two Stfus contain equal inner contents.
2673 /// This ignores pointers and is_owned flags and looks at the values in fields.
2674 /// Two objects with NULL inner values will be considered "equal" here.
2675 #[no_mangle]
2676 pub extern "C" fn Stfu_eq(a: &Stfu, b: &Stfu) -> bool {
2677         if a.inner == b.inner { return true; }
2678         if a.inner.is_null() || b.inner.is_null() { return false; }
2679         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2680 }
2681
2682 use lightning::ln::msgs::Splice as nativeSpliceImport;
2683 pub(crate) type nativeSplice = nativeSpliceImport;
2684
2685 /// A splice message to be sent by or received from the stfu initiator (splice initiator).
2686 #[must_use]
2687 #[repr(C)]
2688 pub struct Splice {
2689         /// A pointer to the opaque Rust object.
2690
2691         /// Nearly everywhere, inner must be non-null, however in places where
2692         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2693         pub inner: *mut nativeSplice,
2694         /// Indicates that this is the only struct which contains the same pointer.
2695
2696         /// Rust functions which take ownership of an object provided via an argument require
2697         /// this to be true and invalidate the object pointed to by inner.
2698         pub is_owned: bool,
2699 }
2700
2701 impl Drop for Splice {
2702         fn drop(&mut self) {
2703                 if self.is_owned && !<*mut nativeSplice>::is_null(self.inner) {
2704                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2705                 }
2706         }
2707 }
2708 /// Frees any resources used by the Splice, if is_owned is set and inner is non-NULL.
2709 #[no_mangle]
2710 pub extern "C" fn Splice_free(this_obj: Splice) { }
2711 #[allow(unused)]
2712 /// Used only if an object of this type is returned as a trait impl by a method
2713 pub(crate) extern "C" fn Splice_free_void(this_ptr: *mut c_void) {
2714         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSplice) };
2715 }
2716 #[allow(unused)]
2717 impl Splice {
2718         pub(crate) fn get_native_ref(&self) -> &'static nativeSplice {
2719                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2720         }
2721         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSplice {
2722                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2723         }
2724         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2725         pub(crate) fn take_inner(mut self) -> *mut nativeSplice {
2726                 assert!(self.is_owned);
2727                 let ret = ObjOps::untweak_ptr(self.inner);
2728                 self.inner = core::ptr::null_mut();
2729                 ret
2730         }
2731 }
2732 /// The channel ID where splicing is intended
2733 #[no_mangle]
2734 pub extern "C" fn Splice_get_channel_id(this_ptr: &Splice) -> crate::lightning::ln::types::ChannelId {
2735         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2736         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2737 }
2738 /// The channel ID where splicing is intended
2739 #[no_mangle]
2740 pub extern "C" fn Splice_set_channel_id(this_ptr: &mut Splice, mut val: crate::lightning::ln::types::ChannelId) {
2741         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2742 }
2743 /// The genesis hash of the blockchain where the channel is intended to be spliced
2744 #[no_mangle]
2745 pub extern "C" fn Splice_get_chain_hash(this_ptr: &Splice) -> *const [u8; 32] {
2746         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
2747         inner_val.as_ref()
2748 }
2749 /// The genesis hash of the blockchain where the channel is intended to be spliced
2750 #[no_mangle]
2751 pub extern "C" fn Splice_set_chain_hash(this_ptr: &mut Splice, mut val: crate::c_types::ThirtyTwoBytes) {
2752         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
2753 }
2754 /// The intended change in channel capacity: the amount to be added (positive value)
2755 /// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
2756 #[no_mangle]
2757 pub extern "C" fn Splice_get_relative_satoshis(this_ptr: &Splice) -> i64 {
2758         let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis;
2759         *inner_val
2760 }
2761 /// The intended change in channel capacity: the amount to be added (positive value)
2762 /// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
2763 #[no_mangle]
2764 pub extern "C" fn Splice_set_relative_satoshis(this_ptr: &mut Splice, mut val: i64) {
2765         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val;
2766 }
2767 /// The feerate for the new funding transaction, set by the splice initiator
2768 #[no_mangle]
2769 pub extern "C" fn Splice_get_funding_feerate_perkw(this_ptr: &Splice) -> u32 {
2770         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_perkw;
2771         *inner_val
2772 }
2773 /// The feerate for the new funding transaction, set by the splice initiator
2774 #[no_mangle]
2775 pub extern "C" fn Splice_set_funding_feerate_perkw(this_ptr: &mut Splice, mut val: u32) {
2776         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_perkw = val;
2777 }
2778 /// The locktime for the new funding transaction
2779 #[no_mangle]
2780 pub extern "C" fn Splice_get_locktime(this_ptr: &Splice) -> u32 {
2781         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
2782         *inner_val
2783 }
2784 /// The locktime for the new funding transaction
2785 #[no_mangle]
2786 pub extern "C" fn Splice_set_locktime(this_ptr: &mut Splice, mut val: u32) {
2787         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
2788 }
2789 /// The key of the sender (splice initiator) controlling the new funding transaction
2790 #[no_mangle]
2791 pub extern "C" fn Splice_get_funding_pubkey(this_ptr: &Splice) -> crate::c_types::PublicKey {
2792         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
2793         crate::c_types::PublicKey::from_rust(&inner_val)
2794 }
2795 /// The key of the sender (splice initiator) controlling the new funding transaction
2796 #[no_mangle]
2797 pub extern "C" fn Splice_set_funding_pubkey(this_ptr: &mut Splice, mut val: crate::c_types::PublicKey) {
2798         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
2799 }
2800 /// Constructs a new Splice given each field
2801 #[must_use]
2802 #[no_mangle]
2803 pub extern "C" fn Splice_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_feerate_perkw_arg: u32, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey) -> Splice {
2804         Splice { inner: ObjOps::heap_alloc(nativeSplice {
2805                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2806                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
2807                 relative_satoshis: relative_satoshis_arg,
2808                 funding_feerate_perkw: funding_feerate_perkw_arg,
2809                 locktime: locktime_arg,
2810                 funding_pubkey: funding_pubkey_arg.into_rust(),
2811         }), is_owned: true }
2812 }
2813 impl Clone for Splice {
2814         fn clone(&self) -> Self {
2815                 Self {
2816                         inner: if <*mut nativeSplice>::is_null(self.inner) { core::ptr::null_mut() } else {
2817                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2818                         is_owned: true,
2819                 }
2820         }
2821 }
2822 #[allow(unused)]
2823 /// Used only if an object of this type is returned as a trait impl by a method
2824 pub(crate) extern "C" fn Splice_clone_void(this_ptr: *const c_void) -> *mut c_void {
2825         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSplice)).clone() })) as *mut c_void
2826 }
2827 #[no_mangle]
2828 /// Creates a copy of the Splice
2829 pub extern "C" fn Splice_clone(orig: &Splice) -> Splice {
2830         orig.clone()
2831 }
2832 /// Get a string which allows debug introspection of a Splice object
2833 pub extern "C" fn Splice_debug_str_void(o: *const c_void) -> Str {
2834         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Splice }).into()}
2835 /// Checks if two Splices contain equal inner contents.
2836 /// This ignores pointers and is_owned flags and looks at the values in fields.
2837 /// Two objects with NULL inner values will be considered "equal" here.
2838 #[no_mangle]
2839 pub extern "C" fn Splice_eq(a: &Splice, b: &Splice) -> bool {
2840         if a.inner == b.inner { return true; }
2841         if a.inner.is_null() || b.inner.is_null() { return false; }
2842         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2843 }
2844
2845 use lightning::ln::msgs::SpliceAck as nativeSpliceAckImport;
2846 pub(crate) type nativeSpliceAck = nativeSpliceAckImport;
2847
2848 /// A splice_ack message to be received by or sent to the splice initiator.
2849 ///
2850 #[must_use]
2851 #[repr(C)]
2852 pub struct SpliceAck {
2853         /// A pointer to the opaque Rust object.
2854
2855         /// Nearly everywhere, inner must be non-null, however in places where
2856         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2857         pub inner: *mut nativeSpliceAck,
2858         /// Indicates that this is the only struct which contains the same pointer.
2859
2860         /// Rust functions which take ownership of an object provided via an argument require
2861         /// this to be true and invalidate the object pointed to by inner.
2862         pub is_owned: bool,
2863 }
2864
2865 impl Drop for SpliceAck {
2866         fn drop(&mut self) {
2867                 if self.is_owned && !<*mut nativeSpliceAck>::is_null(self.inner) {
2868                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2869                 }
2870         }
2871 }
2872 /// Frees any resources used by the SpliceAck, if is_owned is set and inner is non-NULL.
2873 #[no_mangle]
2874 pub extern "C" fn SpliceAck_free(this_obj: SpliceAck) { }
2875 #[allow(unused)]
2876 /// Used only if an object of this type is returned as a trait impl by a method
2877 pub(crate) extern "C" fn SpliceAck_free_void(this_ptr: *mut c_void) {
2878         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceAck) };
2879 }
2880 #[allow(unused)]
2881 impl SpliceAck {
2882         pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceAck {
2883                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2884         }
2885         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceAck {
2886                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2887         }
2888         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2889         pub(crate) fn take_inner(mut self) -> *mut nativeSpliceAck {
2890                 assert!(self.is_owned);
2891                 let ret = ObjOps::untweak_ptr(self.inner);
2892                 self.inner = core::ptr::null_mut();
2893                 ret
2894         }
2895 }
2896 /// The channel ID where splicing is intended
2897 #[no_mangle]
2898 pub extern "C" fn SpliceAck_get_channel_id(this_ptr: &SpliceAck) -> crate::lightning::ln::types::ChannelId {
2899         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2900         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2901 }
2902 /// The channel ID where splicing is intended
2903 #[no_mangle]
2904 pub extern "C" fn SpliceAck_set_channel_id(this_ptr: &mut SpliceAck, mut val: crate::lightning::ln::types::ChannelId) {
2905         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2906 }
2907 /// The genesis hash of the blockchain where the channel is intended to be spliced
2908 #[no_mangle]
2909 pub extern "C" fn SpliceAck_get_chain_hash(this_ptr: &SpliceAck) -> *const [u8; 32] {
2910         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
2911         inner_val.as_ref()
2912 }
2913 /// The genesis hash of the blockchain where the channel is intended to be spliced
2914 #[no_mangle]
2915 pub extern "C" fn SpliceAck_set_chain_hash(this_ptr: &mut SpliceAck, mut val: crate::c_types::ThirtyTwoBytes) {
2916         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
2917 }
2918 /// The intended change in channel capacity: the amount to be added (positive value)
2919 /// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
2920 #[no_mangle]
2921 pub extern "C" fn SpliceAck_get_relative_satoshis(this_ptr: &SpliceAck) -> i64 {
2922         let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis;
2923         *inner_val
2924 }
2925 /// The intended change in channel capacity: the amount to be added (positive value)
2926 /// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
2927 #[no_mangle]
2928 pub extern "C" fn SpliceAck_set_relative_satoshis(this_ptr: &mut SpliceAck, mut val: i64) {
2929         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val;
2930 }
2931 /// The key of the sender (splice acceptor) controlling the new funding transaction
2932 #[no_mangle]
2933 pub extern "C" fn SpliceAck_get_funding_pubkey(this_ptr: &SpliceAck) -> crate::c_types::PublicKey {
2934         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
2935         crate::c_types::PublicKey::from_rust(&inner_val)
2936 }
2937 /// The key of the sender (splice acceptor) controlling the new funding transaction
2938 #[no_mangle]
2939 pub extern "C" fn SpliceAck_set_funding_pubkey(this_ptr: &mut SpliceAck, mut val: crate::c_types::PublicKey) {
2940         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
2941 }
2942 /// Constructs a new SpliceAck given each field
2943 #[must_use]
2944 #[no_mangle]
2945 pub extern "C" fn SpliceAck_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_pubkey_arg: crate::c_types::PublicKey) -> SpliceAck {
2946         SpliceAck { inner: ObjOps::heap_alloc(nativeSpliceAck {
2947                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2948                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
2949                 relative_satoshis: relative_satoshis_arg,
2950                 funding_pubkey: funding_pubkey_arg.into_rust(),
2951         }), is_owned: true }
2952 }
2953 impl Clone for SpliceAck {
2954         fn clone(&self) -> Self {
2955                 Self {
2956                         inner: if <*mut nativeSpliceAck>::is_null(self.inner) { core::ptr::null_mut() } else {
2957                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2958                         is_owned: true,
2959                 }
2960         }
2961 }
2962 #[allow(unused)]
2963 /// Used only if an object of this type is returned as a trait impl by a method
2964 pub(crate) extern "C" fn SpliceAck_clone_void(this_ptr: *const c_void) -> *mut c_void {
2965         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceAck)).clone() })) as *mut c_void
2966 }
2967 #[no_mangle]
2968 /// Creates a copy of the SpliceAck
2969 pub extern "C" fn SpliceAck_clone(orig: &SpliceAck) -> SpliceAck {
2970         orig.clone()
2971 }
2972 /// Get a string which allows debug introspection of a SpliceAck object
2973 pub extern "C" fn SpliceAck_debug_str_void(o: *const c_void) -> Str {
2974         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceAck }).into()}
2975 /// Checks if two SpliceAcks contain equal inner contents.
2976 /// This ignores pointers and is_owned flags and looks at the values in fields.
2977 /// Two objects with NULL inner values will be considered "equal" here.
2978 #[no_mangle]
2979 pub extern "C" fn SpliceAck_eq(a: &SpliceAck, b: &SpliceAck) -> bool {
2980         if a.inner == b.inner { return true; }
2981         if a.inner.is_null() || b.inner.is_null() { return false; }
2982         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2983 }
2984
2985 use lightning::ln::msgs::SpliceLocked as nativeSpliceLockedImport;
2986 pub(crate) type nativeSpliceLocked = nativeSpliceLockedImport;
2987
2988 /// A splice_locked message to be sent to or received from a peer.
2989 ///
2990 #[must_use]
2991 #[repr(C)]
2992 pub struct SpliceLocked {
2993         /// A pointer to the opaque Rust object.
2994
2995         /// Nearly everywhere, inner must be non-null, however in places where
2996         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2997         pub inner: *mut nativeSpliceLocked,
2998         /// Indicates that this is the only struct which contains the same pointer.
2999
3000         /// Rust functions which take ownership of an object provided via an argument require
3001         /// this to be true and invalidate the object pointed to by inner.
3002         pub is_owned: bool,
3003 }
3004
3005 impl Drop for SpliceLocked {
3006         fn drop(&mut self) {
3007                 if self.is_owned && !<*mut nativeSpliceLocked>::is_null(self.inner) {
3008                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3009                 }
3010         }
3011 }
3012 /// Frees any resources used by the SpliceLocked, if is_owned is set and inner is non-NULL.
3013 #[no_mangle]
3014 pub extern "C" fn SpliceLocked_free(this_obj: SpliceLocked) { }
3015 #[allow(unused)]
3016 /// Used only if an object of this type is returned as a trait impl by a method
3017 pub(crate) extern "C" fn SpliceLocked_free_void(this_ptr: *mut c_void) {
3018         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceLocked) };
3019 }
3020 #[allow(unused)]
3021 impl SpliceLocked {
3022         pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceLocked {
3023                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3024         }
3025         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceLocked {
3026                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3027         }
3028         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3029         pub(crate) fn take_inner(mut self) -> *mut nativeSpliceLocked {
3030                 assert!(self.is_owned);
3031                 let ret = ObjOps::untweak_ptr(self.inner);
3032                 self.inner = core::ptr::null_mut();
3033                 ret
3034         }
3035 }
3036 /// The channel ID
3037 #[no_mangle]
3038 pub extern "C" fn SpliceLocked_get_channel_id(this_ptr: &SpliceLocked) -> crate::lightning::ln::types::ChannelId {
3039         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3040         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3041 }
3042 /// The channel ID
3043 #[no_mangle]
3044 pub extern "C" fn SpliceLocked_set_channel_id(this_ptr: &mut SpliceLocked, mut val: crate::lightning::ln::types::ChannelId) {
3045         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3046 }
3047 /// Constructs a new SpliceLocked given each field
3048 #[must_use]
3049 #[no_mangle]
3050 pub extern "C" fn SpliceLocked_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId) -> SpliceLocked {
3051         SpliceLocked { inner: ObjOps::heap_alloc(nativeSpliceLocked {
3052                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3053         }), is_owned: true }
3054 }
3055 impl Clone for SpliceLocked {
3056         fn clone(&self) -> Self {
3057                 Self {
3058                         inner: if <*mut nativeSpliceLocked>::is_null(self.inner) { core::ptr::null_mut() } else {
3059                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3060                         is_owned: true,
3061                 }
3062         }
3063 }
3064 #[allow(unused)]
3065 /// Used only if an object of this type is returned as a trait impl by a method
3066 pub(crate) extern "C" fn SpliceLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
3067         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceLocked)).clone() })) as *mut c_void
3068 }
3069 #[no_mangle]
3070 /// Creates a copy of the SpliceLocked
3071 pub extern "C" fn SpliceLocked_clone(orig: &SpliceLocked) -> SpliceLocked {
3072         orig.clone()
3073 }
3074 /// Get a string which allows debug introspection of a SpliceLocked object
3075 pub extern "C" fn SpliceLocked_debug_str_void(o: *const c_void) -> Str {
3076         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceLocked }).into()}
3077 /// Checks if two SpliceLockeds contain equal inner contents.
3078 /// This ignores pointers and is_owned flags and looks at the values in fields.
3079 /// Two objects with NULL inner values will be considered "equal" here.
3080 #[no_mangle]
3081 pub extern "C" fn SpliceLocked_eq(a: &SpliceLocked, b: &SpliceLocked) -> bool {
3082         if a.inner == b.inner { return true; }
3083         if a.inner.is_null() || b.inner.is_null() { return false; }
3084         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3085 }
3086
3087 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
3088 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
3089
3090 /// A tx_add_input message for adding an input during interactive transaction construction
3091 ///
3092 #[must_use]
3093 #[repr(C)]
3094 pub struct TxAddInput {
3095         /// A pointer to the opaque Rust object.
3096
3097         /// Nearly everywhere, inner must be non-null, however in places where
3098         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3099         pub inner: *mut nativeTxAddInput,
3100         /// Indicates that this is the only struct which contains the same pointer.
3101
3102         /// Rust functions which take ownership of an object provided via an argument require
3103         /// this to be true and invalidate the object pointed to by inner.
3104         pub is_owned: bool,
3105 }
3106
3107 impl Drop for TxAddInput {
3108         fn drop(&mut self) {
3109                 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
3110                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3111                 }
3112         }
3113 }
3114 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
3115 #[no_mangle]
3116 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
3117 #[allow(unused)]
3118 /// Used only if an object of this type is returned as a trait impl by a method
3119 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
3120         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
3121 }
3122 #[allow(unused)]
3123 impl TxAddInput {
3124         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
3125                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3126         }
3127         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
3128                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3129         }
3130         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3131         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
3132                 assert!(self.is_owned);
3133                 let ret = ObjOps::untweak_ptr(self.inner);
3134                 self.inner = core::ptr::null_mut();
3135                 ret
3136         }
3137 }
3138 /// The channel ID
3139 #[no_mangle]
3140 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> crate::lightning::ln::types::ChannelId {
3141         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3142         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3143 }
3144 /// The channel ID
3145 #[no_mangle]
3146 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::lightning::ln::types::ChannelId) {
3147         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3148 }
3149 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
3150 /// non-initiators.
3151 #[no_mangle]
3152 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
3153         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3154         *inner_val
3155 }
3156 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
3157 /// non-initiators.
3158 #[no_mangle]
3159 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
3160         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3161 }
3162 /// Serialized transaction that contains the output this input spends to verify that it is non
3163 /// malleable.
3164 #[no_mangle]
3165 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
3166         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
3167         crate::lightning::util::ser::TransactionU16LenLimited { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::ser::TransactionU16LenLimited<>) as *mut _) }, is_owned: false }
3168 }
3169 /// Serialized transaction that contains the output this input spends to verify that it is non
3170 /// malleable.
3171 #[no_mangle]
3172 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
3173         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
3174 }
3175 /// The index of the output being spent
3176 #[no_mangle]
3177 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
3178         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
3179         *inner_val
3180 }
3181 /// The index of the output being spent
3182 #[no_mangle]
3183 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
3184         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
3185 }
3186 /// The sequence number of this input
3187 #[no_mangle]
3188 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
3189         let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
3190         *inner_val
3191 }
3192 /// The sequence number of this input
3193 #[no_mangle]
3194 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
3195         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
3196 }
3197 /// Constructs a new TxAddInput given each field
3198 #[must_use]
3199 #[no_mangle]
3200 pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput {
3201         TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
3202                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3203                 serial_id: serial_id_arg,
3204                 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
3205                 prevtx_out: prevtx_out_arg,
3206                 sequence: sequence_arg,
3207         }), is_owned: true }
3208 }
3209 impl Clone for TxAddInput {
3210         fn clone(&self) -> Self {
3211                 Self {
3212                         inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
3213                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3214                         is_owned: true,
3215                 }
3216         }
3217 }
3218 #[allow(unused)]
3219 /// Used only if an object of this type is returned as a trait impl by a method
3220 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3221         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddInput)).clone() })) as *mut c_void
3222 }
3223 #[no_mangle]
3224 /// Creates a copy of the TxAddInput
3225 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
3226         orig.clone()
3227 }
3228 /// Get a string which allows debug introspection of a TxAddInput object
3229 pub extern "C" fn TxAddInput_debug_str_void(o: *const c_void) -> Str {
3230         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAddInput }).into()}
3231 /// Generates a non-cryptographic 64-bit hash of the TxAddInput.
3232 #[no_mangle]
3233 pub extern "C" fn TxAddInput_hash(o: &TxAddInput) -> u64 {
3234         if o.inner.is_null() { return 0; }
3235         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3236         #[allow(deprecated)]
3237         let mut hasher = core::hash::SipHasher::new();
3238         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3239         core::hash::Hasher::finish(&hasher)
3240 }
3241 /// Checks if two TxAddInputs contain equal inner contents.
3242 /// This ignores pointers and is_owned flags and looks at the values in fields.
3243 /// Two objects with NULL inner values will be considered "equal" here.
3244 #[no_mangle]
3245 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
3246         if a.inner == b.inner { return true; }
3247         if a.inner.is_null() || b.inner.is_null() { return false; }
3248         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3249 }
3250
3251 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
3252 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
3253
3254 /// A tx_add_output message for adding an output during interactive transaction construction.
3255 ///
3256 #[must_use]
3257 #[repr(C)]
3258 pub struct TxAddOutput {
3259         /// A pointer to the opaque Rust object.
3260
3261         /// Nearly everywhere, inner must be non-null, however in places where
3262         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3263         pub inner: *mut nativeTxAddOutput,
3264         /// Indicates that this is the only struct which contains the same pointer.
3265
3266         /// Rust functions which take ownership of an object provided via an argument require
3267         /// this to be true and invalidate the object pointed to by inner.
3268         pub is_owned: bool,
3269 }
3270
3271 impl Drop for TxAddOutput {
3272         fn drop(&mut self) {
3273                 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
3274                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3275                 }
3276         }
3277 }
3278 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
3279 #[no_mangle]
3280 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
3281 #[allow(unused)]
3282 /// Used only if an object of this type is returned as a trait impl by a method
3283 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
3284         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
3285 }
3286 #[allow(unused)]
3287 impl TxAddOutput {
3288         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
3289                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3290         }
3291         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
3292                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3293         }
3294         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3295         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
3296                 assert!(self.is_owned);
3297                 let ret = ObjOps::untweak_ptr(self.inner);
3298                 self.inner = core::ptr::null_mut();
3299                 ret
3300         }
3301 }
3302 /// The channel ID
3303 #[no_mangle]
3304 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> crate::lightning::ln::types::ChannelId {
3305         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3306         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3307 }
3308 /// The channel ID
3309 #[no_mangle]
3310 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::lightning::ln::types::ChannelId) {
3311         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3312 }
3313 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
3314 /// non-initiators.
3315 #[no_mangle]
3316 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
3317         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3318         *inner_val
3319 }
3320 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
3321 /// non-initiators.
3322 #[no_mangle]
3323 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
3324         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3325 }
3326 /// The satoshi value of the output
3327 #[no_mangle]
3328 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
3329         let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
3330         *inner_val
3331 }
3332 /// The satoshi value of the output
3333 #[no_mangle]
3334 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
3335         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
3336 }
3337 /// The scriptPubKey for the output
3338 #[no_mangle]
3339 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
3340         let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
3341         inner_val.as_bytes().to_vec().into()
3342 }
3343 /// The scriptPubKey for the output
3344 #[no_mangle]
3345 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
3346         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust());
3347 }
3348 /// Constructs a new TxAddOutput given each field
3349 #[must_use]
3350 #[no_mangle]
3351 pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput {
3352         TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
3353                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3354                 serial_id: serial_id_arg,
3355                 sats: sats_arg,
3356                 script: ::bitcoin::blockdata::script::ScriptBuf::from(script_arg.into_rust()),
3357         }), is_owned: true }
3358 }
3359 impl Clone for TxAddOutput {
3360         fn clone(&self) -> Self {
3361                 Self {
3362                         inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3363                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3364                         is_owned: true,
3365                 }
3366         }
3367 }
3368 #[allow(unused)]
3369 /// Used only if an object of this type is returned as a trait impl by a method
3370 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3371         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddOutput)).clone() })) as *mut c_void
3372 }
3373 #[no_mangle]
3374 /// Creates a copy of the TxAddOutput
3375 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
3376         orig.clone()
3377 }
3378 /// Get a string which allows debug introspection of a TxAddOutput object
3379 pub extern "C" fn TxAddOutput_debug_str_void(o: *const c_void) -> Str {
3380         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAddOutput }).into()}
3381 /// Generates a non-cryptographic 64-bit hash of the TxAddOutput.
3382 #[no_mangle]
3383 pub extern "C" fn TxAddOutput_hash(o: &TxAddOutput) -> u64 {
3384         if o.inner.is_null() { return 0; }
3385         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3386         #[allow(deprecated)]
3387         let mut hasher = core::hash::SipHasher::new();
3388         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3389         core::hash::Hasher::finish(&hasher)
3390 }
3391 /// Checks if two TxAddOutputs contain equal inner contents.
3392 /// This ignores pointers and is_owned flags and looks at the values in fields.
3393 /// Two objects with NULL inner values will be considered "equal" here.
3394 #[no_mangle]
3395 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
3396         if a.inner == b.inner { return true; }
3397         if a.inner.is_null() || b.inner.is_null() { return false; }
3398         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3399 }
3400
3401 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
3402 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
3403
3404 /// A tx_remove_input message for removing an input during interactive transaction construction.
3405 ///
3406 #[must_use]
3407 #[repr(C)]
3408 pub struct TxRemoveInput {
3409         /// A pointer to the opaque Rust object.
3410
3411         /// Nearly everywhere, inner must be non-null, however in places where
3412         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3413         pub inner: *mut nativeTxRemoveInput,
3414         /// Indicates that this is the only struct which contains the same pointer.
3415
3416         /// Rust functions which take ownership of an object provided via an argument require
3417         /// this to be true and invalidate the object pointed to by inner.
3418         pub is_owned: bool,
3419 }
3420
3421 impl Drop for TxRemoveInput {
3422         fn drop(&mut self) {
3423                 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
3424                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3425                 }
3426         }
3427 }
3428 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
3429 #[no_mangle]
3430 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
3431 #[allow(unused)]
3432 /// Used only if an object of this type is returned as a trait impl by a method
3433 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
3434         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
3435 }
3436 #[allow(unused)]
3437 impl TxRemoveInput {
3438         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
3439                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3440         }
3441         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
3442                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3443         }
3444         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3445         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
3446                 assert!(self.is_owned);
3447                 let ret = ObjOps::untweak_ptr(self.inner);
3448                 self.inner = core::ptr::null_mut();
3449                 ret
3450         }
3451 }
3452 /// The channel ID
3453 #[no_mangle]
3454 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> crate::lightning::ln::types::ChannelId {
3455         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3456         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3457 }
3458 /// The channel ID
3459 #[no_mangle]
3460 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::lightning::ln::types::ChannelId) {
3461         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3462 }
3463 /// The serial ID of the input to be removed
3464 #[no_mangle]
3465 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
3466         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3467         *inner_val
3468 }
3469 /// The serial ID of the input to be removed
3470 #[no_mangle]
3471 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
3472         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3473 }
3474 /// Constructs a new TxRemoveInput given each field
3475 #[must_use]
3476 #[no_mangle]
3477 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64) -> TxRemoveInput {
3478         TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
3479                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3480                 serial_id: serial_id_arg,
3481         }), is_owned: true }
3482 }
3483 impl Clone for TxRemoveInput {
3484         fn clone(&self) -> Self {
3485                 Self {
3486                         inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
3487                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3488                         is_owned: true,
3489                 }
3490         }
3491 }
3492 #[allow(unused)]
3493 /// Used only if an object of this type is returned as a trait impl by a method
3494 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3495         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveInput)).clone() })) as *mut c_void
3496 }
3497 #[no_mangle]
3498 /// Creates a copy of the TxRemoveInput
3499 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
3500         orig.clone()
3501 }
3502 /// Get a string which allows debug introspection of a TxRemoveInput object
3503 pub extern "C" fn TxRemoveInput_debug_str_void(o: *const c_void) -> Str {
3504         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxRemoveInput }).into()}
3505 /// Generates a non-cryptographic 64-bit hash of the TxRemoveInput.
3506 #[no_mangle]
3507 pub extern "C" fn TxRemoveInput_hash(o: &TxRemoveInput) -> u64 {
3508         if o.inner.is_null() { return 0; }
3509         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3510         #[allow(deprecated)]
3511         let mut hasher = core::hash::SipHasher::new();
3512         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3513         core::hash::Hasher::finish(&hasher)
3514 }
3515 /// Checks if two TxRemoveInputs contain equal inner contents.
3516 /// This ignores pointers and is_owned flags and looks at the values in fields.
3517 /// Two objects with NULL inner values will be considered "equal" here.
3518 #[no_mangle]
3519 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
3520         if a.inner == b.inner { return true; }
3521         if a.inner.is_null() || b.inner.is_null() { return false; }
3522         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3523 }
3524
3525 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
3526 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
3527
3528 /// A tx_remove_output message for removing an output during interactive transaction construction.
3529 ///
3530 #[must_use]
3531 #[repr(C)]
3532 pub struct TxRemoveOutput {
3533         /// A pointer to the opaque Rust object.
3534
3535         /// Nearly everywhere, inner must be non-null, however in places where
3536         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3537         pub inner: *mut nativeTxRemoveOutput,
3538         /// Indicates that this is the only struct which contains the same pointer.
3539
3540         /// Rust functions which take ownership of an object provided via an argument require
3541         /// this to be true and invalidate the object pointed to by inner.
3542         pub is_owned: bool,
3543 }
3544
3545 impl Drop for TxRemoveOutput {
3546         fn drop(&mut self) {
3547                 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
3548                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3549                 }
3550         }
3551 }
3552 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
3553 #[no_mangle]
3554 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
3555 #[allow(unused)]
3556 /// Used only if an object of this type is returned as a trait impl by a method
3557 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
3558         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
3559 }
3560 #[allow(unused)]
3561 impl TxRemoveOutput {
3562         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
3563                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3564         }
3565         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
3566                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3567         }
3568         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3569         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
3570                 assert!(self.is_owned);
3571                 let ret = ObjOps::untweak_ptr(self.inner);
3572                 self.inner = core::ptr::null_mut();
3573                 ret
3574         }
3575 }
3576 /// The channel ID
3577 #[no_mangle]
3578 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> crate::lightning::ln::types::ChannelId {
3579         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3580         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3581 }
3582 /// The channel ID
3583 #[no_mangle]
3584 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::lightning::ln::types::ChannelId) {
3585         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3586 }
3587 /// The serial ID of the output to be removed
3588 #[no_mangle]
3589 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3590         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3591         *inner_val
3592 }
3593 /// The serial ID of the output to be removed
3594 #[no_mangle]
3595 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3596         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3597 }
3598 /// Constructs a new TxRemoveOutput given each field
3599 #[must_use]
3600 #[no_mangle]
3601 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64) -> TxRemoveOutput {
3602         TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3603                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3604                 serial_id: serial_id_arg,
3605         }), is_owned: true }
3606 }
3607 impl Clone for TxRemoveOutput {
3608         fn clone(&self) -> Self {
3609                 Self {
3610                         inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3611                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3612                         is_owned: true,
3613                 }
3614         }
3615 }
3616 #[allow(unused)]
3617 /// Used only if an object of this type is returned as a trait impl by a method
3618 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3619         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveOutput)).clone() })) as *mut c_void
3620 }
3621 #[no_mangle]
3622 /// Creates a copy of the TxRemoveOutput
3623 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3624         orig.clone()
3625 }
3626 /// Get a string which allows debug introspection of a TxRemoveOutput object
3627 pub extern "C" fn TxRemoveOutput_debug_str_void(o: *const c_void) -> Str {
3628         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxRemoveOutput }).into()}
3629 /// Generates a non-cryptographic 64-bit hash of the TxRemoveOutput.
3630 #[no_mangle]
3631 pub extern "C" fn TxRemoveOutput_hash(o: &TxRemoveOutput) -> u64 {
3632         if o.inner.is_null() { return 0; }
3633         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3634         #[allow(deprecated)]
3635         let mut hasher = core::hash::SipHasher::new();
3636         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3637         core::hash::Hasher::finish(&hasher)
3638 }
3639 /// Checks if two TxRemoveOutputs contain equal inner contents.
3640 /// This ignores pointers and is_owned flags and looks at the values in fields.
3641 /// Two objects with NULL inner values will be considered "equal" here.
3642 #[no_mangle]
3643 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3644         if a.inner == b.inner { return true; }
3645         if a.inner.is_null() || b.inner.is_null() { return false; }
3646         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3647 }
3648
3649 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3650 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3651
3652 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3653 /// interactive transaction construction.
3654 ///
3655 #[must_use]
3656 #[repr(C)]
3657 pub struct TxComplete {
3658         /// A pointer to the opaque Rust object.
3659
3660         /// Nearly everywhere, inner must be non-null, however in places where
3661         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3662         pub inner: *mut nativeTxComplete,
3663         /// Indicates that this is the only struct which contains the same pointer.
3664
3665         /// Rust functions which take ownership of an object provided via an argument require
3666         /// this to be true and invalidate the object pointed to by inner.
3667         pub is_owned: bool,
3668 }
3669
3670 impl Drop for TxComplete {
3671         fn drop(&mut self) {
3672                 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3673                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3674                 }
3675         }
3676 }
3677 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3678 #[no_mangle]
3679 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3680 #[allow(unused)]
3681 /// Used only if an object of this type is returned as a trait impl by a method
3682 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3683         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3684 }
3685 #[allow(unused)]
3686 impl TxComplete {
3687         pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3688                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3689         }
3690         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3691                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3692         }
3693         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3694         pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3695                 assert!(self.is_owned);
3696                 let ret = ObjOps::untweak_ptr(self.inner);
3697                 self.inner = core::ptr::null_mut();
3698                 ret
3699         }
3700 }
3701 /// The channel ID
3702 #[no_mangle]
3703 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> crate::lightning::ln::types::ChannelId {
3704         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3705         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3706 }
3707 /// The channel ID
3708 #[no_mangle]
3709 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::lightning::ln::types::ChannelId) {
3710         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3711 }
3712 /// Constructs a new TxComplete given each field
3713 #[must_use]
3714 #[no_mangle]
3715 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId) -> TxComplete {
3716         TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3717                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3718         }), is_owned: true }
3719 }
3720 impl Clone for TxComplete {
3721         fn clone(&self) -> Self {
3722                 Self {
3723                         inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3724                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3725                         is_owned: true,
3726                 }
3727         }
3728 }
3729 #[allow(unused)]
3730 /// Used only if an object of this type is returned as a trait impl by a method
3731 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3732         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxComplete)).clone() })) as *mut c_void
3733 }
3734 #[no_mangle]
3735 /// Creates a copy of the TxComplete
3736 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3737         orig.clone()
3738 }
3739 /// Get a string which allows debug introspection of a TxComplete object
3740 pub extern "C" fn TxComplete_debug_str_void(o: *const c_void) -> Str {
3741         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxComplete }).into()}
3742 /// Generates a non-cryptographic 64-bit hash of the TxComplete.
3743 #[no_mangle]
3744 pub extern "C" fn TxComplete_hash(o: &TxComplete) -> u64 {
3745         if o.inner.is_null() { return 0; }
3746         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3747         #[allow(deprecated)]
3748         let mut hasher = core::hash::SipHasher::new();
3749         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3750         core::hash::Hasher::finish(&hasher)
3751 }
3752 /// Checks if two TxCompletes contain equal inner contents.
3753 /// This ignores pointers and is_owned flags and looks at the values in fields.
3754 /// Two objects with NULL inner values will be considered "equal" here.
3755 #[no_mangle]
3756 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3757         if a.inner == b.inner { return true; }
3758         if a.inner.is_null() || b.inner.is_null() { return false; }
3759         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3760 }
3761
3762 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3763 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3764
3765 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3766 /// interactive transaction construction.
3767 ///
3768 #[must_use]
3769 #[repr(C)]
3770 pub struct TxSignatures {
3771         /// A pointer to the opaque Rust object.
3772
3773         /// Nearly everywhere, inner must be non-null, however in places where
3774         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3775         pub inner: *mut nativeTxSignatures,
3776         /// Indicates that this is the only struct which contains the same pointer.
3777
3778         /// Rust functions which take ownership of an object provided via an argument require
3779         /// this to be true and invalidate the object pointed to by inner.
3780         pub is_owned: bool,
3781 }
3782
3783 impl Drop for TxSignatures {
3784         fn drop(&mut self) {
3785                 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3786                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3787                 }
3788         }
3789 }
3790 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3791 #[no_mangle]
3792 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3793 #[allow(unused)]
3794 /// Used only if an object of this type is returned as a trait impl by a method
3795 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3796         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3797 }
3798 #[allow(unused)]
3799 impl TxSignatures {
3800         pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3801                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3802         }
3803         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3804                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3805         }
3806         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3807         pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3808                 assert!(self.is_owned);
3809                 let ret = ObjOps::untweak_ptr(self.inner);
3810                 self.inner = core::ptr::null_mut();
3811                 ret
3812         }
3813 }
3814 /// The channel ID
3815 #[no_mangle]
3816 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> crate::lightning::ln::types::ChannelId {
3817         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3818         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3819 }
3820 /// The channel ID
3821 #[no_mangle]
3822 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::lightning::ln::types::ChannelId) {
3823         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3824 }
3825 /// The TXID
3826 #[no_mangle]
3827 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3828         let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3829         inner_val.as_ref()
3830 }
3831 /// The TXID
3832 #[no_mangle]
3833 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3834         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3835 }
3836 /// The list of witnesses
3837 ///
3838 /// Returns a copy of the field.
3839 #[no_mangle]
3840 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3841         let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
3842         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Witness::from_bitcoin(&item) }); };
3843         local_inner_val.into()
3844 }
3845 /// The list of witnesses
3846 #[no_mangle]
3847 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
3848         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
3849         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
3850 }
3851 /// Optional signature for the shared input -- the previous funding outpoint -- signed by both peers
3852 #[no_mangle]
3853 pub extern "C" fn TxSignatures_get_funding_outpoint_sig(this_ptr: &TxSignatures) -> crate::c_types::derived::COption_ECDSASignatureZ {
3854         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_outpoint_sig;
3855         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ECDSASignatureZ::None } else { crate::c_types::derived::COption_ECDSASignatureZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ECDSASignature::from_rust(&(*inner_val.as_ref().unwrap()).clone()) }) };
3856         local_inner_val
3857 }
3858 /// Optional signature for the shared input -- the previous funding outpoint -- signed by both peers
3859 #[no_mangle]
3860 pub extern "C" fn TxSignatures_set_funding_outpoint_sig(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::COption_ECDSASignatureZ) {
3861         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_rust() }})} };
3862         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_outpoint_sig = local_val;
3863 }
3864 /// Constructs a new TxSignatures given each field
3865 #[must_use]
3866 #[no_mangle]
3867 pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ, mut funding_outpoint_sig_arg: crate::c_types::derived::COption_ECDSASignatureZ) -> TxSignatures {
3868         let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
3869         let mut local_funding_outpoint_sig_arg = { /*funding_outpoint_sig_arg*/ let funding_outpoint_sig_arg_opt = funding_outpoint_sig_arg; if funding_outpoint_sig_arg_opt.is_none() { None } else { Some({ { { funding_outpoint_sig_arg_opt.take() }.into_rust() }})} };
3870         TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
3871                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3872                 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
3873                 witnesses: local_witnesses_arg,
3874                 funding_outpoint_sig: local_funding_outpoint_sig_arg,
3875         }), is_owned: true }
3876 }
3877 impl Clone for TxSignatures {
3878         fn clone(&self) -> Self {
3879                 Self {
3880                         inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3881                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3882                         is_owned: true,
3883                 }
3884         }
3885 }
3886 #[allow(unused)]
3887 /// Used only if an object of this type is returned as a trait impl by a method
3888 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3889         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxSignatures)).clone() })) as *mut c_void
3890 }
3891 #[no_mangle]
3892 /// Creates a copy of the TxSignatures
3893 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
3894         orig.clone()
3895 }
3896 /// Get a string which allows debug introspection of a TxSignatures object
3897 pub extern "C" fn TxSignatures_debug_str_void(o: *const c_void) -> Str {
3898         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxSignatures }).into()}
3899 /// Generates a non-cryptographic 64-bit hash of the TxSignatures.
3900 #[no_mangle]
3901 pub extern "C" fn TxSignatures_hash(o: &TxSignatures) -> u64 {
3902         if o.inner.is_null() { return 0; }
3903         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3904         #[allow(deprecated)]
3905         let mut hasher = core::hash::SipHasher::new();
3906         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3907         core::hash::Hasher::finish(&hasher)
3908 }
3909 /// Checks if two TxSignaturess contain equal inner contents.
3910 /// This ignores pointers and is_owned flags and looks at the values in fields.
3911 /// Two objects with NULL inner values will be considered "equal" here.
3912 #[no_mangle]
3913 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
3914         if a.inner == b.inner { return true; }
3915         if a.inner.is_null() || b.inner.is_null() { return false; }
3916         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3917 }
3918
3919 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
3920 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
3921
3922 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
3923 /// completed.
3924 ///
3925 #[must_use]
3926 #[repr(C)]
3927 pub struct TxInitRbf {
3928         /// A pointer to the opaque Rust object.
3929
3930         /// Nearly everywhere, inner must be non-null, however in places where
3931         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3932         pub inner: *mut nativeTxInitRbf,
3933         /// Indicates that this is the only struct which contains the same pointer.
3934
3935         /// Rust functions which take ownership of an object provided via an argument require
3936         /// this to be true and invalidate the object pointed to by inner.
3937         pub is_owned: bool,
3938 }
3939
3940 impl Drop for TxInitRbf {
3941         fn drop(&mut self) {
3942                 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
3943                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3944                 }
3945         }
3946 }
3947 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
3948 #[no_mangle]
3949 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
3950 #[allow(unused)]
3951 /// Used only if an object of this type is returned as a trait impl by a method
3952 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
3953         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
3954 }
3955 #[allow(unused)]
3956 impl TxInitRbf {
3957         pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
3958                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3959         }
3960         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
3961                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3962         }
3963         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3964         pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
3965                 assert!(self.is_owned);
3966                 let ret = ObjOps::untweak_ptr(self.inner);
3967                 self.inner = core::ptr::null_mut();
3968                 ret
3969         }
3970 }
3971 /// The channel ID
3972 #[no_mangle]
3973 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> crate::lightning::ln::types::ChannelId {
3974         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3975         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3976 }
3977 /// The channel ID
3978 #[no_mangle]
3979 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::lightning::ln::types::ChannelId) {
3980         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3981 }
3982 /// The locktime of the transaction
3983 #[no_mangle]
3984 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
3985         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
3986         *inner_val
3987 }
3988 /// The locktime of the transaction
3989 #[no_mangle]
3990 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
3991         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
3992 }
3993 /// The feerate of the transaction
3994 #[no_mangle]
3995 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
3996         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
3997         *inner_val
3998 }
3999 /// The feerate of the transaction
4000 #[no_mangle]
4001 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
4002         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
4003 }
4004 /// The number of satoshis the sender will contribute to or, if negative, remove from
4005 /// (e.g. splice-out) the funding output of the transaction
4006 #[no_mangle]
4007 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
4008         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
4009         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) };
4010         local_inner_val
4011 }
4012 /// The number of satoshis the sender will contribute to or, if negative, remove from
4013 /// (e.g. splice-out) the funding output of the transaction
4014 #[no_mangle]
4015 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
4016         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4017         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
4018 }
4019 /// Constructs a new TxInitRbf given each field
4020 #[must_use]
4021 #[no_mangle]
4022 pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf {
4023         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
4024         TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
4025                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4026                 locktime: locktime_arg,
4027                 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
4028                 funding_output_contribution: local_funding_output_contribution_arg,
4029         }), is_owned: true }
4030 }
4031 impl Clone for TxInitRbf {
4032         fn clone(&self) -> Self {
4033                 Self {
4034                         inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
4035                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4036                         is_owned: true,
4037                 }
4038         }
4039 }
4040 #[allow(unused)]
4041 /// Used only if an object of this type is returned as a trait impl by a method
4042 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
4043         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxInitRbf)).clone() })) as *mut c_void
4044 }
4045 #[no_mangle]
4046 /// Creates a copy of the TxInitRbf
4047 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
4048         orig.clone()
4049 }
4050 /// Get a string which allows debug introspection of a TxInitRbf object
4051 pub extern "C" fn TxInitRbf_debug_str_void(o: *const c_void) -> Str {
4052         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxInitRbf }).into()}
4053 /// Generates a non-cryptographic 64-bit hash of the TxInitRbf.
4054 #[no_mangle]
4055 pub extern "C" fn TxInitRbf_hash(o: &TxInitRbf) -> u64 {
4056         if o.inner.is_null() { return 0; }
4057         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4058         #[allow(deprecated)]
4059         let mut hasher = core::hash::SipHasher::new();
4060         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4061         core::hash::Hasher::finish(&hasher)
4062 }
4063 /// Checks if two TxInitRbfs contain equal inner contents.
4064 /// This ignores pointers and is_owned flags and looks at the values in fields.
4065 /// Two objects with NULL inner values will be considered "equal" here.
4066 #[no_mangle]
4067 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
4068         if a.inner == b.inner { return true; }
4069         if a.inner.is_null() || b.inner.is_null() { return false; }
4070         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4071 }
4072
4073 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
4074 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
4075
4076 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
4077 /// completed.
4078 ///
4079 #[must_use]
4080 #[repr(C)]
4081 pub struct TxAckRbf {
4082         /// A pointer to the opaque Rust object.
4083
4084         /// Nearly everywhere, inner must be non-null, however in places where
4085         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4086         pub inner: *mut nativeTxAckRbf,
4087         /// Indicates that this is the only struct which contains the same pointer.
4088
4089         /// Rust functions which take ownership of an object provided via an argument require
4090         /// this to be true and invalidate the object pointed to by inner.
4091         pub is_owned: bool,
4092 }
4093
4094 impl Drop for TxAckRbf {
4095         fn drop(&mut self) {
4096                 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
4097                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4098                 }
4099         }
4100 }
4101 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
4102 #[no_mangle]
4103 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
4104 #[allow(unused)]
4105 /// Used only if an object of this type is returned as a trait impl by a method
4106 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
4107         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
4108 }
4109 #[allow(unused)]
4110 impl TxAckRbf {
4111         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
4112                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4113         }
4114         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
4115                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4116         }
4117         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4118         pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
4119                 assert!(self.is_owned);
4120                 let ret = ObjOps::untweak_ptr(self.inner);
4121                 self.inner = core::ptr::null_mut();
4122                 ret
4123         }
4124 }
4125 /// The channel ID
4126 #[no_mangle]
4127 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> crate::lightning::ln::types::ChannelId {
4128         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4129         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4130 }
4131 /// The channel ID
4132 #[no_mangle]
4133 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::lightning::ln::types::ChannelId) {
4134         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4135 }
4136 /// The number of satoshis the sender will contribute to or, if negative, remove from
4137 /// (e.g. splice-out) the funding output of the transaction
4138 #[no_mangle]
4139 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
4140         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
4141         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) };
4142         local_inner_val
4143 }
4144 /// The number of satoshis the sender will contribute to or, if negative, remove from
4145 /// (e.g. splice-out) the funding output of the transaction
4146 #[no_mangle]
4147 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
4148         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4149         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
4150 }
4151 /// Constructs a new TxAckRbf given each field
4152 #[must_use]
4153 #[no_mangle]
4154 pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf {
4155         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
4156         TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
4157                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4158                 funding_output_contribution: local_funding_output_contribution_arg,
4159         }), is_owned: true }
4160 }
4161 impl Clone for TxAckRbf {
4162         fn clone(&self) -> Self {
4163                 Self {
4164                         inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
4165                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4166                         is_owned: true,
4167                 }
4168         }
4169 }
4170 #[allow(unused)]
4171 /// Used only if an object of this type is returned as a trait impl by a method
4172 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
4173         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAckRbf)).clone() })) as *mut c_void
4174 }
4175 #[no_mangle]
4176 /// Creates a copy of the TxAckRbf
4177 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
4178         orig.clone()
4179 }
4180 /// Get a string which allows debug introspection of a TxAckRbf object
4181 pub extern "C" fn TxAckRbf_debug_str_void(o: *const c_void) -> Str {
4182         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAckRbf }).into()}
4183 /// Generates a non-cryptographic 64-bit hash of the TxAckRbf.
4184 #[no_mangle]
4185 pub extern "C" fn TxAckRbf_hash(o: &TxAckRbf) -> u64 {
4186         if o.inner.is_null() { return 0; }
4187         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4188         #[allow(deprecated)]
4189         let mut hasher = core::hash::SipHasher::new();
4190         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4191         core::hash::Hasher::finish(&hasher)
4192 }
4193 /// Checks if two TxAckRbfs contain equal inner contents.
4194 /// This ignores pointers and is_owned flags and looks at the values in fields.
4195 /// Two objects with NULL inner values will be considered "equal" here.
4196 #[no_mangle]
4197 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
4198         if a.inner == b.inner { return true; }
4199         if a.inner.is_null() || b.inner.is_null() { return false; }
4200         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4201 }
4202
4203 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
4204 pub(crate) type nativeTxAbort = nativeTxAbortImport;
4205
4206 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
4207 ///
4208 #[must_use]
4209 #[repr(C)]
4210 pub struct TxAbort {
4211         /// A pointer to the opaque Rust object.
4212
4213         /// Nearly everywhere, inner must be non-null, however in places where
4214         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4215         pub inner: *mut nativeTxAbort,
4216         /// Indicates that this is the only struct which contains the same pointer.
4217
4218         /// Rust functions which take ownership of an object provided via an argument require
4219         /// this to be true and invalidate the object pointed to by inner.
4220         pub is_owned: bool,
4221 }
4222
4223 impl Drop for TxAbort {
4224         fn drop(&mut self) {
4225                 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
4226                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4227                 }
4228         }
4229 }
4230 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
4231 #[no_mangle]
4232 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
4233 #[allow(unused)]
4234 /// Used only if an object of this type is returned as a trait impl by a method
4235 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
4236         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
4237 }
4238 #[allow(unused)]
4239 impl TxAbort {
4240         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
4241                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4242         }
4243         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
4244                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4245         }
4246         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4247         pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
4248                 assert!(self.is_owned);
4249                 let ret = ObjOps::untweak_ptr(self.inner);
4250                 self.inner = core::ptr::null_mut();
4251                 ret
4252         }
4253 }
4254 /// The channel ID
4255 #[no_mangle]
4256 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> crate::lightning::ln::types::ChannelId {
4257         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4258         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4259 }
4260 /// The channel ID
4261 #[no_mangle]
4262 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::lightning::ln::types::ChannelId) {
4263         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4264 }
4265 /// Message data
4266 ///
4267 /// Returns a copy of the field.
4268 #[no_mangle]
4269 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
4270         let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
4271         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4272         local_inner_val.into()
4273 }
4274 /// Message data
4275 #[no_mangle]
4276 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
4277         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4278         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
4279 }
4280 /// Constructs a new TxAbort given each field
4281 #[must_use]
4282 #[no_mangle]
4283 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
4284         let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
4285         TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
4286                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4287                 data: local_data_arg,
4288         }), is_owned: true }
4289 }
4290 impl Clone for TxAbort {
4291         fn clone(&self) -> Self {
4292                 Self {
4293                         inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
4294                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4295                         is_owned: true,
4296                 }
4297         }
4298 }
4299 #[allow(unused)]
4300 /// Used only if an object of this type is returned as a trait impl by a method
4301 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
4302         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAbort)).clone() })) as *mut c_void
4303 }
4304 #[no_mangle]
4305 /// Creates a copy of the TxAbort
4306 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
4307         orig.clone()
4308 }
4309 /// Get a string which allows debug introspection of a TxAbort object
4310 pub extern "C" fn TxAbort_debug_str_void(o: *const c_void) -> Str {
4311         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAbort }).into()}
4312 /// Generates a non-cryptographic 64-bit hash of the TxAbort.
4313 #[no_mangle]
4314 pub extern "C" fn TxAbort_hash(o: &TxAbort) -> u64 {
4315         if o.inner.is_null() { return 0; }
4316         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4317         #[allow(deprecated)]
4318         let mut hasher = core::hash::SipHasher::new();
4319         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4320         core::hash::Hasher::finish(&hasher)
4321 }
4322 /// Checks if two TxAborts contain equal inner contents.
4323 /// This ignores pointers and is_owned flags and looks at the values in fields.
4324 /// Two objects with NULL inner values will be considered "equal" here.
4325 #[no_mangle]
4326 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
4327         if a.inner == b.inner { return true; }
4328         if a.inner.is_null() || b.inner.is_null() { return false; }
4329         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4330 }
4331
4332 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
4333 pub(crate) type nativeShutdown = nativeShutdownImport;
4334
4335 /// A [`shutdown`] message to be sent to or received from a peer.
4336 ///
4337 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
4338 #[must_use]
4339 #[repr(C)]
4340 pub struct Shutdown {
4341         /// A pointer to the opaque Rust object.
4342
4343         /// Nearly everywhere, inner must be non-null, however in places where
4344         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4345         pub inner: *mut nativeShutdown,
4346         /// Indicates that this is the only struct which contains the same pointer.
4347
4348         /// Rust functions which take ownership of an object provided via an argument require
4349         /// this to be true and invalidate the object pointed to by inner.
4350         pub is_owned: bool,
4351 }
4352
4353 impl Drop for Shutdown {
4354         fn drop(&mut self) {
4355                 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
4356                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4357                 }
4358         }
4359 }
4360 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
4361 #[no_mangle]
4362 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
4363 #[allow(unused)]
4364 /// Used only if an object of this type is returned as a trait impl by a method
4365 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
4366         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
4367 }
4368 #[allow(unused)]
4369 impl Shutdown {
4370         pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
4371                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4372         }
4373         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
4374                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4375         }
4376         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4377         pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
4378                 assert!(self.is_owned);
4379                 let ret = ObjOps::untweak_ptr(self.inner);
4380                 self.inner = core::ptr::null_mut();
4381                 ret
4382         }
4383 }
4384 /// The channel ID
4385 #[no_mangle]
4386 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> crate::lightning::ln::types::ChannelId {
4387         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4388         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4389 }
4390 /// The channel ID
4391 #[no_mangle]
4392 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::lightning::ln::types::ChannelId) {
4393         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4394 }
4395 /// The destination of this peer's funds on closing.
4396 ///
4397 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
4398 #[no_mangle]
4399 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
4400         let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
4401         inner_val.as_bytes().to_vec().into()
4402 }
4403 /// The destination of this peer's funds on closing.
4404 ///
4405 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
4406 #[no_mangle]
4407 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
4408         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust());
4409 }
4410 /// Constructs a new Shutdown given each field
4411 #[must_use]
4412 #[no_mangle]
4413 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
4414         Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
4415                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4416                 scriptpubkey: ::bitcoin::blockdata::script::ScriptBuf::from(scriptpubkey_arg.into_rust()),
4417         }), is_owned: true }
4418 }
4419 impl Clone for Shutdown {
4420         fn clone(&self) -> Self {
4421                 Self {
4422                         inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
4423                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4424                         is_owned: true,
4425                 }
4426         }
4427 }
4428 #[allow(unused)]
4429 /// Used only if an object of this type is returned as a trait impl by a method
4430 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
4431         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeShutdown)).clone() })) as *mut c_void
4432 }
4433 #[no_mangle]
4434 /// Creates a copy of the Shutdown
4435 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
4436         orig.clone()
4437 }
4438 /// Get a string which allows debug introspection of a Shutdown object
4439 pub extern "C" fn Shutdown_debug_str_void(o: *const c_void) -> Str {
4440         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Shutdown }).into()}
4441 /// Generates a non-cryptographic 64-bit hash of the Shutdown.
4442 #[no_mangle]
4443 pub extern "C" fn Shutdown_hash(o: &Shutdown) -> u64 {
4444         if o.inner.is_null() { return 0; }
4445         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4446         #[allow(deprecated)]
4447         let mut hasher = core::hash::SipHasher::new();
4448         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4449         core::hash::Hasher::finish(&hasher)
4450 }
4451 /// Checks if two Shutdowns contain equal inner contents.
4452 /// This ignores pointers and is_owned flags and looks at the values in fields.
4453 /// Two objects with NULL inner values will be considered "equal" here.
4454 #[no_mangle]
4455 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
4456         if a.inner == b.inner { return true; }
4457         if a.inner.is_null() || b.inner.is_null() { return false; }
4458         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4459 }
4460
4461 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
4462 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
4463
4464 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
4465 ///
4466 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
4467 /// to use.
4468 #[must_use]
4469 #[repr(C)]
4470 pub struct ClosingSignedFeeRange {
4471         /// A pointer to the opaque Rust object.
4472
4473         /// Nearly everywhere, inner must be non-null, however in places where
4474         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4475         pub inner: *mut nativeClosingSignedFeeRange,
4476         /// Indicates that this is the only struct which contains the same pointer.
4477
4478         /// Rust functions which take ownership of an object provided via an argument require
4479         /// this to be true and invalidate the object pointed to by inner.
4480         pub is_owned: bool,
4481 }
4482
4483 impl Drop for ClosingSignedFeeRange {
4484         fn drop(&mut self) {
4485                 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
4486                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4487                 }
4488         }
4489 }
4490 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
4491 #[no_mangle]
4492 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
4493 #[allow(unused)]
4494 /// Used only if an object of this type is returned as a trait impl by a method
4495 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
4496         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
4497 }
4498 #[allow(unused)]
4499 impl ClosingSignedFeeRange {
4500         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
4501                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4502         }
4503         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
4504                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4505         }
4506         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4507         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
4508                 assert!(self.is_owned);
4509                 let ret = ObjOps::untweak_ptr(self.inner);
4510                 self.inner = core::ptr::null_mut();
4511                 ret
4512         }
4513 }
4514 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
4515 /// transaction.
4516 #[no_mangle]
4517 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
4518         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
4519         *inner_val
4520 }
4521 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
4522 /// transaction.
4523 #[no_mangle]
4524 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
4525         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
4526 }
4527 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
4528 /// transaction.
4529 #[no_mangle]
4530 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
4531         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
4532         *inner_val
4533 }
4534 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
4535 /// transaction.
4536 #[no_mangle]
4537 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
4538         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
4539 }
4540 /// Constructs a new ClosingSignedFeeRange given each field
4541 #[must_use]
4542 #[no_mangle]
4543 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
4544         ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
4545                 min_fee_satoshis: min_fee_satoshis_arg,
4546                 max_fee_satoshis: max_fee_satoshis_arg,
4547         }), is_owned: true }
4548 }
4549 impl Clone for ClosingSignedFeeRange {
4550         fn clone(&self) -> Self {
4551                 Self {
4552                         inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4553                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4554                         is_owned: true,
4555                 }
4556         }
4557 }
4558 #[allow(unused)]
4559 /// Used only if an object of this type is returned as a trait impl by a method
4560 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4561         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSignedFeeRange)).clone() })) as *mut c_void
4562 }
4563 #[no_mangle]
4564 /// Creates a copy of the ClosingSignedFeeRange
4565 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
4566         orig.clone()
4567 }
4568 /// Get a string which allows debug introspection of a ClosingSignedFeeRange object
4569 pub extern "C" fn ClosingSignedFeeRange_debug_str_void(o: *const c_void) -> Str {
4570         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ClosingSignedFeeRange }).into()}
4571 /// Generates a non-cryptographic 64-bit hash of the ClosingSignedFeeRange.
4572 #[no_mangle]
4573 pub extern "C" fn ClosingSignedFeeRange_hash(o: &ClosingSignedFeeRange) -> u64 {
4574         if o.inner.is_null() { return 0; }
4575         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4576         #[allow(deprecated)]
4577         let mut hasher = core::hash::SipHasher::new();
4578         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4579         core::hash::Hasher::finish(&hasher)
4580 }
4581 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
4582 /// This ignores pointers and is_owned flags and looks at the values in fields.
4583 /// Two objects with NULL inner values will be considered "equal" here.
4584 #[no_mangle]
4585 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
4586         if a.inner == b.inner { return true; }
4587         if a.inner.is_null() || b.inner.is_null() { return false; }
4588         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4589 }
4590
4591 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
4592 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
4593
4594 /// A [`closing_signed`] message to be sent to or received from a peer.
4595 ///
4596 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
4597 #[must_use]
4598 #[repr(C)]
4599 pub struct ClosingSigned {
4600         /// A pointer to the opaque Rust object.
4601
4602         /// Nearly everywhere, inner must be non-null, however in places where
4603         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4604         pub inner: *mut nativeClosingSigned,
4605         /// Indicates that this is the only struct which contains the same pointer.
4606
4607         /// Rust functions which take ownership of an object provided via an argument require
4608         /// this to be true and invalidate the object pointed to by inner.
4609         pub is_owned: bool,
4610 }
4611
4612 impl Drop for ClosingSigned {
4613         fn drop(&mut self) {
4614                 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
4615                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4616                 }
4617         }
4618 }
4619 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
4620 #[no_mangle]
4621 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
4622 #[allow(unused)]
4623 /// Used only if an object of this type is returned as a trait impl by a method
4624 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
4625         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
4626 }
4627 #[allow(unused)]
4628 impl ClosingSigned {
4629         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
4630                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4631         }
4632         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
4633                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4634         }
4635         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4636         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
4637                 assert!(self.is_owned);
4638                 let ret = ObjOps::untweak_ptr(self.inner);
4639                 self.inner = core::ptr::null_mut();
4640                 ret
4641         }
4642 }
4643 /// The channel ID
4644 #[no_mangle]
4645 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> crate::lightning::ln::types::ChannelId {
4646         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4647         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4648 }
4649 /// The channel ID
4650 #[no_mangle]
4651 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::types::ChannelId) {
4652         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4653 }
4654 /// The proposed total fee for the closing transaction
4655 #[no_mangle]
4656 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
4657         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
4658         *inner_val
4659 }
4660 /// The proposed total fee for the closing transaction
4661 #[no_mangle]
4662 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
4663         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
4664 }
4665 /// A signature on the closing transaction
4666 #[no_mangle]
4667 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::ECDSASignature {
4668         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4669         crate::c_types::ECDSASignature::from_rust(&inner_val)
4670 }
4671 /// A signature on the closing transaction
4672 #[no_mangle]
4673 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ECDSASignature) {
4674         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4675 }
4676 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4677 /// nodes.
4678 ///
4679 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4680 #[no_mangle]
4681 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
4682         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
4683         let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { 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::ClosingSignedFeeRange<>) as *mut _ }, is_owned: false };
4684         local_inner_val
4685 }
4686 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4687 /// nodes.
4688 ///
4689 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4690 #[no_mangle]
4691 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
4692         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4693         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
4694 }
4695 /// Constructs a new ClosingSigned given each field
4696 ///
4697 /// Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4698 #[must_use]
4699 #[no_mangle]
4700 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::ECDSASignature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
4701         let mut local_fee_range_arg = if fee_range_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(fee_range_arg.take_inner()) } }) };
4702         ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
4703                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4704                 fee_satoshis: fee_satoshis_arg,
4705                 signature: signature_arg.into_rust(),
4706                 fee_range: local_fee_range_arg,
4707         }), is_owned: true }
4708 }
4709 impl Clone for ClosingSigned {
4710         fn clone(&self) -> Self {
4711                 Self {
4712                         inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4713                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4714                         is_owned: true,
4715                 }
4716         }
4717 }
4718 #[allow(unused)]
4719 /// Used only if an object of this type is returned as a trait impl by a method
4720 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4721         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSigned)).clone() })) as *mut c_void
4722 }
4723 #[no_mangle]
4724 /// Creates a copy of the ClosingSigned
4725 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4726         orig.clone()
4727 }
4728 /// Get a string which allows debug introspection of a ClosingSigned object
4729 pub extern "C" fn ClosingSigned_debug_str_void(o: *const c_void) -> Str {
4730         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ClosingSigned }).into()}
4731 /// Generates a non-cryptographic 64-bit hash of the ClosingSigned.
4732 #[no_mangle]
4733 pub extern "C" fn ClosingSigned_hash(o: &ClosingSigned) -> u64 {
4734         if o.inner.is_null() { return 0; }
4735         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4736         #[allow(deprecated)]
4737         let mut hasher = core::hash::SipHasher::new();
4738         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4739         core::hash::Hasher::finish(&hasher)
4740 }
4741 /// Checks if two ClosingSigneds contain equal inner contents.
4742 /// This ignores pointers and is_owned flags and looks at the values in fields.
4743 /// Two objects with NULL inner values will be considered "equal" here.
4744 #[no_mangle]
4745 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4746         if a.inner == b.inner { return true; }
4747         if a.inner.is_null() || b.inner.is_null() { return false; }
4748         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4749 }
4750
4751 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4752 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4753
4754 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4755 ///
4756 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4757 #[must_use]
4758 #[repr(C)]
4759 pub struct UpdateAddHTLC {
4760         /// A pointer to the opaque Rust object.
4761
4762         /// Nearly everywhere, inner must be non-null, however in places where
4763         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4764         pub inner: *mut nativeUpdateAddHTLC,
4765         /// Indicates that this is the only struct which contains the same pointer.
4766
4767         /// Rust functions which take ownership of an object provided via an argument require
4768         /// this to be true and invalidate the object pointed to by inner.
4769         pub is_owned: bool,
4770 }
4771
4772 impl Drop for UpdateAddHTLC {
4773         fn drop(&mut self) {
4774                 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4775                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4776                 }
4777         }
4778 }
4779 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4780 #[no_mangle]
4781 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4782 #[allow(unused)]
4783 /// Used only if an object of this type is returned as a trait impl by a method
4784 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4785         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4786 }
4787 #[allow(unused)]
4788 impl UpdateAddHTLC {
4789         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4790                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4791         }
4792         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4793                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4794         }
4795         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4796         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4797                 assert!(self.is_owned);
4798                 let ret = ObjOps::untweak_ptr(self.inner);
4799                 self.inner = core::ptr::null_mut();
4800                 ret
4801         }
4802 }
4803 /// The channel ID
4804 #[no_mangle]
4805 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> crate::lightning::ln::types::ChannelId {
4806         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4807         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4808 }
4809 /// The channel ID
4810 #[no_mangle]
4811 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::lightning::ln::types::ChannelId) {
4812         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4813 }
4814 /// The HTLC ID
4815 #[no_mangle]
4816 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4817         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4818         *inner_val
4819 }
4820 /// The HTLC ID
4821 #[no_mangle]
4822 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4823         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4824 }
4825 /// The HTLC value in milli-satoshi
4826 #[no_mangle]
4827 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4828         let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4829         *inner_val
4830 }
4831 /// The HTLC value in milli-satoshi
4832 #[no_mangle]
4833 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4834         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4835 }
4836 /// The payment hash, the pre-image of which controls HTLC redemption
4837 #[no_mangle]
4838 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4839         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4840         &inner_val.0
4841 }
4842 /// The payment hash, the pre-image of which controls HTLC redemption
4843 #[no_mangle]
4844 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4845         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::types::PaymentHash(val.data);
4846 }
4847 /// The expiry height of the HTLC
4848 #[no_mangle]
4849 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4850         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4851         *inner_val
4852 }
4853 /// The expiry height of the HTLC
4854 #[no_mangle]
4855 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4856         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
4857 }
4858 /// The extra fee skimmed by the sender of this message. See
4859 /// [`ChannelConfig::accept_underpaying_htlcs`].
4860 ///
4861 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4862 #[no_mangle]
4863 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
4864         let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
4865         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
4866         local_inner_val
4867 }
4868 /// The extra fee skimmed by the sender of this message. See
4869 /// [`ChannelConfig::accept_underpaying_htlcs`].
4870 ///
4871 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4872 #[no_mangle]
4873 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
4874         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4875         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
4876 }
4877 /// The onion routing packet with encrypted data for the next hop.
4878 #[no_mangle]
4879 pub extern "C" fn UpdateAddHTLC_get_onion_routing_packet(this_ptr: &UpdateAddHTLC) -> crate::lightning::ln::msgs::OnionPacket {
4880         let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
4881         crate::lightning::ln::msgs::OnionPacket { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::OnionPacket<>) as *mut _) }, is_owned: false }
4882 }
4883 /// The onion routing packet with encrypted data for the next hop.
4884 #[no_mangle]
4885 pub extern "C" fn UpdateAddHTLC_set_onion_routing_packet(this_ptr: &mut UpdateAddHTLC, mut val: crate::lightning::ln::msgs::OnionPacket) {
4886         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
4887 }
4888 /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
4889 /// routing packet and the recipient-provided encrypted payload within.
4890 ///
4891 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4892 #[no_mangle]
4893 pub extern "C" fn UpdateAddHTLC_get_blinding_point(this_ptr: &UpdateAddHTLC) -> crate::c_types::PublicKey {
4894         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
4895         let mut local_inner_val = if inner_val.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(inner_val.unwrap())) } };
4896         local_inner_val
4897 }
4898 /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
4899 /// routing packet and the recipient-provided encrypted payload within.
4900 ///
4901 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4902 #[no_mangle]
4903 pub extern "C" fn UpdateAddHTLC_set_blinding_point(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::PublicKey) {
4904         let mut local_val = if val.is_null() { None } else { Some( { val.into_rust() }) };
4905         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = local_val;
4906 }
4907 /// Constructs a new UpdateAddHTLC given each field
4908 ///
4909 /// Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4910 #[must_use]
4911 #[no_mangle]
4912 pub extern "C" fn UpdateAddHTLC_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut htlc_id_arg: u64, mut amount_msat_arg: u64, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut cltv_expiry_arg: u32, mut skimmed_fee_msat_arg: crate::c_types::derived::COption_u64Z, mut onion_routing_packet_arg: crate::lightning::ln::msgs::OnionPacket, mut blinding_point_arg: crate::c_types::PublicKey) -> UpdateAddHTLC {
4913         let mut local_skimmed_fee_msat_arg = if skimmed_fee_msat_arg.is_some() { Some( { skimmed_fee_msat_arg.take() }) } else { None };
4914         let mut local_blinding_point_arg = if blinding_point_arg.is_null() { None } else { Some( { blinding_point_arg.into_rust() }) };
4915         UpdateAddHTLC { inner: ObjOps::heap_alloc(nativeUpdateAddHTLC {
4916                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4917                 htlc_id: htlc_id_arg,
4918                 amount_msat: amount_msat_arg,
4919                 payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_arg.data),
4920                 cltv_expiry: cltv_expiry_arg,
4921                 skimmed_fee_msat: local_skimmed_fee_msat_arg,
4922                 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
4923                 blinding_point: local_blinding_point_arg,
4924         }), is_owned: true }
4925 }
4926 impl Clone for UpdateAddHTLC {
4927         fn clone(&self) -> Self {
4928                 Self {
4929                         inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4930                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4931                         is_owned: true,
4932                 }
4933         }
4934 }
4935 #[allow(unused)]
4936 /// Used only if an object of this type is returned as a trait impl by a method
4937 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4938         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateAddHTLC)).clone() })) as *mut c_void
4939 }
4940 #[no_mangle]
4941 /// Creates a copy of the UpdateAddHTLC
4942 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
4943         orig.clone()
4944 }
4945 /// Get a string which allows debug introspection of a UpdateAddHTLC object
4946 pub extern "C" fn UpdateAddHTLC_debug_str_void(o: *const c_void) -> Str {
4947         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateAddHTLC }).into()}
4948 /// Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC.
4949 #[no_mangle]
4950 pub extern "C" fn UpdateAddHTLC_hash(o: &UpdateAddHTLC) -> u64 {
4951         if o.inner.is_null() { return 0; }
4952         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4953         #[allow(deprecated)]
4954         let mut hasher = core::hash::SipHasher::new();
4955         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4956         core::hash::Hasher::finish(&hasher)
4957 }
4958 /// Checks if two UpdateAddHTLCs contain equal inner contents.
4959 /// This ignores pointers and is_owned flags and looks at the values in fields.
4960 /// Two objects with NULL inner values will be considered "equal" here.
4961 #[no_mangle]
4962 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
4963         if a.inner == b.inner { return true; }
4964         if a.inner.is_null() || b.inner.is_null() { return false; }
4965         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4966 }
4967
4968 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
4969 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
4970
4971 /// An onion message to be sent to or received from a peer.
4972 ///
4973 #[must_use]
4974 #[repr(C)]
4975 pub struct OnionMessage {
4976         /// A pointer to the opaque Rust object.
4977
4978         /// Nearly everywhere, inner must be non-null, however in places where
4979         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4980         pub inner: *mut nativeOnionMessage,
4981         /// Indicates that this is the only struct which contains the same pointer.
4982
4983         /// Rust functions which take ownership of an object provided via an argument require
4984         /// this to be true and invalidate the object pointed to by inner.
4985         pub is_owned: bool,
4986 }
4987
4988 impl Drop for OnionMessage {
4989         fn drop(&mut self) {
4990                 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
4991                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4992                 }
4993         }
4994 }
4995 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
4996 #[no_mangle]
4997 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
4998 #[allow(unused)]
4999 /// Used only if an object of this type is returned as a trait impl by a method
5000 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
5001         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
5002 }
5003 #[allow(unused)]
5004 impl OnionMessage {
5005         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
5006                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5007         }
5008         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
5009                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5010         }
5011         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5012         pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
5013                 assert!(self.is_owned);
5014                 let ret = ObjOps::untweak_ptr(self.inner);
5015                 self.inner = core::ptr::null_mut();
5016                 ret
5017         }
5018 }
5019 /// Used in decrypting the onion packet's payload.
5020 #[no_mangle]
5021 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
5022         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
5023         crate::c_types::PublicKey::from_rust(&inner_val)
5024 }
5025 /// Used in decrypting the onion packet's payload.
5026 #[no_mangle]
5027 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
5028         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
5029 }
5030 /// The full onion packet including hop data, pubkey, and hmac
5031 #[no_mangle]
5032 pub extern "C" fn OnionMessage_get_onion_routing_packet(this_ptr: &OnionMessage) -> crate::lightning::onion_message::packet::Packet {
5033         let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
5034         crate::lightning::onion_message::packet::Packet { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::onion_message::packet::Packet<>) as *mut _) }, is_owned: false }
5035 }
5036 /// The full onion packet including hop data, pubkey, and hmac
5037 #[no_mangle]
5038 pub extern "C" fn OnionMessage_set_onion_routing_packet(this_ptr: &mut OnionMessage, mut val: crate::lightning::onion_message::packet::Packet) {
5039         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
5040 }
5041 /// Constructs a new OnionMessage given each field
5042 #[must_use]
5043 #[no_mangle]
5044 pub extern "C" fn OnionMessage_new(mut blinding_point_arg: crate::c_types::PublicKey, mut onion_routing_packet_arg: crate::lightning::onion_message::packet::Packet) -> OnionMessage {
5045         OnionMessage { inner: ObjOps::heap_alloc(nativeOnionMessage {
5046                 blinding_point: blinding_point_arg.into_rust(),
5047                 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
5048         }), is_owned: true }
5049 }
5050 impl Clone for OnionMessage {
5051         fn clone(&self) -> Self {
5052                 Self {
5053                         inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
5054                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5055                         is_owned: true,
5056                 }
5057         }
5058 }
5059 #[allow(unused)]
5060 /// Used only if an object of this type is returned as a trait impl by a method
5061 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
5062         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionMessage)).clone() })) as *mut c_void
5063 }
5064 #[no_mangle]
5065 /// Creates a copy of the OnionMessage
5066 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
5067         orig.clone()
5068 }
5069 /// Get a string which allows debug introspection of a OnionMessage object
5070 pub extern "C" fn OnionMessage_debug_str_void(o: *const c_void) -> Str {
5071         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionMessage }).into()}
5072 /// Generates a non-cryptographic 64-bit hash of the OnionMessage.
5073 #[no_mangle]
5074 pub extern "C" fn OnionMessage_hash(o: &OnionMessage) -> u64 {
5075         if o.inner.is_null() { return 0; }
5076         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5077         #[allow(deprecated)]
5078         let mut hasher = core::hash::SipHasher::new();
5079         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5080         core::hash::Hasher::finish(&hasher)
5081 }
5082 /// Checks if two OnionMessages contain equal inner contents.
5083 /// This ignores pointers and is_owned flags and looks at the values in fields.
5084 /// Two objects with NULL inner values will be considered "equal" here.
5085 #[no_mangle]
5086 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
5087         if a.inner == b.inner { return true; }
5088         if a.inner.is_null() || b.inner.is_null() { return false; }
5089         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5090 }
5091
5092 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
5093 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
5094
5095 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
5096 ///
5097 /// [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
5098 #[must_use]
5099 #[repr(C)]
5100 pub struct UpdateFulfillHTLC {
5101         /// A pointer to the opaque Rust object.
5102
5103         /// Nearly everywhere, inner must be non-null, however in places where
5104         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5105         pub inner: *mut nativeUpdateFulfillHTLC,
5106         /// Indicates that this is the only struct which contains the same pointer.
5107
5108         /// Rust functions which take ownership of an object provided via an argument require
5109         /// this to be true and invalidate the object pointed to by inner.
5110         pub is_owned: bool,
5111 }
5112
5113 impl Drop for UpdateFulfillHTLC {
5114         fn drop(&mut self) {
5115                 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
5116                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5117                 }
5118         }
5119 }
5120 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
5121 #[no_mangle]
5122 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
5123 #[allow(unused)]
5124 /// Used only if an object of this type is returned as a trait impl by a method
5125 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
5126         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
5127 }
5128 #[allow(unused)]
5129 impl UpdateFulfillHTLC {
5130         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
5131                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5132         }
5133         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
5134                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5135         }
5136         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5137         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
5138                 assert!(self.is_owned);
5139                 let ret = ObjOps::untweak_ptr(self.inner);
5140                 self.inner = core::ptr::null_mut();
5141                 ret
5142         }
5143 }
5144 /// The channel ID
5145 #[no_mangle]
5146 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> crate::lightning::ln::types::ChannelId {
5147         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5148         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5149 }
5150 /// The channel ID
5151 #[no_mangle]
5152 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::lightning::ln::types::ChannelId) {
5153         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5154 }
5155 /// The HTLC ID
5156 #[no_mangle]
5157 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
5158         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5159         *inner_val
5160 }
5161 /// The HTLC ID
5162 #[no_mangle]
5163 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
5164         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5165 }
5166 /// The pre-image of the payment hash, allowing HTLC redemption
5167 #[no_mangle]
5168 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
5169         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
5170         &inner_val.0
5171 }
5172 /// The pre-image of the payment hash, allowing HTLC redemption
5173 #[no_mangle]
5174 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5175         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::types::PaymentPreimage(val.data);
5176 }
5177 /// Constructs a new UpdateFulfillHTLC given each field
5178 #[must_use]
5179 #[no_mangle]
5180 pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC {
5181         UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
5182                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5183                 htlc_id: htlc_id_arg,
5184                 payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage_arg.data),
5185         }), is_owned: true }
5186 }
5187 impl Clone for UpdateFulfillHTLC {
5188         fn clone(&self) -> Self {
5189                 Self {
5190                         inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5191                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5192                         is_owned: true,
5193                 }
5194         }
5195 }
5196 #[allow(unused)]
5197 /// Used only if an object of this type is returned as a trait impl by a method
5198 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5199         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
5200 }
5201 #[no_mangle]
5202 /// Creates a copy of the UpdateFulfillHTLC
5203 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
5204         orig.clone()
5205 }
5206 /// Get a string which allows debug introspection of a UpdateFulfillHTLC object
5207 pub extern "C" fn UpdateFulfillHTLC_debug_str_void(o: *const c_void) -> Str {
5208         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFulfillHTLC }).into()}
5209 /// Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC.
5210 #[no_mangle]
5211 pub extern "C" fn UpdateFulfillHTLC_hash(o: &UpdateFulfillHTLC) -> u64 {
5212         if o.inner.is_null() { return 0; }
5213         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5214         #[allow(deprecated)]
5215         let mut hasher = core::hash::SipHasher::new();
5216         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5217         core::hash::Hasher::finish(&hasher)
5218 }
5219 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
5220 /// This ignores pointers and is_owned flags and looks at the values in fields.
5221 /// Two objects with NULL inner values will be considered "equal" here.
5222 #[no_mangle]
5223 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
5224         if a.inner == b.inner { return true; }
5225         if a.inner.is_null() || b.inner.is_null() { return false; }
5226         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5227 }
5228
5229 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
5230 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
5231
5232 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
5233 ///
5234 /// [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
5235 #[must_use]
5236 #[repr(C)]
5237 pub struct UpdateFailHTLC {
5238         /// A pointer to the opaque Rust object.
5239
5240         /// Nearly everywhere, inner must be non-null, however in places where
5241         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5242         pub inner: *mut nativeUpdateFailHTLC,
5243         /// Indicates that this is the only struct which contains the same pointer.
5244
5245         /// Rust functions which take ownership of an object provided via an argument require
5246         /// this to be true and invalidate the object pointed to by inner.
5247         pub is_owned: bool,
5248 }
5249
5250 impl Drop for UpdateFailHTLC {
5251         fn drop(&mut self) {
5252                 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
5253                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5254                 }
5255         }
5256 }
5257 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
5258 #[no_mangle]
5259 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
5260 #[allow(unused)]
5261 /// Used only if an object of this type is returned as a trait impl by a method
5262 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
5263         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
5264 }
5265 #[allow(unused)]
5266 impl UpdateFailHTLC {
5267         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
5268                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5269         }
5270         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
5271                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5272         }
5273         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5274         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
5275                 assert!(self.is_owned);
5276                 let ret = ObjOps::untweak_ptr(self.inner);
5277                 self.inner = core::ptr::null_mut();
5278                 ret
5279         }
5280 }
5281 /// The channel ID
5282 #[no_mangle]
5283 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> crate::lightning::ln::types::ChannelId {
5284         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5285         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5286 }
5287 /// The channel ID
5288 #[no_mangle]
5289 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::lightning::ln::types::ChannelId) {
5290         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5291 }
5292 /// The HTLC ID
5293 #[no_mangle]
5294 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
5295         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5296         *inner_val
5297 }
5298 /// The HTLC ID
5299 #[no_mangle]
5300 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
5301         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5302 }
5303 impl Clone for UpdateFailHTLC {
5304         fn clone(&self) -> Self {
5305                 Self {
5306                         inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5307                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5308                         is_owned: true,
5309                 }
5310         }
5311 }
5312 #[allow(unused)]
5313 /// Used only if an object of this type is returned as a trait impl by a method
5314 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5315         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailHTLC)).clone() })) as *mut c_void
5316 }
5317 #[no_mangle]
5318 /// Creates a copy of the UpdateFailHTLC
5319 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
5320         orig.clone()
5321 }
5322 /// Get a string which allows debug introspection of a UpdateFailHTLC object
5323 pub extern "C" fn UpdateFailHTLC_debug_str_void(o: *const c_void) -> Str {
5324         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailHTLC }).into()}
5325 /// Generates a non-cryptographic 64-bit hash of the UpdateFailHTLC.
5326 #[no_mangle]
5327 pub extern "C" fn UpdateFailHTLC_hash(o: &UpdateFailHTLC) -> u64 {
5328         if o.inner.is_null() { return 0; }
5329         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5330         #[allow(deprecated)]
5331         let mut hasher = core::hash::SipHasher::new();
5332         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5333         core::hash::Hasher::finish(&hasher)
5334 }
5335 /// Checks if two UpdateFailHTLCs contain equal inner contents.
5336 /// This ignores pointers and is_owned flags and looks at the values in fields.
5337 /// Two objects with NULL inner values will be considered "equal" here.
5338 #[no_mangle]
5339 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
5340         if a.inner == b.inner { return true; }
5341         if a.inner.is_null() || b.inner.is_null() { return false; }
5342         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5343 }
5344
5345 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
5346 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
5347
5348 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
5349 ///
5350 /// [`update_fail_malformed_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
5351 #[must_use]
5352 #[repr(C)]
5353 pub struct UpdateFailMalformedHTLC {
5354         /// A pointer to the opaque Rust object.
5355
5356         /// Nearly everywhere, inner must be non-null, however in places where
5357         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5358         pub inner: *mut nativeUpdateFailMalformedHTLC,
5359         /// Indicates that this is the only struct which contains the same pointer.
5360
5361         /// Rust functions which take ownership of an object provided via an argument require
5362         /// this to be true and invalidate the object pointed to by inner.
5363         pub is_owned: bool,
5364 }
5365
5366 impl Drop for UpdateFailMalformedHTLC {
5367         fn drop(&mut self) {
5368                 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
5369                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5370                 }
5371         }
5372 }
5373 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
5374 #[no_mangle]
5375 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
5376 #[allow(unused)]
5377 /// Used only if an object of this type is returned as a trait impl by a method
5378 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
5379         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
5380 }
5381 #[allow(unused)]
5382 impl UpdateFailMalformedHTLC {
5383         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
5384                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5385         }
5386         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
5387                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5388         }
5389         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5390         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
5391                 assert!(self.is_owned);
5392                 let ret = ObjOps::untweak_ptr(self.inner);
5393                 self.inner = core::ptr::null_mut();
5394                 ret
5395         }
5396 }
5397 /// The channel ID
5398 #[no_mangle]
5399 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> crate::lightning::ln::types::ChannelId {
5400         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5401         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5402 }
5403 /// The channel ID
5404 #[no_mangle]
5405 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::lightning::ln::types::ChannelId) {
5406         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5407 }
5408 /// The HTLC ID
5409 #[no_mangle]
5410 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
5411         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5412         *inner_val
5413 }
5414 /// The HTLC ID
5415 #[no_mangle]
5416 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
5417         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5418 }
5419 /// The failure code
5420 #[no_mangle]
5421 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
5422         let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
5423         *inner_val
5424 }
5425 /// The failure code
5426 #[no_mangle]
5427 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
5428         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
5429 }
5430 impl Clone for UpdateFailMalformedHTLC {
5431         fn clone(&self) -> Self {
5432                 Self {
5433                         inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5434                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5435                         is_owned: true,
5436                 }
5437         }
5438 }
5439 #[allow(unused)]
5440 /// Used only if an object of this type is returned as a trait impl by a method
5441 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5442         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
5443 }
5444 #[no_mangle]
5445 /// Creates a copy of the UpdateFailMalformedHTLC
5446 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
5447         orig.clone()
5448 }
5449 /// Get a string which allows debug introspection of a UpdateFailMalformedHTLC object
5450 pub extern "C" fn UpdateFailMalformedHTLC_debug_str_void(o: *const c_void) -> Str {
5451         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailMalformedHTLC }).into()}
5452 /// Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC.
5453 #[no_mangle]
5454 pub extern "C" fn UpdateFailMalformedHTLC_hash(o: &UpdateFailMalformedHTLC) -> u64 {
5455         if o.inner.is_null() { return 0; }
5456         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5457         #[allow(deprecated)]
5458         let mut hasher = core::hash::SipHasher::new();
5459         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5460         core::hash::Hasher::finish(&hasher)
5461 }
5462 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
5463 /// This ignores pointers and is_owned flags and looks at the values in fields.
5464 /// Two objects with NULL inner values will be considered "equal" here.
5465 #[no_mangle]
5466 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
5467         if a.inner == b.inner { return true; }
5468         if a.inner.is_null() || b.inner.is_null() { return false; }
5469         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5470 }
5471
5472 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
5473 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
5474
5475 /// A [`commitment_signed`] message to be sent to or received from a peer.
5476 ///
5477 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
5478 #[must_use]
5479 #[repr(C)]
5480 pub struct CommitmentSigned {
5481         /// A pointer to the opaque Rust object.
5482
5483         /// Nearly everywhere, inner must be non-null, however in places where
5484         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5485         pub inner: *mut nativeCommitmentSigned,
5486         /// Indicates that this is the only struct which contains the same pointer.
5487
5488         /// Rust functions which take ownership of an object provided via an argument require
5489         /// this to be true and invalidate the object pointed to by inner.
5490         pub is_owned: bool,
5491 }
5492
5493 impl Drop for CommitmentSigned {
5494         fn drop(&mut self) {
5495                 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
5496                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5497                 }
5498         }
5499 }
5500 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
5501 #[no_mangle]
5502 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
5503 #[allow(unused)]
5504 /// Used only if an object of this type is returned as a trait impl by a method
5505 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
5506         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
5507 }
5508 #[allow(unused)]
5509 impl CommitmentSigned {
5510         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
5511                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5512         }
5513         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
5514                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5515         }
5516         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5517         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
5518                 assert!(self.is_owned);
5519                 let ret = ObjOps::untweak_ptr(self.inner);
5520                 self.inner = core::ptr::null_mut();
5521                 ret
5522         }
5523 }
5524 /// The channel ID
5525 #[no_mangle]
5526 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> crate::lightning::ln::types::ChannelId {
5527         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5528         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5529 }
5530 /// The channel ID
5531 #[no_mangle]
5532 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::lightning::ln::types::ChannelId) {
5533         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5534 }
5535 /// A signature on the commitment transaction
5536 #[no_mangle]
5537 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::ECDSASignature {
5538         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
5539         crate::c_types::ECDSASignature::from_rust(&inner_val)
5540 }
5541 /// A signature on the commitment transaction
5542 #[no_mangle]
5543 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ECDSASignature) {
5544         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
5545 }
5546 /// Signatures on the HTLC transactions
5547 ///
5548 /// Returns a copy of the field.
5549 #[no_mangle]
5550 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_ECDSASignatureZ {
5551         let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
5552         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::ECDSASignature::from_rust(&item) }); };
5553         local_inner_val.into()
5554 }
5555 /// Signatures on the HTLC transactions
5556 #[no_mangle]
5557 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_ECDSASignatureZ) {
5558         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
5559         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
5560 }
5561 /// Constructs a new CommitmentSigned given each field
5562 #[must_use]
5563 #[no_mangle]
5564 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ) -> CommitmentSigned {
5565         let mut local_htlc_signatures_arg = Vec::new(); for mut item in htlc_signatures_arg.into_rust().drain(..) { local_htlc_signatures_arg.push( { item.into_rust() }); };
5566         CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
5567                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5568                 signature: signature_arg.into_rust(),
5569                 htlc_signatures: local_htlc_signatures_arg,
5570         }), is_owned: true }
5571 }
5572 impl Clone for CommitmentSigned {
5573         fn clone(&self) -> Self {
5574                 Self {
5575                         inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
5576                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5577                         is_owned: true,
5578                 }
5579         }
5580 }
5581 #[allow(unused)]
5582 /// Used only if an object of this type is returned as a trait impl by a method
5583 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
5584         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentSigned)).clone() })) as *mut c_void
5585 }
5586 #[no_mangle]
5587 /// Creates a copy of the CommitmentSigned
5588 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
5589         orig.clone()
5590 }
5591 /// Get a string which allows debug introspection of a CommitmentSigned object
5592 pub extern "C" fn CommitmentSigned_debug_str_void(o: *const c_void) -> Str {
5593         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentSigned }).into()}
5594 /// Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
5595 #[no_mangle]
5596 pub extern "C" fn CommitmentSigned_hash(o: &CommitmentSigned) -> u64 {
5597         if o.inner.is_null() { return 0; }
5598         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5599         #[allow(deprecated)]
5600         let mut hasher = core::hash::SipHasher::new();
5601         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5602         core::hash::Hasher::finish(&hasher)
5603 }
5604 /// Checks if two CommitmentSigneds contain equal inner contents.
5605 /// This ignores pointers and is_owned flags and looks at the values in fields.
5606 /// Two objects with NULL inner values will be considered "equal" here.
5607 #[no_mangle]
5608 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
5609         if a.inner == b.inner { return true; }
5610         if a.inner.is_null() || b.inner.is_null() { return false; }
5611         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5612 }
5613
5614 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
5615 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
5616
5617 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
5618 ///
5619 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
5620 #[must_use]
5621 #[repr(C)]
5622 pub struct RevokeAndACK {
5623         /// A pointer to the opaque Rust object.
5624
5625         /// Nearly everywhere, inner must be non-null, however in places where
5626         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5627         pub inner: *mut nativeRevokeAndACK,
5628         /// Indicates that this is the only struct which contains the same pointer.
5629
5630         /// Rust functions which take ownership of an object provided via an argument require
5631         /// this to be true and invalidate the object pointed to by inner.
5632         pub is_owned: bool,
5633 }
5634
5635 impl Drop for RevokeAndACK {
5636         fn drop(&mut self) {
5637                 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
5638                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5639                 }
5640         }
5641 }
5642 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
5643 #[no_mangle]
5644 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
5645 #[allow(unused)]
5646 /// Used only if an object of this type is returned as a trait impl by a method
5647 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
5648         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
5649 }
5650 #[allow(unused)]
5651 impl RevokeAndACK {
5652         pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
5653                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5654         }
5655         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
5656                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5657         }
5658         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5659         pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
5660                 assert!(self.is_owned);
5661                 let ret = ObjOps::untweak_ptr(self.inner);
5662                 self.inner = core::ptr::null_mut();
5663                 ret
5664         }
5665 }
5666 /// The channel ID
5667 #[no_mangle]
5668 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> crate::lightning::ln::types::ChannelId {
5669         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5670         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5671 }
5672 /// The channel ID
5673 #[no_mangle]
5674 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::lightning::ln::types::ChannelId) {
5675         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5676 }
5677 /// The secret corresponding to the per-commitment point
5678 #[no_mangle]
5679 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
5680         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
5681         inner_val
5682 }
5683 /// The secret corresponding to the per-commitment point
5684 #[no_mangle]
5685 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
5686         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
5687 }
5688 /// The next sender-broadcast commitment transaction's per-commitment point
5689 #[no_mangle]
5690 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
5691         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
5692         crate::c_types::PublicKey::from_rust(&inner_val)
5693 }
5694 /// The next sender-broadcast commitment transaction's per-commitment point
5695 #[no_mangle]
5696 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
5697         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
5698 }
5699 /// Constructs a new RevokeAndACK given each field
5700 #[must_use]
5701 #[no_mangle]
5702 pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK {
5703         RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
5704                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5705                 per_commitment_secret: per_commitment_secret_arg.data,
5706                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
5707         }), is_owned: true }
5708 }
5709 impl Clone for RevokeAndACK {
5710         fn clone(&self) -> Self {
5711                 Self {
5712                         inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
5713                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5714                         is_owned: true,
5715                 }
5716         }
5717 }
5718 #[allow(unused)]
5719 /// Used only if an object of this type is returned as a trait impl by a method
5720 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
5721         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRevokeAndACK)).clone() })) as *mut c_void
5722 }
5723 #[no_mangle]
5724 /// Creates a copy of the RevokeAndACK
5725 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
5726         orig.clone()
5727 }
5728 /// Get a string which allows debug introspection of a RevokeAndACK object
5729 pub extern "C" fn RevokeAndACK_debug_str_void(o: *const c_void) -> Str {
5730         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::RevokeAndACK }).into()}
5731 /// Generates a non-cryptographic 64-bit hash of the RevokeAndACK.
5732 #[no_mangle]
5733 pub extern "C" fn RevokeAndACK_hash(o: &RevokeAndACK) -> u64 {
5734         if o.inner.is_null() { return 0; }
5735         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5736         #[allow(deprecated)]
5737         let mut hasher = core::hash::SipHasher::new();
5738         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5739         core::hash::Hasher::finish(&hasher)
5740 }
5741 /// Checks if two RevokeAndACKs contain equal inner contents.
5742 /// This ignores pointers and is_owned flags and looks at the values in fields.
5743 /// Two objects with NULL inner values will be considered "equal" here.
5744 #[no_mangle]
5745 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
5746         if a.inner == b.inner { return true; }
5747         if a.inner.is_null() || b.inner.is_null() { return false; }
5748         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5749 }
5750
5751 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
5752 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
5753
5754 /// An [`update_fee`] message to be sent to or received from a peer
5755 ///
5756 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
5757 #[must_use]
5758 #[repr(C)]
5759 pub struct UpdateFee {
5760         /// A pointer to the opaque Rust object.
5761
5762         /// Nearly everywhere, inner must be non-null, however in places where
5763         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5764         pub inner: *mut nativeUpdateFee,
5765         /// Indicates that this is the only struct which contains the same pointer.
5766
5767         /// Rust functions which take ownership of an object provided via an argument require
5768         /// this to be true and invalidate the object pointed to by inner.
5769         pub is_owned: bool,
5770 }
5771
5772 impl Drop for UpdateFee {
5773         fn drop(&mut self) {
5774                 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
5775                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5776                 }
5777         }
5778 }
5779 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
5780 #[no_mangle]
5781 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
5782 #[allow(unused)]
5783 /// Used only if an object of this type is returned as a trait impl by a method
5784 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
5785         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
5786 }
5787 #[allow(unused)]
5788 impl UpdateFee {
5789         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
5790                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5791         }
5792         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
5793                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5794         }
5795         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5796         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
5797                 assert!(self.is_owned);
5798                 let ret = ObjOps::untweak_ptr(self.inner);
5799                 self.inner = core::ptr::null_mut();
5800                 ret
5801         }
5802 }
5803 /// The channel ID
5804 #[no_mangle]
5805 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> crate::lightning::ln::types::ChannelId {
5806         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5807         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5808 }
5809 /// The channel ID
5810 #[no_mangle]
5811 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::lightning::ln::types::ChannelId) {
5812         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5813 }
5814 /// Fee rate per 1000-weight of the transaction
5815 #[no_mangle]
5816 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
5817         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
5818         *inner_val
5819 }
5820 /// Fee rate per 1000-weight of the transaction
5821 #[no_mangle]
5822 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
5823         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
5824 }
5825 /// Constructs a new UpdateFee given each field
5826 #[must_use]
5827 #[no_mangle]
5828 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut feerate_per_kw_arg: u32) -> UpdateFee {
5829         UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
5830                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5831                 feerate_per_kw: feerate_per_kw_arg,
5832         }), is_owned: true }
5833 }
5834 impl Clone for UpdateFee {
5835         fn clone(&self) -> Self {
5836                 Self {
5837                         inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
5838                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5839                         is_owned: true,
5840                 }
5841         }
5842 }
5843 #[allow(unused)]
5844 /// Used only if an object of this type is returned as a trait impl by a method
5845 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
5846         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFee)).clone() })) as *mut c_void
5847 }
5848 #[no_mangle]
5849 /// Creates a copy of the UpdateFee
5850 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
5851         orig.clone()
5852 }
5853 /// Get a string which allows debug introspection of a UpdateFee object
5854 pub extern "C" fn UpdateFee_debug_str_void(o: *const c_void) -> Str {
5855         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFee }).into()}
5856 /// Generates a non-cryptographic 64-bit hash of the UpdateFee.
5857 #[no_mangle]
5858 pub extern "C" fn UpdateFee_hash(o: &UpdateFee) -> u64 {
5859         if o.inner.is_null() { return 0; }
5860         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5861         #[allow(deprecated)]
5862         let mut hasher = core::hash::SipHasher::new();
5863         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5864         core::hash::Hasher::finish(&hasher)
5865 }
5866 /// Checks if two UpdateFees contain equal inner contents.
5867 /// This ignores pointers and is_owned flags and looks at the values in fields.
5868 /// Two objects with NULL inner values will be considered "equal" here.
5869 #[no_mangle]
5870 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
5871         if a.inner == b.inner { return true; }
5872         if a.inner.is_null() || b.inner.is_null() { return false; }
5873         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5874 }
5875
5876 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
5877 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
5878
5879 /// A [`channel_reestablish`] message to be sent to or received from a peer.
5880 ///
5881 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
5882 #[must_use]
5883 #[repr(C)]
5884 pub struct ChannelReestablish {
5885         /// A pointer to the opaque Rust object.
5886
5887         /// Nearly everywhere, inner must be non-null, however in places where
5888         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5889         pub inner: *mut nativeChannelReestablish,
5890         /// Indicates that this is the only struct which contains the same pointer.
5891
5892         /// Rust functions which take ownership of an object provided via an argument require
5893         /// this to be true and invalidate the object pointed to by inner.
5894         pub is_owned: bool,
5895 }
5896
5897 impl Drop for ChannelReestablish {
5898         fn drop(&mut self) {
5899                 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
5900                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5901                 }
5902         }
5903 }
5904 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
5905 #[no_mangle]
5906 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
5907 #[allow(unused)]
5908 /// Used only if an object of this type is returned as a trait impl by a method
5909 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
5910         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
5911 }
5912 #[allow(unused)]
5913 impl ChannelReestablish {
5914         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
5915                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5916         }
5917         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
5918                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5919         }
5920         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5921         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
5922                 assert!(self.is_owned);
5923                 let ret = ObjOps::untweak_ptr(self.inner);
5924                 self.inner = core::ptr::null_mut();
5925                 ret
5926         }
5927 }
5928 /// The channel ID
5929 #[no_mangle]
5930 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> crate::lightning::ln::types::ChannelId {
5931         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5932         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5933 }
5934 /// The channel ID
5935 #[no_mangle]
5936 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::lightning::ln::types::ChannelId) {
5937         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5938 }
5939 /// The next commitment number for the sender
5940 #[no_mangle]
5941 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5942         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
5943         *inner_val
5944 }
5945 /// The next commitment number for the sender
5946 #[no_mangle]
5947 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5948         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
5949 }
5950 /// The next commitment number for the recipient
5951 #[no_mangle]
5952 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5953         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
5954         *inner_val
5955 }
5956 /// The next commitment number for the recipient
5957 #[no_mangle]
5958 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5959         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
5960 }
5961 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5962 /// belonging to the recipient
5963 #[no_mangle]
5964 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5965         let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
5966         inner_val
5967 }
5968 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5969 /// belonging to the recipient
5970 #[no_mangle]
5971 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5972         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
5973 }
5974 /// The sender's per-commitment point for their current commitment transaction
5975 #[no_mangle]
5976 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
5977         let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
5978         crate::c_types::PublicKey::from_rust(&inner_val)
5979 }
5980 /// The sender's per-commitment point for their current commitment transaction
5981 #[no_mangle]
5982 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
5983         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
5984 }
5985 /// The next funding transaction ID
5986 #[no_mangle]
5987 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
5988         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
5989         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: *(*inner_val.as_ref().unwrap()).clone().as_ref() } }) };
5990         local_inner_val
5991 }
5992 /// The next funding transaction ID
5993 #[no_mangle]
5994 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
5995         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ val_opt.take() }.data[..]).unwrap() }})} };
5996         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
5997 }
5998 /// Constructs a new ChannelReestablish given each field
5999 #[must_use]
6000 #[no_mangle]
6001 pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> ChannelReestablish {
6002         let mut local_next_funding_txid_arg = { /*next_funding_txid_arg*/ let next_funding_txid_arg_opt = next_funding_txid_arg; if next_funding_txid_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ next_funding_txid_arg_opt.take() }.data[..]).unwrap() }})} };
6003         ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
6004                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
6005                 next_local_commitment_number: next_local_commitment_number_arg,
6006                 next_remote_commitment_number: next_remote_commitment_number_arg,
6007                 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
6008                 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
6009                 next_funding_txid: local_next_funding_txid_arg,
6010         }), is_owned: true }
6011 }
6012 impl Clone for ChannelReestablish {
6013         fn clone(&self) -> Self {
6014                 Self {
6015                         inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
6016                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6017                         is_owned: true,
6018                 }
6019         }
6020 }
6021 #[allow(unused)]
6022 /// Used only if an object of this type is returned as a trait impl by a method
6023 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
6024         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReestablish)).clone() })) as *mut c_void
6025 }
6026 #[no_mangle]
6027 /// Creates a copy of the ChannelReestablish
6028 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
6029         orig.clone()
6030 }
6031 /// Get a string which allows debug introspection of a ChannelReestablish object
6032 pub extern "C" fn ChannelReestablish_debug_str_void(o: *const c_void) -> Str {
6033         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelReestablish }).into()}
6034 /// Generates a non-cryptographic 64-bit hash of the ChannelReestablish.
6035 #[no_mangle]
6036 pub extern "C" fn ChannelReestablish_hash(o: &ChannelReestablish) -> u64 {
6037         if o.inner.is_null() { return 0; }
6038         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6039         #[allow(deprecated)]
6040         let mut hasher = core::hash::SipHasher::new();
6041         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6042         core::hash::Hasher::finish(&hasher)
6043 }
6044 /// Checks if two ChannelReestablishs contain equal inner contents.
6045 /// This ignores pointers and is_owned flags and looks at the values in fields.
6046 /// Two objects with NULL inner values will be considered "equal" here.
6047 #[no_mangle]
6048 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
6049         if a.inner == b.inner { return true; }
6050         if a.inner.is_null() || b.inner.is_null() { return false; }
6051         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6052 }
6053
6054 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
6055 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
6056
6057 /// An [`announcement_signatures`] message to be sent to or received from a peer.
6058 ///
6059 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
6060 #[must_use]
6061 #[repr(C)]
6062 pub struct AnnouncementSignatures {
6063         /// A pointer to the opaque Rust object.
6064
6065         /// Nearly everywhere, inner must be non-null, however in places where
6066         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6067         pub inner: *mut nativeAnnouncementSignatures,
6068         /// Indicates that this is the only struct which contains the same pointer.
6069
6070         /// Rust functions which take ownership of an object provided via an argument require
6071         /// this to be true and invalidate the object pointed to by inner.
6072         pub is_owned: bool,
6073 }
6074
6075 impl Drop for AnnouncementSignatures {
6076         fn drop(&mut self) {
6077                 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
6078                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6079                 }
6080         }
6081 }
6082 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
6083 #[no_mangle]
6084 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
6085 #[allow(unused)]
6086 /// Used only if an object of this type is returned as a trait impl by a method
6087 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
6088         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
6089 }
6090 #[allow(unused)]
6091 impl AnnouncementSignatures {
6092         pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
6093                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6094         }
6095         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
6096                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6097         }
6098         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6099         pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
6100                 assert!(self.is_owned);
6101                 let ret = ObjOps::untweak_ptr(self.inner);
6102                 self.inner = core::ptr::null_mut();
6103                 ret
6104         }
6105 }
6106 /// The channel ID
6107 #[no_mangle]
6108 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> crate::lightning::ln::types::ChannelId {
6109         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
6110         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
6111 }
6112 /// The channel ID
6113 #[no_mangle]
6114 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::lightning::ln::types::ChannelId) {
6115         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
6116 }
6117 /// The short channel ID
6118 #[no_mangle]
6119 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
6120         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6121         *inner_val
6122 }
6123 /// The short channel ID
6124 #[no_mangle]
6125 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
6126         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6127 }
6128 /// A signature by the node key
6129 #[no_mangle]
6130 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
6131         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
6132         crate::c_types::ECDSASignature::from_rust(&inner_val)
6133 }
6134 /// A signature by the node key
6135 #[no_mangle]
6136 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
6137         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
6138 }
6139 /// A signature by the funding key
6140 #[no_mangle]
6141 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
6142         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
6143         crate::c_types::ECDSASignature::from_rust(&inner_val)
6144 }
6145 /// A signature by the funding key
6146 #[no_mangle]
6147 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
6148         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
6149 }
6150 /// Constructs a new AnnouncementSignatures given each field
6151 #[must_use]
6152 #[no_mangle]
6153 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_arg: crate::c_types::ECDSASignature) -> AnnouncementSignatures {
6154         AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
6155                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
6156                 short_channel_id: short_channel_id_arg,
6157                 node_signature: node_signature_arg.into_rust(),
6158                 bitcoin_signature: bitcoin_signature_arg.into_rust(),
6159         }), is_owned: true }
6160 }
6161 impl Clone for AnnouncementSignatures {
6162         fn clone(&self) -> Self {
6163                 Self {
6164                         inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
6165                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6166                         is_owned: true,
6167                 }
6168         }
6169 }
6170 #[allow(unused)]
6171 /// Used only if an object of this type is returned as a trait impl by a method
6172 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
6173         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAnnouncementSignatures)).clone() })) as *mut c_void
6174 }
6175 #[no_mangle]
6176 /// Creates a copy of the AnnouncementSignatures
6177 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
6178         orig.clone()
6179 }
6180 /// Get a string which allows debug introspection of a AnnouncementSignatures object
6181 pub extern "C" fn AnnouncementSignatures_debug_str_void(o: *const c_void) -> Str {
6182         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AnnouncementSignatures }).into()}
6183 /// Generates a non-cryptographic 64-bit hash of the AnnouncementSignatures.
6184 #[no_mangle]
6185 pub extern "C" fn AnnouncementSignatures_hash(o: &AnnouncementSignatures) -> u64 {
6186         if o.inner.is_null() { return 0; }
6187         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6188         #[allow(deprecated)]
6189         let mut hasher = core::hash::SipHasher::new();
6190         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6191         core::hash::Hasher::finish(&hasher)
6192 }
6193 /// Checks if two AnnouncementSignaturess contain equal inner contents.
6194 /// This ignores pointers and is_owned flags and looks at the values in fields.
6195 /// Two objects with NULL inner values will be considered "equal" here.
6196 #[no_mangle]
6197 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
6198         if a.inner == b.inner { return true; }
6199         if a.inner.is_null() || b.inner.is_null() { return false; }
6200         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6201 }
6202 /// An address which can be used to connect to a remote peer.
6203 #[derive(Clone)]
6204 #[must_use]
6205 #[repr(C)]
6206 pub enum SocketAddress {
6207         /// An IPv4 address and port on which the peer is listening.
6208         TcpIpV4 {
6209                 /// The 4-byte IPv4 address
6210                 addr: crate::c_types::FourBytes,
6211                 /// The port on which the node is listening
6212                 port: u16,
6213         },
6214         /// An IPv6 address and port on which the peer is listening.
6215         TcpIpV6 {
6216                 /// The 16-byte IPv6 address
6217                 addr: crate::c_types::SixteenBytes,
6218                 /// The port on which the node is listening
6219                 port: u16,
6220         },
6221         /// An old-style Tor onion address/port on which the peer is listening.
6222         ///
6223         /// This field is deprecated and the Tor network generally no longer supports V2 Onion
6224         /// addresses. Thus, the details are not parsed here.
6225         OnionV2(
6226                 crate::c_types::TwelveBytes),
6227         /// A new-style Tor onion address/port on which the peer is listening.
6228         ///
6229         /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
6230         /// wrap as base32 and append \".onion\".
6231         OnionV3 {
6232                 /// The ed25519 long-term public key of the peer
6233                 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
6234                 /// The checksum of the pubkey and version, as included in the onion address
6235                 checksum: u16,
6236                 /// The version byte, as defined by the Tor Onion v3 spec.
6237                 version: u8,
6238                 /// The port on which the node is listening
6239                 port: u16,
6240         },
6241         /// A hostname/port on which the peer is listening.
6242         Hostname {
6243                 /// The hostname on which the node is listening.
6244                 hostname: crate::lightning::util::ser::Hostname,
6245                 /// The port on which the node is listening.
6246                 port: u16,
6247         },
6248 }
6249 use lightning::ln::msgs::SocketAddress as SocketAddressImport;
6250 pub(crate) type nativeSocketAddress = SocketAddressImport;
6251
6252 impl SocketAddress {
6253         #[allow(unused)]
6254         pub(crate) fn to_native(&self) -> nativeSocketAddress {
6255                 match self {
6256                         SocketAddress::TcpIpV4 {ref addr, ref port, } => {
6257                                 let mut addr_nonref = Clone::clone(addr);
6258                                 let mut port_nonref = Clone::clone(port);
6259                                 nativeSocketAddress::TcpIpV4 {
6260                                         addr: addr_nonref.data,
6261                                         port: port_nonref,
6262                                 }
6263                         },
6264                         SocketAddress::TcpIpV6 {ref addr, ref port, } => {
6265                                 let mut addr_nonref = Clone::clone(addr);
6266                                 let mut port_nonref = Clone::clone(port);
6267                                 nativeSocketAddress::TcpIpV6 {
6268                                         addr: addr_nonref.data,
6269                                         port: port_nonref,
6270                                 }
6271                         },
6272                         SocketAddress::OnionV2 (ref a, ) => {
6273                                 let mut a_nonref = Clone::clone(a);
6274                                 nativeSocketAddress::OnionV2 (
6275                                         a_nonref.data,
6276                                 )
6277                         },
6278                         SocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
6279                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
6280                                 let mut checksum_nonref = Clone::clone(checksum);
6281                                 let mut version_nonref = Clone::clone(version);
6282                                 let mut port_nonref = Clone::clone(port);
6283                                 nativeSocketAddress::OnionV3 {
6284                                         ed25519_pubkey: ed25519_pubkey_nonref.data,
6285                                         checksum: checksum_nonref,
6286                                         version: version_nonref,
6287                                         port: port_nonref,
6288                                 }
6289                         },
6290                         SocketAddress::Hostname {ref hostname, ref port, } => {
6291                                 let mut hostname_nonref = Clone::clone(hostname);
6292                                 let mut port_nonref = Clone::clone(port);
6293                                 nativeSocketAddress::Hostname {
6294                                         hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
6295                                         port: port_nonref,
6296                                 }
6297                         },
6298                 }
6299         }
6300         #[allow(unused)]
6301         pub(crate) fn into_native(self) -> nativeSocketAddress {
6302                 match self {
6303                         SocketAddress::TcpIpV4 {mut addr, mut port, } => {
6304                                 nativeSocketAddress::TcpIpV4 {
6305                                         addr: addr.data,
6306                                         port: port,
6307                                 }
6308                         },
6309                         SocketAddress::TcpIpV6 {mut addr, mut port, } => {
6310                                 nativeSocketAddress::TcpIpV6 {
6311                                         addr: addr.data,
6312                                         port: port,
6313                                 }
6314                         },
6315                         SocketAddress::OnionV2 (mut a, ) => {
6316                                 nativeSocketAddress::OnionV2 (
6317                                         a.data,
6318                                 )
6319                         },
6320                         SocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
6321                                 nativeSocketAddress::OnionV3 {
6322                                         ed25519_pubkey: ed25519_pubkey.data,
6323                                         checksum: checksum,
6324                                         version: version,
6325                                         port: port,
6326                                 }
6327                         },
6328                         SocketAddress::Hostname {mut hostname, mut port, } => {
6329                                 nativeSocketAddress::Hostname {
6330                                         hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
6331                                         port: port,
6332                                 }
6333                         },
6334                 }
6335         }
6336         #[allow(unused)]
6337         pub(crate) fn from_native(native: &SocketAddressImport) -> Self {
6338                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSocketAddress) };
6339                 match native {
6340                         nativeSocketAddress::TcpIpV4 {ref addr, ref port, } => {
6341                                 let mut addr_nonref = Clone::clone(addr);
6342                                 let mut port_nonref = Clone::clone(port);
6343                                 SocketAddress::TcpIpV4 {
6344                                         addr: crate::c_types::FourBytes { data: addr_nonref },
6345                                         port: port_nonref,
6346                                 }
6347                         },
6348                         nativeSocketAddress::TcpIpV6 {ref addr, ref port, } => {
6349                                 let mut addr_nonref = Clone::clone(addr);
6350                                 let mut port_nonref = Clone::clone(port);
6351                                 SocketAddress::TcpIpV6 {
6352                                         addr: crate::c_types::SixteenBytes { data: addr_nonref },
6353                                         port: port_nonref,
6354                                 }
6355                         },
6356                         nativeSocketAddress::OnionV2 (ref a, ) => {
6357                                 let mut a_nonref = Clone::clone(a);
6358                                 SocketAddress::OnionV2 (
6359                                         crate::c_types::TwelveBytes { data: a_nonref },
6360                                 )
6361                         },
6362                         nativeSocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
6363                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
6364                                 let mut checksum_nonref = Clone::clone(checksum);
6365                                 let mut version_nonref = Clone::clone(version);
6366                                 let mut port_nonref = Clone::clone(port);
6367                                 SocketAddress::OnionV3 {
6368                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
6369                                         checksum: checksum_nonref,
6370                                         version: version_nonref,
6371                                         port: port_nonref,
6372                                 }
6373                         },
6374                         nativeSocketAddress::Hostname {ref hostname, ref port, } => {
6375                                 let mut hostname_nonref = Clone::clone(hostname);
6376                                 let mut port_nonref = Clone::clone(port);
6377                                 SocketAddress::Hostname {
6378                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
6379                                         port: port_nonref,
6380                                 }
6381                         },
6382                 }
6383         }
6384         #[allow(unused)]
6385         pub(crate) fn native_into(native: nativeSocketAddress) -> Self {
6386                 match native {
6387                         nativeSocketAddress::TcpIpV4 {mut addr, mut port, } => {
6388                                 SocketAddress::TcpIpV4 {
6389                                         addr: crate::c_types::FourBytes { data: addr },
6390                                         port: port,
6391                                 }
6392                         },
6393                         nativeSocketAddress::TcpIpV6 {mut addr, mut port, } => {
6394                                 SocketAddress::TcpIpV6 {
6395                                         addr: crate::c_types::SixteenBytes { data: addr },
6396                                         port: port,
6397                                 }
6398                         },
6399                         nativeSocketAddress::OnionV2 (mut a, ) => {
6400                                 SocketAddress::OnionV2 (
6401                                         crate::c_types::TwelveBytes { data: a },
6402                                 )
6403                         },
6404                         nativeSocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
6405                                 SocketAddress::OnionV3 {
6406                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
6407                                         checksum: checksum,
6408                                         version: version,
6409                                         port: port,
6410                                 }
6411                         },
6412                         nativeSocketAddress::Hostname {mut hostname, mut port, } => {
6413                                 SocketAddress::Hostname {
6414                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
6415                                         port: port,
6416                                 }
6417                         },
6418                 }
6419         }
6420 }
6421 /// Frees any resources used by the SocketAddress
6422 #[no_mangle]
6423 pub extern "C" fn SocketAddress_free(this_ptr: SocketAddress) { }
6424 /// Creates a copy of the SocketAddress
6425 #[no_mangle]
6426 pub extern "C" fn SocketAddress_clone(orig: &SocketAddress) -> SocketAddress {
6427         orig.clone()
6428 }
6429 #[allow(unused)]
6430 /// Used only if an object of this type is returned as a trait impl by a method
6431 pub(crate) extern "C" fn SocketAddress_clone_void(this_ptr: *const c_void) -> *mut c_void {
6432         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddress)).clone() })) as *mut c_void
6433 }
6434 #[allow(unused)]
6435 /// Used only if an object of this type is returned as a trait impl by a method
6436 pub(crate) extern "C" fn SocketAddress_free_void(this_ptr: *mut c_void) {
6437         let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddress) };
6438 }
6439 #[no_mangle]
6440 /// Utility method to constructs a new TcpIpV4-variant SocketAddress
6441 pub extern "C" fn SocketAddress_tcp_ip_v4(addr: crate::c_types::FourBytes, port: u16) -> SocketAddress {
6442         SocketAddress::TcpIpV4 {
6443                 addr,
6444                 port,
6445         }
6446 }
6447 #[no_mangle]
6448 /// Utility method to constructs a new TcpIpV6-variant SocketAddress
6449 pub extern "C" fn SocketAddress_tcp_ip_v6(addr: crate::c_types::SixteenBytes, port: u16) -> SocketAddress {
6450         SocketAddress::TcpIpV6 {
6451                 addr,
6452                 port,
6453         }
6454 }
6455 #[no_mangle]
6456 /// Utility method to constructs a new OnionV2-variant SocketAddress
6457 pub extern "C" fn SocketAddress_onion_v2(a: crate::c_types::TwelveBytes) -> SocketAddress {
6458         SocketAddress::OnionV2(a, )
6459 }
6460 #[no_mangle]
6461 /// Utility method to constructs a new OnionV3-variant SocketAddress
6462 pub extern "C" fn SocketAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> SocketAddress {
6463         SocketAddress::OnionV3 {
6464                 ed25519_pubkey,
6465                 checksum,
6466                 version,
6467                 port,
6468         }
6469 }
6470 #[no_mangle]
6471 /// Utility method to constructs a new Hostname-variant SocketAddress
6472 pub extern "C" fn SocketAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> SocketAddress {
6473         SocketAddress::Hostname {
6474                 hostname,
6475                 port,
6476         }
6477 }
6478 /// Get a string which allows debug introspection of a SocketAddress object
6479 pub extern "C" fn SocketAddress_debug_str_void(o: *const c_void) -> Str {
6480         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SocketAddress }).into()}
6481 /// Generates a non-cryptographic 64-bit hash of the SocketAddress.
6482 #[no_mangle]
6483 pub extern "C" fn SocketAddress_hash(o: &SocketAddress) -> u64 {
6484         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6485         #[allow(deprecated)]
6486         let mut hasher = core::hash::SipHasher::new();
6487         core::hash::Hash::hash(&o.to_native(), &mut hasher);
6488         core::hash::Hasher::finish(&hasher)
6489 }
6490 /// Checks if two SocketAddresss contain equal inner contents.
6491 /// This ignores pointers and is_owned flags and looks at the values in fields.
6492 #[no_mangle]
6493 pub extern "C" fn SocketAddress_eq(a: &SocketAddress, b: &SocketAddress) -> bool {
6494         if &a.to_native() == &b.to_native() { true } else { false }
6495 }
6496 #[no_mangle]
6497 /// Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read
6498 pub extern "C" fn SocketAddress_write(obj: &crate::lightning::ln::msgs::SocketAddress) -> crate::c_types::derived::CVec_u8Z {
6499         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6500 }
6501 #[allow(unused)]
6502 pub(crate) extern "C" fn SocketAddress_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6503         SocketAddress_write(unsafe { &*(obj as *const SocketAddress) })
6504 }
6505 #[no_mangle]
6506 /// Read a SocketAddress from a byte array, created by SocketAddress_write
6507 pub extern "C" fn SocketAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SocketAddressDecodeErrorZ {
6508         let res: Result<lightning::ln::msgs::SocketAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6509         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
6510         local_res
6511 }
6512 /// [`SocketAddress`] error variants
6513 #[derive(Clone)]
6514 #[must_use]
6515 #[repr(C)]
6516 pub enum SocketAddressParseError {
6517         /// Socket address (IPv4/IPv6) parsing error
6518         SocketAddrParse,
6519         /// Invalid input format
6520         InvalidInput,
6521         /// Invalid port
6522         InvalidPort,
6523         /// Invalid onion v3 address
6524         InvalidOnionV3,
6525 }
6526 use lightning::ln::msgs::SocketAddressParseError as SocketAddressParseErrorImport;
6527 pub(crate) type nativeSocketAddressParseError = SocketAddressParseErrorImport;
6528
6529 impl SocketAddressParseError {
6530         #[allow(unused)]
6531         pub(crate) fn to_native(&self) -> nativeSocketAddressParseError {
6532                 match self {
6533                         SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
6534                         SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
6535                         SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
6536                         SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
6537                 }
6538         }
6539         #[allow(unused)]
6540         pub(crate) fn into_native(self) -> nativeSocketAddressParseError {
6541                 match self {
6542                         SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
6543                         SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
6544                         SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
6545                         SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
6546                 }
6547         }
6548         #[allow(unused)]
6549         pub(crate) fn from_native(native: &SocketAddressParseErrorImport) -> Self {
6550                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSocketAddressParseError) };
6551                 match native {
6552                         nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
6553                         nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
6554                         nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
6555                         nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
6556                 }
6557         }
6558         #[allow(unused)]
6559         pub(crate) fn native_into(native: nativeSocketAddressParseError) -> Self {
6560                 match native {
6561                         nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
6562                         nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
6563                         nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
6564                         nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
6565                 }
6566         }
6567 }
6568 /// Creates a copy of the SocketAddressParseError
6569 #[no_mangle]
6570 pub extern "C" fn SocketAddressParseError_clone(orig: &SocketAddressParseError) -> SocketAddressParseError {
6571         orig.clone()
6572 }
6573 #[allow(unused)]
6574 /// Used only if an object of this type is returned as a trait impl by a method
6575 pub(crate) extern "C" fn SocketAddressParseError_clone_void(this_ptr: *const c_void) -> *mut c_void {
6576         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddressParseError)).clone() })) as *mut c_void
6577 }
6578 #[allow(unused)]
6579 /// Used only if an object of this type is returned as a trait impl by a method
6580 pub(crate) extern "C" fn SocketAddressParseError_free_void(this_ptr: *mut c_void) {
6581         let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddressParseError) };
6582 }
6583 #[no_mangle]
6584 /// Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError
6585 pub extern "C" fn SocketAddressParseError_socket_addr_parse() -> SocketAddressParseError {
6586         SocketAddressParseError::SocketAddrParse}
6587 #[no_mangle]
6588 /// Utility method to constructs a new InvalidInput-variant SocketAddressParseError
6589 pub extern "C" fn SocketAddressParseError_invalid_input() -> SocketAddressParseError {
6590         SocketAddressParseError::InvalidInput}
6591 #[no_mangle]
6592 /// Utility method to constructs a new InvalidPort-variant SocketAddressParseError
6593 pub extern "C" fn SocketAddressParseError_invalid_port() -> SocketAddressParseError {
6594         SocketAddressParseError::InvalidPort}
6595 #[no_mangle]
6596 /// Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError
6597 pub extern "C" fn SocketAddressParseError_invalid_onion_v3() -> SocketAddressParseError {
6598         SocketAddressParseError::InvalidOnionV3}
6599 /// Get a string which allows debug introspection of a SocketAddressParseError object
6600 pub extern "C" fn SocketAddressParseError_debug_str_void(o: *const c_void) -> Str {
6601         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SocketAddressParseError }).into()}
6602 /// Generates a non-cryptographic 64-bit hash of the SocketAddressParseError.
6603 #[no_mangle]
6604 pub extern "C" fn SocketAddressParseError_hash(o: &SocketAddressParseError) -> u64 {
6605         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6606         #[allow(deprecated)]
6607         let mut hasher = core::hash::SipHasher::new();
6608         core::hash::Hash::hash(&o.to_native(), &mut hasher);
6609         core::hash::Hasher::finish(&hasher)
6610 }
6611 /// Checks if two SocketAddressParseErrors contain equal inner contents.
6612 /// This ignores pointers and is_owned flags and looks at the values in fields.
6613 #[no_mangle]
6614 pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool {
6615         if &a.to_native() == &b.to_native() { true } else { false }
6616 }
6617 /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
6618 ///
6619 /// The host part must end with \".onion\".
6620 #[no_mangle]
6621 pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6622         let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
6623         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::SocketAddressParseError::native_into(e) }).into() };
6624         local_ret
6625 }
6626
6627 #[no_mangle]
6628 /// Get the string representation of a SocketAddress object
6629 pub extern "C" fn SocketAddress_to_str(o: &crate::lightning::ln::msgs::SocketAddress) -> Str {
6630         alloc::format!("{}", &o.to_native()).into()
6631 }
6632 #[no_mangle]
6633 /// Read a SocketAddress object from a string
6634 pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6635         match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
6636                 Ok(r) => {
6637                         crate::c_types::CResultTempl::ok(
6638                                 crate::lightning::ln::msgs::SocketAddress::native_into(r)
6639                         )
6640                 },
6641                 Err(e) => {
6642                         crate::c_types::CResultTempl::err(
6643                                 crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
6644                         )
6645                 },
6646         }.into()
6647 }
6648 /// Represents the set of gossip messages that require a signature from a node's identity key.
6649 #[derive(Clone)]
6650 #[must_use]
6651 #[repr(C)]
6652 pub enum UnsignedGossipMessage {
6653         /// An unsigned channel announcement.
6654         ChannelAnnouncement(
6655                 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
6656         /// An unsigned channel update.
6657         ChannelUpdate(
6658                 crate::lightning::ln::msgs::UnsignedChannelUpdate),
6659         /// An unsigned node announcement.
6660         NodeAnnouncement(
6661                 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
6662 }
6663 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
6664 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
6665
6666 impl UnsignedGossipMessage {
6667         #[allow(unused)]
6668         pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
6669                 match self {
6670                         UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6671                                 let mut a_nonref = Clone::clone(a);
6672                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
6673                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
6674                                 )
6675                         },
6676                         UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6677                                 let mut a_nonref = Clone::clone(a);
6678                                 nativeUnsignedGossipMessage::ChannelUpdate (
6679                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
6680                                 )
6681                         },
6682                         UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6683                                 let mut a_nonref = Clone::clone(a);
6684                                 nativeUnsignedGossipMessage::NodeAnnouncement (
6685                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
6686                                 )
6687                         },
6688                 }
6689         }
6690         #[allow(unused)]
6691         pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
6692                 match self {
6693                         UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6694                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
6695                                         *unsafe { Box::from_raw(a.take_inner()) },
6696                                 )
6697                         },
6698                         UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6699                                 nativeUnsignedGossipMessage::ChannelUpdate (
6700                                         *unsafe { Box::from_raw(a.take_inner()) },
6701                                 )
6702                         },
6703                         UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6704                                 nativeUnsignedGossipMessage::NodeAnnouncement (
6705                                         *unsafe { Box::from_raw(a.take_inner()) },
6706                                 )
6707                         },
6708                 }
6709         }
6710         #[allow(unused)]
6711         pub(crate) fn from_native(native: &UnsignedGossipMessageImport) -> Self {
6712                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeUnsignedGossipMessage) };
6713                 match native {
6714                         nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6715                                 let mut a_nonref = Clone::clone(a);
6716                                 UnsignedGossipMessage::ChannelAnnouncement (
6717                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6718                                 )
6719                         },
6720                         nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6721                                 let mut a_nonref = Clone::clone(a);
6722                                 UnsignedGossipMessage::ChannelUpdate (
6723                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6724                                 )
6725                         },
6726                         nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6727                                 let mut a_nonref = Clone::clone(a);
6728                                 UnsignedGossipMessage::NodeAnnouncement (
6729                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6730                                 )
6731                         },
6732                 }
6733         }
6734         #[allow(unused)]
6735         pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
6736                 match native {
6737                         nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6738                                 UnsignedGossipMessage::ChannelAnnouncement (
6739                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6740                                 )
6741                         },
6742                         nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6743                                 UnsignedGossipMessage::ChannelUpdate (
6744                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
6745                                 )
6746                         },
6747                         nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6748                                 UnsignedGossipMessage::NodeAnnouncement (
6749                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6750                                 )
6751                         },
6752                 }
6753         }
6754 }
6755 /// Frees any resources used by the UnsignedGossipMessage
6756 #[no_mangle]
6757 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
6758 /// Creates a copy of the UnsignedGossipMessage
6759 #[no_mangle]
6760 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
6761         orig.clone()
6762 }
6763 #[allow(unused)]
6764 /// Used only if an object of this type is returned as a trait impl by a method
6765 pub(crate) extern "C" fn UnsignedGossipMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
6766         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const UnsignedGossipMessage)).clone() })) as *mut c_void
6767 }
6768 #[allow(unused)]
6769 /// Used only if an object of this type is returned as a trait impl by a method
6770 pub(crate) extern "C" fn UnsignedGossipMessage_free_void(this_ptr: *mut c_void) {
6771         let _ = unsafe { Box::from_raw(this_ptr as *mut UnsignedGossipMessage) };
6772 }
6773 #[no_mangle]
6774 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
6775 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
6776         UnsignedGossipMessage::ChannelAnnouncement(a, )
6777 }
6778 #[no_mangle]
6779 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
6780 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
6781         UnsignedGossipMessage::ChannelUpdate(a, )
6782 }
6783 #[no_mangle]
6784 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
6785 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
6786         UnsignedGossipMessage::NodeAnnouncement(a, )
6787 }
6788 #[no_mangle]
6789 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
6790 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
6791         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6792 }
6793 #[allow(unused)]
6794 pub(crate) extern "C" fn UnsignedGossipMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6795         UnsignedGossipMessage_write(unsafe { &*(obj as *const UnsignedGossipMessage) })
6796 }
6797
6798 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
6799 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
6800
6801 /// The unsigned part of a [`node_announcement`] message.
6802 ///
6803 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
6804 #[must_use]
6805 #[repr(C)]
6806 pub struct UnsignedNodeAnnouncement {
6807         /// A pointer to the opaque Rust object.
6808
6809         /// Nearly everywhere, inner must be non-null, however in places where
6810         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6811         pub inner: *mut nativeUnsignedNodeAnnouncement,
6812         /// Indicates that this is the only struct which contains the same pointer.
6813
6814         /// Rust functions which take ownership of an object provided via an argument require
6815         /// this to be true and invalidate the object pointed to by inner.
6816         pub is_owned: bool,
6817 }
6818
6819 impl Drop for UnsignedNodeAnnouncement {
6820         fn drop(&mut self) {
6821                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
6822                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6823                 }
6824         }
6825 }
6826 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
6827 #[no_mangle]
6828 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
6829 #[allow(unused)]
6830 /// Used only if an object of this type is returned as a trait impl by a method
6831 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
6832         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
6833 }
6834 #[allow(unused)]
6835 impl UnsignedNodeAnnouncement {
6836         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
6837                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6838         }
6839         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
6840                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6841         }
6842         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6843         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
6844                 assert!(self.is_owned);
6845                 let ret = ObjOps::untweak_ptr(self.inner);
6846                 self.inner = core::ptr::null_mut();
6847                 ret
6848         }
6849 }
6850 /// The advertised features
6851 #[no_mangle]
6852 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
6853         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6854         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 }
6855 }
6856 /// The advertised features
6857 #[no_mangle]
6858 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
6859         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
6860 }
6861 /// A strictly monotonic announcement counter, with gaps allowed
6862 #[no_mangle]
6863 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
6864         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
6865         *inner_val
6866 }
6867 /// A strictly monotonic announcement counter, with gaps allowed
6868 #[no_mangle]
6869 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
6870         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
6871 }
6872 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
6873 /// to this node).
6874 #[no_mangle]
6875 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6876         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
6877         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 }
6878 }
6879 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
6880 /// to this node).
6881 #[no_mangle]
6882 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6883         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
6884 }
6885 /// An RGB color for UI purposes
6886 #[no_mangle]
6887 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
6888         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
6889         inner_val
6890 }
6891 /// An RGB color for UI purposes
6892 #[no_mangle]
6893 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
6894         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
6895 }
6896 /// An alias, for UI purposes.
6897 ///
6898 /// This should be sanitized before use. There is no guarantee of uniqueness.
6899 #[no_mangle]
6900 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
6901         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
6902         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 }
6903 }
6904 /// An alias, for UI purposes.
6905 ///
6906 /// This should be sanitized before use. There is no guarantee of uniqueness.
6907 #[no_mangle]
6908 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
6909         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
6910 }
6911 /// List of addresses on which this node is reachable
6912 ///
6913 /// Returns a copy of the field.
6914 #[no_mangle]
6915 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
6916         let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
6917         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) }); };
6918         local_inner_val.into()
6919 }
6920 /// List of addresses on which this node is reachable
6921 #[no_mangle]
6922 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
6923         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
6924         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
6925 }
6926 /// Excess address data which was signed as a part of the message which we do not (yet) understand how
6927 /// to decode.
6928 ///
6929 /// This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol.
6930 ///
6931 /// Returns a copy of the field.
6932 #[no_mangle]
6933 pub extern "C" fn UnsignedNodeAnnouncement_get_excess_address_data(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6934         let mut inner_val = this_ptr.get_native_mut_ref().excess_address_data.clone();
6935         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6936         local_inner_val.into()
6937 }
6938 /// Excess address data which was signed as a part of the message which we do not (yet) understand how
6939 /// to decode.
6940 ///
6941 /// This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol.
6942 #[no_mangle]
6943 pub extern "C" fn UnsignedNodeAnnouncement_set_excess_address_data(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6944         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6945         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_address_data = local_val;
6946 }
6947 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6948 /// to decode.
6949 ///
6950 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6951 ///
6952 /// Returns a copy of the field.
6953 #[no_mangle]
6954 pub extern "C" fn UnsignedNodeAnnouncement_get_excess_data(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6955         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6956         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6957         local_inner_val.into()
6958 }
6959 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6960 /// to decode.
6961 ///
6962 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6963 #[no_mangle]
6964 pub extern "C" fn UnsignedNodeAnnouncement_set_excess_data(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6965         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6966         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6967 }
6968 /// Constructs a new UnsignedNodeAnnouncement given each field
6969 #[must_use]
6970 #[no_mangle]
6971 pub extern "C" fn UnsignedNodeAnnouncement_new(mut features_arg: crate::lightning::ln::features::NodeFeatures, mut timestamp_arg: u32, mut node_id_arg: crate::lightning::routing::gossip::NodeId, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut addresses_arg: crate::c_types::derived::CVec_SocketAddressZ, mut excess_address_data_arg: crate::c_types::derived::CVec_u8Z, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedNodeAnnouncement {
6972         let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
6973         let mut local_excess_address_data_arg = Vec::new(); for mut item in excess_address_data_arg.into_rust().drain(..) { local_excess_address_data_arg.push( { item }); };
6974         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6975         UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedNodeAnnouncement {
6976                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
6977                 timestamp: timestamp_arg,
6978                 node_id: *unsafe { Box::from_raw(node_id_arg.take_inner()) },
6979                 rgb: rgb_arg.data,
6980                 alias: *unsafe { Box::from_raw(alias_arg.take_inner()) },
6981                 addresses: local_addresses_arg,
6982                 excess_address_data: local_excess_address_data_arg,
6983                 excess_data: local_excess_data_arg,
6984         }), is_owned: true }
6985 }
6986 impl Clone for UnsignedNodeAnnouncement {
6987         fn clone(&self) -> Self {
6988                 Self {
6989                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6990                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6991                         is_owned: true,
6992                 }
6993         }
6994 }
6995 #[allow(unused)]
6996 /// Used only if an object of this type is returned as a trait impl by a method
6997 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6998         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
6999 }
7000 #[no_mangle]
7001 /// Creates a copy of the UnsignedNodeAnnouncement
7002 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
7003         orig.clone()
7004 }
7005 /// Get a string which allows debug introspection of a UnsignedNodeAnnouncement object
7006 pub extern "C" fn UnsignedNodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7007         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedNodeAnnouncement }).into()}
7008 /// Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement.
7009 #[no_mangle]
7010 pub extern "C" fn UnsignedNodeAnnouncement_hash(o: &UnsignedNodeAnnouncement) -> u64 {
7011         if o.inner.is_null() { return 0; }
7012         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7013         #[allow(deprecated)]
7014         let mut hasher = core::hash::SipHasher::new();
7015         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7016         core::hash::Hasher::finish(&hasher)
7017 }
7018 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
7019 /// This ignores pointers and is_owned flags and looks at the values in fields.
7020 /// Two objects with NULL inner values will be considered "equal" here.
7021 #[no_mangle]
7022 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
7023         if a.inner == b.inner { return true; }
7024         if a.inner.is_null() || b.inner.is_null() { return false; }
7025         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7026 }
7027
7028 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
7029 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
7030
7031 /// A [`node_announcement`] message to be sent to or received from a peer.
7032 ///
7033 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
7034 #[must_use]
7035 #[repr(C)]
7036 pub struct NodeAnnouncement {
7037         /// A pointer to the opaque Rust object.
7038
7039         /// Nearly everywhere, inner must be non-null, however in places where
7040         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7041         pub inner: *mut nativeNodeAnnouncement,
7042         /// Indicates that this is the only struct which contains the same pointer.
7043
7044         /// Rust functions which take ownership of an object provided via an argument require
7045         /// this to be true and invalidate the object pointed to by inner.
7046         pub is_owned: bool,
7047 }
7048
7049 impl Drop for NodeAnnouncement {
7050         fn drop(&mut self) {
7051                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
7052                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7053                 }
7054         }
7055 }
7056 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
7057 #[no_mangle]
7058 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
7059 #[allow(unused)]
7060 /// Used only if an object of this type is returned as a trait impl by a method
7061 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
7062         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
7063 }
7064 #[allow(unused)]
7065 impl NodeAnnouncement {
7066         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
7067                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7068         }
7069         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
7070                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7071         }
7072         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7073         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
7074                 assert!(self.is_owned);
7075                 let ret = ObjOps::untweak_ptr(self.inner);
7076                 self.inner = core::ptr::null_mut();
7077                 ret
7078         }
7079 }
7080 /// The signature by the node key
7081 #[no_mangle]
7082 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
7083         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7084         crate::c_types::ECDSASignature::from_rust(&inner_val)
7085 }
7086 /// The signature by the node key
7087 #[no_mangle]
7088 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
7089         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7090 }
7091 /// The actual content of the announcement
7092 #[no_mangle]
7093 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
7094         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7095         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 }
7096 }
7097 /// The actual content of the announcement
7098 #[no_mangle]
7099 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
7100         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7101 }
7102 /// Constructs a new NodeAnnouncement given each field
7103 #[must_use]
7104 #[no_mangle]
7105 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
7106         NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
7107                 signature: signature_arg.into_rust(),
7108                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7109         }), is_owned: true }
7110 }
7111 impl Clone for NodeAnnouncement {
7112         fn clone(&self) -> Self {
7113                 Self {
7114                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7115                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7116                         is_owned: true,
7117                 }
7118         }
7119 }
7120 #[allow(unused)]
7121 /// Used only if an object of this type is returned as a trait impl by a method
7122 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7123         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncement)).clone() })) as *mut c_void
7124 }
7125 #[no_mangle]
7126 /// Creates a copy of the NodeAnnouncement
7127 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
7128         orig.clone()
7129 }
7130 /// Get a string which allows debug introspection of a NodeAnnouncement object
7131 pub extern "C" fn NodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7132         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::NodeAnnouncement }).into()}
7133 /// Generates a non-cryptographic 64-bit hash of the NodeAnnouncement.
7134 #[no_mangle]
7135 pub extern "C" fn NodeAnnouncement_hash(o: &NodeAnnouncement) -> u64 {
7136         if o.inner.is_null() { return 0; }
7137         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7138         #[allow(deprecated)]
7139         let mut hasher = core::hash::SipHasher::new();
7140         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7141         core::hash::Hasher::finish(&hasher)
7142 }
7143 /// Checks if two NodeAnnouncements contain equal inner contents.
7144 /// This ignores pointers and is_owned flags and looks at the values in fields.
7145 /// Two objects with NULL inner values will be considered "equal" here.
7146 #[no_mangle]
7147 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
7148         if a.inner == b.inner { return true; }
7149         if a.inner.is_null() || b.inner.is_null() { return false; }
7150         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7151 }
7152
7153 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
7154 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
7155
7156 /// The unsigned part of a [`channel_announcement`] message.
7157 ///
7158 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7159 #[must_use]
7160 #[repr(C)]
7161 pub struct UnsignedChannelAnnouncement {
7162         /// A pointer to the opaque Rust object.
7163
7164         /// Nearly everywhere, inner must be non-null, however in places where
7165         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7166         pub inner: *mut nativeUnsignedChannelAnnouncement,
7167         /// Indicates that this is the only struct which contains the same pointer.
7168
7169         /// Rust functions which take ownership of an object provided via an argument require
7170         /// this to be true and invalidate the object pointed to by inner.
7171         pub is_owned: bool,
7172 }
7173
7174 impl Drop for UnsignedChannelAnnouncement {
7175         fn drop(&mut self) {
7176                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
7177                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7178                 }
7179         }
7180 }
7181 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
7182 #[no_mangle]
7183 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
7184 #[allow(unused)]
7185 /// Used only if an object of this type is returned as a trait impl by a method
7186 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7187         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
7188 }
7189 #[allow(unused)]
7190 impl UnsignedChannelAnnouncement {
7191         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
7192                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7193         }
7194         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
7195                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7196         }
7197         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7198         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
7199                 assert!(self.is_owned);
7200                 let ret = ObjOps::untweak_ptr(self.inner);
7201                 self.inner = core::ptr::null_mut();
7202                 ret
7203         }
7204 }
7205 /// The advertised channel features
7206 #[no_mangle]
7207 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
7208         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
7209         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 }
7210 }
7211 /// The advertised channel features
7212 #[no_mangle]
7213 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
7214         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
7215 }
7216 /// The genesis hash of the blockchain where the channel is to be opened
7217 #[no_mangle]
7218 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
7219         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7220         inner_val.as_ref()
7221 }
7222 /// The genesis hash of the blockchain where the channel is to be opened
7223 #[no_mangle]
7224 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
7225         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7226 }
7227 /// The short channel ID
7228 #[no_mangle]
7229 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
7230         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7231         *inner_val
7232 }
7233 /// The short channel ID
7234 #[no_mangle]
7235 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
7236         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7237 }
7238 /// One of the two `node_id`s which are endpoints of this channel
7239 #[no_mangle]
7240 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7241         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
7242         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 }
7243 }
7244 /// One of the two `node_id`s which are endpoints of this channel
7245 #[no_mangle]
7246 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7247         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
7248 }
7249 /// The other of the two `node_id`s which are endpoints of this channel
7250 #[no_mangle]
7251 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7252         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
7253         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 }
7254 }
7255 /// The other of the two `node_id`s which are endpoints of this channel
7256 #[no_mangle]
7257 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7258         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
7259 }
7260 /// The funding key for the first node
7261 #[no_mangle]
7262 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7263         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
7264         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 }
7265 }
7266 /// The funding key for the first node
7267 #[no_mangle]
7268 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7269         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
7270 }
7271 /// The funding key for the second node
7272 #[no_mangle]
7273 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7274         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
7275         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 }
7276 }
7277 /// The funding key for the second node
7278 #[no_mangle]
7279 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7280         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
7281 }
7282 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7283 /// to decode.
7284 ///
7285 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7286 ///
7287 /// Returns a copy of the field.
7288 #[no_mangle]
7289 pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
7290         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7291         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7292         local_inner_val.into()
7293 }
7294 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7295 /// to decode.
7296 ///
7297 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7298 #[no_mangle]
7299 pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
7300         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7301         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7302 }
7303 /// Constructs a new UnsignedChannelAnnouncement given each field
7304 #[must_use]
7305 #[no_mangle]
7306 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 {
7307         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7308         UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
7309                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
7310                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7311                 short_channel_id: short_channel_id_arg,
7312                 node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
7313                 node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
7314                 bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
7315                 bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
7316                 excess_data: local_excess_data_arg,
7317         }), is_owned: true }
7318 }
7319 impl Clone for UnsignedChannelAnnouncement {
7320         fn clone(&self) -> Self {
7321                 Self {
7322                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7323                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7324                         is_owned: true,
7325                 }
7326         }
7327 }
7328 #[allow(unused)]
7329 /// Used only if an object of this type is returned as a trait impl by a method
7330 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7331         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
7332 }
7333 #[no_mangle]
7334 /// Creates a copy of the UnsignedChannelAnnouncement
7335 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
7336         orig.clone()
7337 }
7338 /// Get a string which allows debug introspection of a UnsignedChannelAnnouncement object
7339 pub extern "C" fn UnsignedChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7340         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelAnnouncement }).into()}
7341 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement.
7342 #[no_mangle]
7343 pub extern "C" fn UnsignedChannelAnnouncement_hash(o: &UnsignedChannelAnnouncement) -> u64 {
7344         if o.inner.is_null() { return 0; }
7345         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7346         #[allow(deprecated)]
7347         let mut hasher = core::hash::SipHasher::new();
7348         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7349         core::hash::Hasher::finish(&hasher)
7350 }
7351 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
7352 /// This ignores pointers and is_owned flags and looks at the values in fields.
7353 /// Two objects with NULL inner values will be considered "equal" here.
7354 #[no_mangle]
7355 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
7356         if a.inner == b.inner { return true; }
7357         if a.inner.is_null() || b.inner.is_null() { return false; }
7358         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7359 }
7360
7361 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
7362 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
7363
7364 /// A [`channel_announcement`] message to be sent to or received from a peer.
7365 ///
7366 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7367 #[must_use]
7368 #[repr(C)]
7369 pub struct ChannelAnnouncement {
7370         /// A pointer to the opaque Rust object.
7371
7372         /// Nearly everywhere, inner must be non-null, however in places where
7373         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7374         pub inner: *mut nativeChannelAnnouncement,
7375         /// Indicates that this is the only struct which contains the same pointer.
7376
7377         /// Rust functions which take ownership of an object provided via an argument require
7378         /// this to be true and invalidate the object pointed to by inner.
7379         pub is_owned: bool,
7380 }
7381
7382 impl Drop for ChannelAnnouncement {
7383         fn drop(&mut self) {
7384                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
7385                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7386                 }
7387         }
7388 }
7389 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
7390 #[no_mangle]
7391 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
7392 #[allow(unused)]
7393 /// Used only if an object of this type is returned as a trait impl by a method
7394 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7395         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
7396 }
7397 #[allow(unused)]
7398 impl ChannelAnnouncement {
7399         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
7400                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7401         }
7402         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
7403                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7404         }
7405         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7406         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
7407                 assert!(self.is_owned);
7408                 let ret = ObjOps::untweak_ptr(self.inner);
7409                 self.inner = core::ptr::null_mut();
7410                 ret
7411         }
7412 }
7413 /// Authentication of the announcement by the first public node
7414 #[no_mangle]
7415 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7416         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
7417         crate::c_types::ECDSASignature::from_rust(&inner_val)
7418 }
7419 /// Authentication of the announcement by the first public node
7420 #[no_mangle]
7421 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7422         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
7423 }
7424 /// Authentication of the announcement by the second public node
7425 #[no_mangle]
7426 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7427         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
7428         crate::c_types::ECDSASignature::from_rust(&inner_val)
7429 }
7430 /// Authentication of the announcement by the second public node
7431 #[no_mangle]
7432 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7433         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
7434 }
7435 /// Proof of funding UTXO ownership by the first public node
7436 #[no_mangle]
7437 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7438         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
7439         crate::c_types::ECDSASignature::from_rust(&inner_val)
7440 }
7441 /// Proof of funding UTXO ownership by the first public node
7442 #[no_mangle]
7443 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7444         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
7445 }
7446 /// Proof of funding UTXO ownership by the second public node
7447 #[no_mangle]
7448 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7449         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
7450         crate::c_types::ECDSASignature::from_rust(&inner_val)
7451 }
7452 /// Proof of funding UTXO ownership by the second public node
7453 #[no_mangle]
7454 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7455         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
7456 }
7457 /// The actual announcement
7458 #[no_mangle]
7459 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
7460         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7461         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 }
7462 }
7463 /// The actual announcement
7464 #[no_mangle]
7465 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
7466         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7467 }
7468 /// Constructs a new ChannelAnnouncement given each field
7469 #[must_use]
7470 #[no_mangle]
7471 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 {
7472         ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
7473                 node_signature_1: node_signature_1_arg.into_rust(),
7474                 node_signature_2: node_signature_2_arg.into_rust(),
7475                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
7476                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
7477                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7478         }), is_owned: true }
7479 }
7480 impl Clone for ChannelAnnouncement {
7481         fn clone(&self) -> Self {
7482                 Self {
7483                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7484                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7485                         is_owned: true,
7486                 }
7487         }
7488 }
7489 #[allow(unused)]
7490 /// Used only if an object of this type is returned as a trait impl by a method
7491 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7492         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelAnnouncement)).clone() })) as *mut c_void
7493 }
7494 #[no_mangle]
7495 /// Creates a copy of the ChannelAnnouncement
7496 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
7497         orig.clone()
7498 }
7499 /// Get a string which allows debug introspection of a ChannelAnnouncement object
7500 pub extern "C" fn ChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7501         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelAnnouncement }).into()}
7502 /// Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement.
7503 #[no_mangle]
7504 pub extern "C" fn ChannelAnnouncement_hash(o: &ChannelAnnouncement) -> u64 {
7505         if o.inner.is_null() { return 0; }
7506         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7507         #[allow(deprecated)]
7508         let mut hasher = core::hash::SipHasher::new();
7509         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7510         core::hash::Hasher::finish(&hasher)
7511 }
7512 /// Checks if two ChannelAnnouncements contain equal inner contents.
7513 /// This ignores pointers and is_owned flags and looks at the values in fields.
7514 /// Two objects with NULL inner values will be considered "equal" here.
7515 #[no_mangle]
7516 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
7517         if a.inner == b.inner { return true; }
7518         if a.inner.is_null() || b.inner.is_null() { return false; }
7519         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7520 }
7521
7522 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
7523 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
7524
7525 /// The unsigned part of a [`channel_update`] message.
7526 ///
7527 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7528 #[must_use]
7529 #[repr(C)]
7530 pub struct UnsignedChannelUpdate {
7531         /// A pointer to the opaque Rust object.
7532
7533         /// Nearly everywhere, inner must be non-null, however in places where
7534         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7535         pub inner: *mut nativeUnsignedChannelUpdate,
7536         /// Indicates that this is the only struct which contains the same pointer.
7537
7538         /// Rust functions which take ownership of an object provided via an argument require
7539         /// this to be true and invalidate the object pointed to by inner.
7540         pub is_owned: bool,
7541 }
7542
7543 impl Drop for UnsignedChannelUpdate {
7544         fn drop(&mut self) {
7545                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
7546                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7547                 }
7548         }
7549 }
7550 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
7551 #[no_mangle]
7552 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
7553 #[allow(unused)]
7554 /// Used only if an object of this type is returned as a trait impl by a method
7555 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
7556         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
7557 }
7558 #[allow(unused)]
7559 impl UnsignedChannelUpdate {
7560         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
7561                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7562         }
7563         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
7564                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7565         }
7566         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7567         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
7568                 assert!(self.is_owned);
7569                 let ret = ObjOps::untweak_ptr(self.inner);
7570                 self.inner = core::ptr::null_mut();
7571                 ret
7572         }
7573 }
7574 /// The genesis hash of the blockchain where the channel is to be opened
7575 #[no_mangle]
7576 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
7577         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7578         inner_val.as_ref()
7579 }
7580 /// The genesis hash of the blockchain where the channel is to be opened
7581 #[no_mangle]
7582 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
7583         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7584 }
7585 /// The short channel ID
7586 #[no_mangle]
7587 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
7588         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7589         *inner_val
7590 }
7591 /// The short channel ID
7592 #[no_mangle]
7593 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7594         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7595 }
7596 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7597 #[no_mangle]
7598 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
7599         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
7600         *inner_val
7601 }
7602 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7603 #[no_mangle]
7604 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7605         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
7606 }
7607 /// Channel flags
7608 #[no_mangle]
7609 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
7610         let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
7611         *inner_val
7612 }
7613 /// Channel flags
7614 #[no_mangle]
7615 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
7616         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
7617 }
7618 /// The number of blocks such that if:
7619 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7620 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7621 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7622 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7623 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7624 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7625 /// constructing the route.
7626 #[no_mangle]
7627 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
7628         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
7629         *inner_val
7630 }
7631 /// The number of blocks such that if:
7632 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7633 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7634 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7635 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7636 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7637 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7638 /// constructing the route.
7639 #[no_mangle]
7640 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
7641         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
7642 }
7643 /// The minimum HTLC size incoming to sender, in milli-satoshi
7644 #[no_mangle]
7645 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7646         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
7647         *inner_val
7648 }
7649 /// The minimum HTLC size incoming to sender, in milli-satoshi
7650 #[no_mangle]
7651 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7652         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
7653 }
7654 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7655 ///
7656 /// This used to be optional.
7657 #[no_mangle]
7658 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7659         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
7660         *inner_val
7661 }
7662 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7663 ///
7664 /// This used to be optional.
7665 #[no_mangle]
7666 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7667         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
7668 }
7669 /// The base HTLC fee charged by sender, in milli-satoshi
7670 #[no_mangle]
7671 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
7672         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
7673         *inner_val
7674 }
7675 /// The base HTLC fee charged by sender, in milli-satoshi
7676 #[no_mangle]
7677 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7678         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
7679 }
7680 /// The amount to fee multiplier, in micro-satoshi
7681 #[no_mangle]
7682 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
7683         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
7684         *inner_val
7685 }
7686 /// The amount to fee multiplier, in micro-satoshi
7687 #[no_mangle]
7688 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7689         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
7690 }
7691 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7692 /// to decode.
7693 ///
7694 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7695 ///
7696 /// Returns a copy of the field.
7697 #[no_mangle]
7698 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
7699         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7700         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7701         local_inner_val.into()
7702 }
7703 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7704 /// to decode.
7705 ///
7706 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7707 #[no_mangle]
7708 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
7709         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7710         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7711 }
7712 /// Constructs a new UnsignedChannelUpdate given each field
7713 #[must_use]
7714 #[no_mangle]
7715 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 {
7716         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7717         UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
7718                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7719                 short_channel_id: short_channel_id_arg,
7720                 timestamp: timestamp_arg,
7721                 flags: flags_arg,
7722                 cltv_expiry_delta: cltv_expiry_delta_arg,
7723                 htlc_minimum_msat: htlc_minimum_msat_arg,
7724                 htlc_maximum_msat: htlc_maximum_msat_arg,
7725                 fee_base_msat: fee_base_msat_arg,
7726                 fee_proportional_millionths: fee_proportional_millionths_arg,
7727                 excess_data: local_excess_data_arg,
7728         }), is_owned: true }
7729 }
7730 impl Clone for UnsignedChannelUpdate {
7731         fn clone(&self) -> Self {
7732                 Self {
7733                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7734                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7735                         is_owned: true,
7736                 }
7737         }
7738 }
7739 #[allow(unused)]
7740 /// Used only if an object of this type is returned as a trait impl by a method
7741 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7742         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
7743 }
7744 #[no_mangle]
7745 /// Creates a copy of the UnsignedChannelUpdate
7746 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
7747         orig.clone()
7748 }
7749 /// Get a string which allows debug introspection of a UnsignedChannelUpdate object
7750 pub extern "C" fn UnsignedChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7751         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelUpdate }).into()}
7752 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate.
7753 #[no_mangle]
7754 pub extern "C" fn UnsignedChannelUpdate_hash(o: &UnsignedChannelUpdate) -> u64 {
7755         if o.inner.is_null() { return 0; }
7756         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7757         #[allow(deprecated)]
7758         let mut hasher = core::hash::SipHasher::new();
7759         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7760         core::hash::Hasher::finish(&hasher)
7761 }
7762 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
7763 /// This ignores pointers and is_owned flags and looks at the values in fields.
7764 /// Two objects with NULL inner values will be considered "equal" here.
7765 #[no_mangle]
7766 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
7767         if a.inner == b.inner { return true; }
7768         if a.inner.is_null() || b.inner.is_null() { return false; }
7769         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7770 }
7771
7772 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
7773 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
7774
7775 /// A [`channel_update`] message to be sent to or received from a peer.
7776 ///
7777 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7778 #[must_use]
7779 #[repr(C)]
7780 pub struct ChannelUpdate {
7781         /// A pointer to the opaque Rust object.
7782
7783         /// Nearly everywhere, inner must be non-null, however in places where
7784         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7785         pub inner: *mut nativeChannelUpdate,
7786         /// Indicates that this is the only struct which contains the same pointer.
7787
7788         /// Rust functions which take ownership of an object provided via an argument require
7789         /// this to be true and invalidate the object pointed to by inner.
7790         pub is_owned: bool,
7791 }
7792
7793 impl Drop for ChannelUpdate {
7794         fn drop(&mut self) {
7795                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
7796                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7797                 }
7798         }
7799 }
7800 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
7801 #[no_mangle]
7802 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
7803 #[allow(unused)]
7804 /// Used only if an object of this type is returned as a trait impl by a method
7805 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
7806         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
7807 }
7808 #[allow(unused)]
7809 impl ChannelUpdate {
7810         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
7811                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7812         }
7813         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
7814                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7815         }
7816         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7817         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
7818                 assert!(self.is_owned);
7819                 let ret = ObjOps::untweak_ptr(self.inner);
7820                 self.inner = core::ptr::null_mut();
7821                 ret
7822         }
7823 }
7824 /// A signature of the channel update
7825 #[no_mangle]
7826 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
7827         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7828         crate::c_types::ECDSASignature::from_rust(&inner_val)
7829 }
7830 /// A signature of the channel update
7831 #[no_mangle]
7832 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
7833         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7834 }
7835 /// The actual channel update
7836 #[no_mangle]
7837 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
7838         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7839         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 }
7840 }
7841 /// The actual channel update
7842 #[no_mangle]
7843 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
7844         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7845 }
7846 /// Constructs a new ChannelUpdate given each field
7847 #[must_use]
7848 #[no_mangle]
7849 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
7850         ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
7851                 signature: signature_arg.into_rust(),
7852                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7853         }), is_owned: true }
7854 }
7855 impl Clone for ChannelUpdate {
7856         fn clone(&self) -> Self {
7857                 Self {
7858                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7859                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7860                         is_owned: true,
7861                 }
7862         }
7863 }
7864 #[allow(unused)]
7865 /// Used only if an object of this type is returned as a trait impl by a method
7866 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7867         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelUpdate)).clone() })) as *mut c_void
7868 }
7869 #[no_mangle]
7870 /// Creates a copy of the ChannelUpdate
7871 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
7872         orig.clone()
7873 }
7874 /// Get a string which allows debug introspection of a ChannelUpdate object
7875 pub extern "C" fn ChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7876         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelUpdate }).into()}
7877 /// Generates a non-cryptographic 64-bit hash of the ChannelUpdate.
7878 #[no_mangle]
7879 pub extern "C" fn ChannelUpdate_hash(o: &ChannelUpdate) -> u64 {
7880         if o.inner.is_null() { return 0; }
7881         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7882         #[allow(deprecated)]
7883         let mut hasher = core::hash::SipHasher::new();
7884         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7885         core::hash::Hasher::finish(&hasher)
7886 }
7887 /// Checks if two ChannelUpdates contain equal inner contents.
7888 /// This ignores pointers and is_owned flags and looks at the values in fields.
7889 /// Two objects with NULL inner values will be considered "equal" here.
7890 #[no_mangle]
7891 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
7892         if a.inner == b.inner { return true; }
7893         if a.inner.is_null() || b.inner.is_null() { return false; }
7894         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7895 }
7896
7897 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
7898 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
7899
7900 /// A [`query_channel_range`] message is used to query a peer for channel
7901 /// UTXOs in a range of blocks. The recipient of a query makes a best
7902 /// effort to reply to the query using one or more [`ReplyChannelRange`]
7903 /// messages.
7904 ///
7905 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
7906 #[must_use]
7907 #[repr(C)]
7908 pub struct QueryChannelRange {
7909         /// A pointer to the opaque Rust object.
7910
7911         /// Nearly everywhere, inner must be non-null, however in places where
7912         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7913         pub inner: *mut nativeQueryChannelRange,
7914         /// Indicates that this is the only struct which contains the same pointer.
7915
7916         /// Rust functions which take ownership of an object provided via an argument require
7917         /// this to be true and invalidate the object pointed to by inner.
7918         pub is_owned: bool,
7919 }
7920
7921 impl Drop for QueryChannelRange {
7922         fn drop(&mut self) {
7923                 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
7924                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7925                 }
7926         }
7927 }
7928 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
7929 #[no_mangle]
7930 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
7931 #[allow(unused)]
7932 /// Used only if an object of this type is returned as a trait impl by a method
7933 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
7934         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
7935 }
7936 #[allow(unused)]
7937 impl QueryChannelRange {
7938         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
7939                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7940         }
7941         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
7942                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7943         }
7944         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7945         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
7946                 assert!(self.is_owned);
7947                 let ret = ObjOps::untweak_ptr(self.inner);
7948                 self.inner = core::ptr::null_mut();
7949                 ret
7950         }
7951 }
7952 /// The genesis hash of the blockchain being queried
7953 #[no_mangle]
7954 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
7955         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7956         inner_val.as_ref()
7957 }
7958 /// The genesis hash of the blockchain being queried
7959 #[no_mangle]
7960 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
7961         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7962 }
7963 /// The height of the first block for the channel UTXOs being queried
7964 #[no_mangle]
7965 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
7966         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
7967         *inner_val
7968 }
7969 /// The height of the first block for the channel UTXOs being queried
7970 #[no_mangle]
7971 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
7972         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
7973 }
7974 /// The number of blocks to include in the query results
7975 #[no_mangle]
7976 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
7977         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
7978         *inner_val
7979 }
7980 /// The number of blocks to include in the query results
7981 #[no_mangle]
7982 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
7983         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
7984 }
7985 /// Constructs a new QueryChannelRange given each field
7986 #[must_use]
7987 #[no_mangle]
7988 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 {
7989         QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
7990                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7991                 first_blocknum: first_blocknum_arg,
7992                 number_of_blocks: number_of_blocks_arg,
7993         }), is_owned: true }
7994 }
7995 impl Clone for QueryChannelRange {
7996         fn clone(&self) -> Self {
7997                 Self {
7998                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
7999                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8000                         is_owned: true,
8001                 }
8002         }
8003 }
8004 #[allow(unused)]
8005 /// Used only if an object of this type is returned as a trait impl by a method
8006 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8007         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryChannelRange)).clone() })) as *mut c_void
8008 }
8009 #[no_mangle]
8010 /// Creates a copy of the QueryChannelRange
8011 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
8012         orig.clone()
8013 }
8014 /// Get a string which allows debug introspection of a QueryChannelRange object
8015 pub extern "C" fn QueryChannelRange_debug_str_void(o: *const c_void) -> Str {
8016         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryChannelRange }).into()}
8017 /// Generates a non-cryptographic 64-bit hash of the QueryChannelRange.
8018 #[no_mangle]
8019 pub extern "C" fn QueryChannelRange_hash(o: &QueryChannelRange) -> u64 {
8020         if o.inner.is_null() { return 0; }
8021         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8022         #[allow(deprecated)]
8023         let mut hasher = core::hash::SipHasher::new();
8024         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8025         core::hash::Hasher::finish(&hasher)
8026 }
8027 /// Checks if two QueryChannelRanges contain equal inner contents.
8028 /// This ignores pointers and is_owned flags and looks at the values in fields.
8029 /// Two objects with NULL inner values will be considered "equal" here.
8030 #[no_mangle]
8031 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
8032         if a.inner == b.inner { return true; }
8033         if a.inner.is_null() || b.inner.is_null() { return false; }
8034         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8035 }
8036
8037 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
8038 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
8039
8040 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
8041 /// message.
8042 ///
8043 /// Multiple `reply_channel_range` messages can be sent in reply
8044 /// to a single [`QueryChannelRange`] message. The query recipient makes a
8045 /// best effort to respond based on their local network view which may
8046 /// not be a perfect view of the network. The `short_channel_id`s in the
8047 /// reply are encoded. We only support `encoding_type=0` uncompressed
8048 /// serialization and do not support `encoding_type=1` zlib serialization.
8049 ///
8050 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
8051 #[must_use]
8052 #[repr(C)]
8053 pub struct ReplyChannelRange {
8054         /// A pointer to the opaque Rust object.
8055
8056         /// Nearly everywhere, inner must be non-null, however in places where
8057         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8058         pub inner: *mut nativeReplyChannelRange,
8059         /// Indicates that this is the only struct which contains the same pointer.
8060
8061         /// Rust functions which take ownership of an object provided via an argument require
8062         /// this to be true and invalidate the object pointed to by inner.
8063         pub is_owned: bool,
8064 }
8065
8066 impl Drop for ReplyChannelRange {
8067         fn drop(&mut self) {
8068                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
8069                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8070                 }
8071         }
8072 }
8073 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
8074 #[no_mangle]
8075 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
8076 #[allow(unused)]
8077 /// Used only if an object of this type is returned as a trait impl by a method
8078 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
8079         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
8080 }
8081 #[allow(unused)]
8082 impl ReplyChannelRange {
8083         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
8084                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8085         }
8086         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
8087                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8088         }
8089         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8090         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
8091                 assert!(self.is_owned);
8092                 let ret = ObjOps::untweak_ptr(self.inner);
8093                 self.inner = core::ptr::null_mut();
8094                 ret
8095         }
8096 }
8097 /// The genesis hash of the blockchain being queried
8098 #[no_mangle]
8099 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
8100         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8101         inner_val.as_ref()
8102 }
8103 /// The genesis hash of the blockchain being queried
8104 #[no_mangle]
8105 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
8106         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8107 }
8108 /// The height of the first block in the range of the reply
8109 #[no_mangle]
8110 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
8111         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
8112         *inner_val
8113 }
8114 /// The height of the first block in the range of the reply
8115 #[no_mangle]
8116 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8117         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
8118 }
8119 /// The number of blocks included in the range of the reply
8120 #[no_mangle]
8121 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
8122         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
8123         *inner_val
8124 }
8125 /// The number of blocks included in the range of the reply
8126 #[no_mangle]
8127 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8128         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
8129 }
8130 /// True when this is the final reply for a query
8131 #[no_mangle]
8132 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
8133         let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
8134         *inner_val
8135 }
8136 /// True when this is the final reply for a query
8137 #[no_mangle]
8138 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
8139         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
8140 }
8141 /// The `short_channel_id`s in the channel range
8142 ///
8143 /// Returns a copy of the field.
8144 #[no_mangle]
8145 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
8146         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8147         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8148         local_inner_val.into()
8149 }
8150 /// The `short_channel_id`s in the channel range
8151 #[no_mangle]
8152 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
8153         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8154         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8155 }
8156 /// Constructs a new ReplyChannelRange given each field
8157 #[must_use]
8158 #[no_mangle]
8159 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 {
8160         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 }); };
8161         ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
8162                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8163                 first_blocknum: first_blocknum_arg,
8164                 number_of_blocks: number_of_blocks_arg,
8165                 sync_complete: sync_complete_arg,
8166                 short_channel_ids: local_short_channel_ids_arg,
8167         }), is_owned: true }
8168 }
8169 impl Clone for ReplyChannelRange {
8170         fn clone(&self) -> Self {
8171                 Self {
8172                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
8173                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8174                         is_owned: true,
8175                 }
8176         }
8177 }
8178 #[allow(unused)]
8179 /// Used only if an object of this type is returned as a trait impl by a method
8180 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8181         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyChannelRange)).clone() })) as *mut c_void
8182 }
8183 #[no_mangle]
8184 /// Creates a copy of the ReplyChannelRange
8185 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
8186         orig.clone()
8187 }
8188 /// Get a string which allows debug introspection of a ReplyChannelRange object
8189 pub extern "C" fn ReplyChannelRange_debug_str_void(o: *const c_void) -> Str {
8190         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyChannelRange }).into()}
8191 /// Generates a non-cryptographic 64-bit hash of the ReplyChannelRange.
8192 #[no_mangle]
8193 pub extern "C" fn ReplyChannelRange_hash(o: &ReplyChannelRange) -> u64 {
8194         if o.inner.is_null() { return 0; }
8195         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8196         #[allow(deprecated)]
8197         let mut hasher = core::hash::SipHasher::new();
8198         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8199         core::hash::Hasher::finish(&hasher)
8200 }
8201 /// Checks if two ReplyChannelRanges contain equal inner contents.
8202 /// This ignores pointers and is_owned flags and looks at the values in fields.
8203 /// Two objects with NULL inner values will be considered "equal" here.
8204 #[no_mangle]
8205 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
8206         if a.inner == b.inner { return true; }
8207         if a.inner.is_null() || b.inner.is_null() { return false; }
8208         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8209 }
8210
8211 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
8212 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
8213
8214 /// A [`query_short_channel_ids`] message is used to query a peer for
8215 /// routing gossip messages related to one or more `short_channel_id`s.
8216 ///
8217 /// The query recipient will reply with the latest, if available,
8218 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
8219 /// it maintains for the requested `short_channel_id`s followed by a
8220 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
8221 /// this query are encoded. We only support `encoding_type=0` uncompressed
8222 /// serialization and do not support `encoding_type=1` zlib serialization.
8223 ///
8224 /// [`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
8225 #[must_use]
8226 #[repr(C)]
8227 pub struct QueryShortChannelIds {
8228         /// A pointer to the opaque Rust object.
8229
8230         /// Nearly everywhere, inner must be non-null, however in places where
8231         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8232         pub inner: *mut nativeQueryShortChannelIds,
8233         /// Indicates that this is the only struct which contains the same pointer.
8234
8235         /// Rust functions which take ownership of an object provided via an argument require
8236         /// this to be true and invalidate the object pointed to by inner.
8237         pub is_owned: bool,
8238 }
8239
8240 impl Drop for QueryShortChannelIds {
8241         fn drop(&mut self) {
8242                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
8243                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8244                 }
8245         }
8246 }
8247 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
8248 #[no_mangle]
8249 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
8250 #[allow(unused)]
8251 /// Used only if an object of this type is returned as a trait impl by a method
8252 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
8253         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
8254 }
8255 #[allow(unused)]
8256 impl QueryShortChannelIds {
8257         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
8258                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8259         }
8260         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
8261                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8262         }
8263         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8264         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
8265                 assert!(self.is_owned);
8266                 let ret = ObjOps::untweak_ptr(self.inner);
8267                 self.inner = core::ptr::null_mut();
8268                 ret
8269         }
8270 }
8271 /// The genesis hash of the blockchain being queried
8272 #[no_mangle]
8273 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
8274         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8275         inner_val.as_ref()
8276 }
8277 /// The genesis hash of the blockchain being queried
8278 #[no_mangle]
8279 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
8280         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8281 }
8282 /// The short_channel_ids that are being queried
8283 ///
8284 /// Returns a copy of the field.
8285 #[no_mangle]
8286 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
8287         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8288         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8289         local_inner_val.into()
8290 }
8291 /// The short_channel_ids that are being queried
8292 #[no_mangle]
8293 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
8294         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8295         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8296 }
8297 /// Constructs a new QueryShortChannelIds given each field
8298 #[must_use]
8299 #[no_mangle]
8300 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 {
8301         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 }); };
8302         QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
8303                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8304                 short_channel_ids: local_short_channel_ids_arg,
8305         }), is_owned: true }
8306 }
8307 impl Clone for QueryShortChannelIds {
8308         fn clone(&self) -> Self {
8309                 Self {
8310                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
8311                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8312                         is_owned: true,
8313                 }
8314         }
8315 }
8316 #[allow(unused)]
8317 /// Used only if an object of this type is returned as a trait impl by a method
8318 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
8319         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryShortChannelIds)).clone() })) as *mut c_void
8320 }
8321 #[no_mangle]
8322 /// Creates a copy of the QueryShortChannelIds
8323 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
8324         orig.clone()
8325 }
8326 /// Get a string which allows debug introspection of a QueryShortChannelIds object
8327 pub extern "C" fn QueryShortChannelIds_debug_str_void(o: *const c_void) -> Str {
8328         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryShortChannelIds }).into()}
8329 /// Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds.
8330 #[no_mangle]
8331 pub extern "C" fn QueryShortChannelIds_hash(o: &QueryShortChannelIds) -> u64 {
8332         if o.inner.is_null() { return 0; }
8333         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8334         #[allow(deprecated)]
8335         let mut hasher = core::hash::SipHasher::new();
8336         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8337         core::hash::Hasher::finish(&hasher)
8338 }
8339 /// Checks if two QueryShortChannelIdss contain equal inner contents.
8340 /// This ignores pointers and is_owned flags and looks at the values in fields.
8341 /// Two objects with NULL inner values will be considered "equal" here.
8342 #[no_mangle]
8343 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
8344         if a.inner == b.inner { return true; }
8345         if a.inner.is_null() || b.inner.is_null() { return false; }
8346         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8347 }
8348
8349 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
8350 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
8351
8352 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
8353 /// message. The query recipient makes a best
8354 /// effort to respond based on their local network view which may not be
8355 /// a perfect view of the network.
8356 ///
8357 /// [`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
8358 #[must_use]
8359 #[repr(C)]
8360 pub struct ReplyShortChannelIdsEnd {
8361         /// A pointer to the opaque Rust object.
8362
8363         /// Nearly everywhere, inner must be non-null, however in places where
8364         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8365         pub inner: *mut nativeReplyShortChannelIdsEnd,
8366         /// Indicates that this is the only struct which contains the same pointer.
8367
8368         /// Rust functions which take ownership of an object provided via an argument require
8369         /// this to be true and invalidate the object pointed to by inner.
8370         pub is_owned: bool,
8371 }
8372
8373 impl Drop for ReplyShortChannelIdsEnd {
8374         fn drop(&mut self) {
8375                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
8376                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8377                 }
8378         }
8379 }
8380 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
8381 #[no_mangle]
8382 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
8383 #[allow(unused)]
8384 /// Used only if an object of this type is returned as a trait impl by a method
8385 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
8386         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
8387 }
8388 #[allow(unused)]
8389 impl ReplyShortChannelIdsEnd {
8390         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
8391                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8392         }
8393         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
8394                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8395         }
8396         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8397         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
8398                 assert!(self.is_owned);
8399                 let ret = ObjOps::untweak_ptr(self.inner);
8400                 self.inner = core::ptr::null_mut();
8401                 ret
8402         }
8403 }
8404 /// The genesis hash of the blockchain that was queried
8405 #[no_mangle]
8406 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
8407         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8408         inner_val.as_ref()
8409 }
8410 /// The genesis hash of the blockchain that was queried
8411 #[no_mangle]
8412 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
8413         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8414 }
8415 /// Indicates if the query recipient maintains up-to-date channel
8416 /// information for the `chain_hash`
8417 #[no_mangle]
8418 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
8419         let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
8420         *inner_val
8421 }
8422 /// Indicates if the query recipient maintains up-to-date channel
8423 /// information for the `chain_hash`
8424 #[no_mangle]
8425 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
8426         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
8427 }
8428 /// Constructs a new ReplyShortChannelIdsEnd given each field
8429 #[must_use]
8430 #[no_mangle]
8431 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
8432         ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
8433                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8434                 full_information: full_information_arg,
8435         }), is_owned: true }
8436 }
8437 impl Clone for ReplyShortChannelIdsEnd {
8438         fn clone(&self) -> Self {
8439                 Self {
8440                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
8441                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8442                         is_owned: true,
8443                 }
8444         }
8445 }
8446 #[allow(unused)]
8447 /// Used only if an object of this type is returned as a trait impl by a method
8448 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
8449         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
8450 }
8451 #[no_mangle]
8452 /// Creates a copy of the ReplyShortChannelIdsEnd
8453 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
8454         orig.clone()
8455 }
8456 /// Get a string which allows debug introspection of a ReplyShortChannelIdsEnd object
8457 pub extern "C" fn ReplyShortChannelIdsEnd_debug_str_void(o: *const c_void) -> Str {
8458         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyShortChannelIdsEnd }).into()}
8459 /// Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd.
8460 #[no_mangle]
8461 pub extern "C" fn ReplyShortChannelIdsEnd_hash(o: &ReplyShortChannelIdsEnd) -> u64 {
8462         if o.inner.is_null() { return 0; }
8463         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8464         #[allow(deprecated)]
8465         let mut hasher = core::hash::SipHasher::new();
8466         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8467         core::hash::Hasher::finish(&hasher)
8468 }
8469 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
8470 /// This ignores pointers and is_owned flags and looks at the values in fields.
8471 /// Two objects with NULL inner values will be considered "equal" here.
8472 #[no_mangle]
8473 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
8474         if a.inner == b.inner { return true; }
8475         if a.inner.is_null() || b.inner.is_null() { return false; }
8476         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8477 }
8478
8479 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
8480 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
8481
8482 /// A [`gossip_timestamp_filter`] message is used by a node to request
8483 /// gossip relay for messages in the requested time range when the
8484 /// `gossip_queries` feature has been negotiated.
8485 ///
8486 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
8487 #[must_use]
8488 #[repr(C)]
8489 pub struct GossipTimestampFilter {
8490         /// A pointer to the opaque Rust object.
8491
8492         /// Nearly everywhere, inner must be non-null, however in places where
8493         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8494         pub inner: *mut nativeGossipTimestampFilter,
8495         /// Indicates that this is the only struct which contains the same pointer.
8496
8497         /// Rust functions which take ownership of an object provided via an argument require
8498         /// this to be true and invalidate the object pointed to by inner.
8499         pub is_owned: bool,
8500 }
8501
8502 impl Drop for GossipTimestampFilter {
8503         fn drop(&mut self) {
8504                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
8505                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8506                 }
8507         }
8508 }
8509 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
8510 #[no_mangle]
8511 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
8512 #[allow(unused)]
8513 /// Used only if an object of this type is returned as a trait impl by a method
8514 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
8515         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
8516 }
8517 #[allow(unused)]
8518 impl GossipTimestampFilter {
8519         pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
8520                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8521         }
8522         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
8523                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8524         }
8525         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8526         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
8527                 assert!(self.is_owned);
8528                 let ret = ObjOps::untweak_ptr(self.inner);
8529                 self.inner = core::ptr::null_mut();
8530                 ret
8531         }
8532 }
8533 /// The genesis hash of the blockchain for channel and node information
8534 #[no_mangle]
8535 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
8536         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8537         inner_val.as_ref()
8538 }
8539 /// The genesis hash of the blockchain for channel and node information
8540 #[no_mangle]
8541 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
8542         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8543 }
8544 /// The starting unix timestamp
8545 #[no_mangle]
8546 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
8547         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
8548         *inner_val
8549 }
8550 /// The starting unix timestamp
8551 #[no_mangle]
8552 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8553         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
8554 }
8555 /// The range of information in seconds
8556 #[no_mangle]
8557 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
8558         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
8559         *inner_val
8560 }
8561 /// The range of information in seconds
8562 #[no_mangle]
8563 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8564         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
8565 }
8566 /// Constructs a new GossipTimestampFilter given each field
8567 #[must_use]
8568 #[no_mangle]
8569 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 {
8570         GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
8571                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8572                 first_timestamp: first_timestamp_arg,
8573                 timestamp_range: timestamp_range_arg,
8574         }), is_owned: true }
8575 }
8576 impl Clone for GossipTimestampFilter {
8577         fn clone(&self) -> Self {
8578                 Self {
8579                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
8580                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8581                         is_owned: true,
8582                 }
8583         }
8584 }
8585 #[allow(unused)]
8586 /// Used only if an object of this type is returned as a trait impl by a method
8587 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
8588         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeGossipTimestampFilter)).clone() })) as *mut c_void
8589 }
8590 #[no_mangle]
8591 /// Creates a copy of the GossipTimestampFilter
8592 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
8593         orig.clone()
8594 }
8595 /// Get a string which allows debug introspection of a GossipTimestampFilter object
8596 pub extern "C" fn GossipTimestampFilter_debug_str_void(o: *const c_void) -> Str {
8597         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::GossipTimestampFilter }).into()}
8598 /// Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter.
8599 #[no_mangle]
8600 pub extern "C" fn GossipTimestampFilter_hash(o: &GossipTimestampFilter) -> u64 {
8601         if o.inner.is_null() { return 0; }
8602         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8603         #[allow(deprecated)]
8604         let mut hasher = core::hash::SipHasher::new();
8605         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8606         core::hash::Hasher::finish(&hasher)
8607 }
8608 /// Checks if two GossipTimestampFilters contain equal inner contents.
8609 /// This ignores pointers and is_owned flags and looks at the values in fields.
8610 /// Two objects with NULL inner values will be considered "equal" here.
8611 #[no_mangle]
8612 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
8613         if a.inner == b.inner { return true; }
8614         if a.inner.is_null() || b.inner.is_null() { return false; }
8615         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8616 }
8617 /// Used to put an error message in a [`LightningError`].
8618 #[derive(Clone)]
8619 #[must_use]
8620 #[repr(C)]
8621 pub enum ErrorAction {
8622         /// The peer took some action which made us think they were useless. Disconnect them.
8623         DisconnectPeer {
8624                 /// An error message which we should make an effort to send before we disconnect.
8625                 ///
8626                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
8627                 msg: crate::lightning::ln::msgs::ErrorMessage,
8628         },
8629         /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
8630         DisconnectPeerWithWarning {
8631                 /// A warning message which we should make an effort to send before we disconnect.
8632                 msg: crate::lightning::ln::msgs::WarningMessage,
8633         },
8634         /// The peer did something harmless that we weren't able to process, just log and ignore
8635         IgnoreError,
8636         /// The peer did something harmless that we weren't able to meaningfully process.
8637         /// If the error is logged, log it at the given level.
8638         IgnoreAndLog(
8639                 crate::lightning::util::logger::Level),
8640         /// The peer provided us with a gossip message which we'd already seen. In most cases this
8641         /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
8642         /// our own channel announcements.
8643         IgnoreDuplicateGossip,
8644         /// The peer did something incorrect. Tell them.
8645         SendErrorMessage {
8646                 /// The message to send.
8647                 msg: crate::lightning::ln::msgs::ErrorMessage,
8648         },
8649         /// The peer did something incorrect. Tell them without closing any channels.
8650         SendWarningMessage {
8651                 /// The message to send.
8652                 msg: crate::lightning::ln::msgs::WarningMessage,
8653                 /// The peer may have done something harmless that we weren't able to meaningfully process,
8654                 /// though we should still tell them about it.
8655                 /// If this event is logged, log it at the given level.
8656                 log_level: crate::lightning::util::logger::Level,
8657         },
8658 }
8659 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
8660 pub(crate) type nativeErrorAction = ErrorActionImport;
8661
8662 impl ErrorAction {
8663         #[allow(unused)]
8664         pub(crate) fn to_native(&self) -> nativeErrorAction {
8665                 match self {
8666                         ErrorAction::DisconnectPeer {ref msg, } => {
8667                                 let mut msg_nonref = Clone::clone(msg);
8668                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
8669                                 nativeErrorAction::DisconnectPeer {
8670                                         msg: local_msg_nonref,
8671                                 }
8672                         },
8673                         ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8674                                 let mut msg_nonref = Clone::clone(msg);
8675                                 nativeErrorAction::DisconnectPeerWithWarning {
8676                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8677                                 }
8678                         },
8679                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8680                         ErrorAction::IgnoreAndLog (ref a, ) => {
8681                                 let mut a_nonref = Clone::clone(a);
8682                                 nativeErrorAction::IgnoreAndLog (
8683                                         a_nonref.into_native(),
8684                                 )
8685                         },
8686                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8687                         ErrorAction::SendErrorMessage {ref msg, } => {
8688                                 let mut msg_nonref = Clone::clone(msg);
8689                                 nativeErrorAction::SendErrorMessage {
8690                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8691                                 }
8692                         },
8693                         ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8694                                 let mut msg_nonref = Clone::clone(msg);
8695                                 let mut log_level_nonref = Clone::clone(log_level);
8696                                 nativeErrorAction::SendWarningMessage {
8697                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8698                                         log_level: log_level_nonref.into_native(),
8699                                 }
8700                         },
8701                 }
8702         }
8703         #[allow(unused)]
8704         pub(crate) fn into_native(self) -> nativeErrorAction {
8705                 match self {
8706                         ErrorAction::DisconnectPeer {mut msg, } => {
8707                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
8708                                 nativeErrorAction::DisconnectPeer {
8709                                         msg: local_msg,
8710                                 }
8711                         },
8712                         ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8713                                 nativeErrorAction::DisconnectPeerWithWarning {
8714                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
8715                                 }
8716                         },
8717                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8718                         ErrorAction::IgnoreAndLog (mut a, ) => {
8719                                 nativeErrorAction::IgnoreAndLog (
8720                                         a.into_native(),
8721                                 )
8722                         },
8723                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8724                         ErrorAction::SendErrorMessage {mut msg, } => {
8725                                 nativeErrorAction::SendErrorMessage {
8726                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
8727                                 }
8728                         },
8729                         ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8730                                 nativeErrorAction::SendWarningMessage {
8731                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
8732                                         log_level: log_level.into_native(),
8733                                 }
8734                         },
8735                 }
8736         }
8737         #[allow(unused)]
8738         pub(crate) fn from_native(native: &ErrorActionImport) -> Self {
8739                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeErrorAction) };
8740                 match native {
8741                         nativeErrorAction::DisconnectPeer {ref msg, } => {
8742                                 let mut msg_nonref = Clone::clone(msg);
8743                                 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 };
8744                                 ErrorAction::DisconnectPeer {
8745                                         msg: local_msg_nonref,
8746                                 }
8747                         },
8748                         nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8749                                 let mut msg_nonref = Clone::clone(msg);
8750                                 ErrorAction::DisconnectPeerWithWarning {
8751                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8752                                 }
8753                         },
8754                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8755                         nativeErrorAction::IgnoreAndLog (ref a, ) => {
8756                                 let mut a_nonref = Clone::clone(a);
8757                                 ErrorAction::IgnoreAndLog (
8758                                         crate::lightning::util::logger::Level::native_into(a_nonref),
8759                                 )
8760                         },
8761                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8762                         nativeErrorAction::SendErrorMessage {ref msg, } => {
8763                                 let mut msg_nonref = Clone::clone(msg);
8764                                 ErrorAction::SendErrorMessage {
8765                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8766                                 }
8767                         },
8768                         nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8769                                 let mut msg_nonref = Clone::clone(msg);
8770                                 let mut log_level_nonref = Clone::clone(log_level);
8771                                 ErrorAction::SendWarningMessage {
8772                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8773                                         log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
8774                                 }
8775                         },
8776                 }
8777         }
8778         #[allow(unused)]
8779         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
8780                 match native {
8781                         nativeErrorAction::DisconnectPeer {mut msg, } => {
8782                                 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 };
8783                                 ErrorAction::DisconnectPeer {
8784                                         msg: local_msg,
8785                                 }
8786                         },
8787                         nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8788                                 ErrorAction::DisconnectPeerWithWarning {
8789                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8790                                 }
8791                         },
8792                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8793                         nativeErrorAction::IgnoreAndLog (mut a, ) => {
8794                                 ErrorAction::IgnoreAndLog (
8795                                         crate::lightning::util::logger::Level::native_into(a),
8796                                 )
8797                         },
8798                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8799                         nativeErrorAction::SendErrorMessage {mut msg, } => {
8800                                 ErrorAction::SendErrorMessage {
8801                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8802                                 }
8803                         },
8804                         nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8805                                 ErrorAction::SendWarningMessage {
8806                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8807                                         log_level: crate::lightning::util::logger::Level::native_into(log_level),
8808                                 }
8809                         },
8810                 }
8811         }
8812 }
8813 /// Frees any resources used by the ErrorAction
8814 #[no_mangle]
8815 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
8816 /// Creates a copy of the ErrorAction
8817 #[no_mangle]
8818 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
8819         orig.clone()
8820 }
8821 #[allow(unused)]
8822 /// Used only if an object of this type is returned as a trait impl by a method
8823 pub(crate) extern "C" fn ErrorAction_clone_void(this_ptr: *const c_void) -> *mut c_void {
8824         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ErrorAction)).clone() })) as *mut c_void
8825 }
8826 #[allow(unused)]
8827 /// Used only if an object of this type is returned as a trait impl by a method
8828 pub(crate) extern "C" fn ErrorAction_free_void(this_ptr: *mut c_void) {
8829         let _ = unsafe { Box::from_raw(this_ptr as *mut ErrorAction) };
8830 }
8831 #[no_mangle]
8832 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
8833 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8834         ErrorAction::DisconnectPeer {
8835                 msg,
8836         }
8837 }
8838 #[no_mangle]
8839 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
8840 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
8841         ErrorAction::DisconnectPeerWithWarning {
8842                 msg,
8843         }
8844 }
8845 #[no_mangle]
8846 /// Utility method to constructs a new IgnoreError-variant ErrorAction
8847 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
8848         ErrorAction::IgnoreError}
8849 #[no_mangle]
8850 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
8851 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
8852         ErrorAction::IgnoreAndLog(a, )
8853 }
8854 #[no_mangle]
8855 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
8856 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
8857         ErrorAction::IgnoreDuplicateGossip}
8858 #[no_mangle]
8859 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
8860 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8861         ErrorAction::SendErrorMessage {
8862                 msg,
8863         }
8864 }
8865 #[no_mangle]
8866 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
8867 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
8868         ErrorAction::SendWarningMessage {
8869                 msg,
8870                 log_level,
8871         }
8872 }
8873 /// Get a string which allows debug introspection of a ErrorAction object
8874 pub extern "C" fn ErrorAction_debug_str_void(o: *const c_void) -> Str {
8875         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorAction }).into()}
8876 /// Generates a non-cryptographic 64-bit hash of the ErrorAction.
8877 #[no_mangle]
8878 pub extern "C" fn ErrorAction_hash(o: &ErrorAction) -> u64 {
8879         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8880         #[allow(deprecated)]
8881         let mut hasher = core::hash::SipHasher::new();
8882         core::hash::Hash::hash(&o.to_native(), &mut hasher);
8883         core::hash::Hasher::finish(&hasher)
8884 }
8885
8886 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
8887 pub(crate) type nativeLightningError = nativeLightningErrorImport;
8888
8889 /// An Err type for failure to process messages.
8890 #[must_use]
8891 #[repr(C)]
8892 pub struct LightningError {
8893         /// A pointer to the opaque Rust object.
8894
8895         /// Nearly everywhere, inner must be non-null, however in places where
8896         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8897         pub inner: *mut nativeLightningError,
8898         /// Indicates that this is the only struct which contains the same pointer.
8899
8900         /// Rust functions which take ownership of an object provided via an argument require
8901         /// this to be true and invalidate the object pointed to by inner.
8902         pub is_owned: bool,
8903 }
8904
8905 impl Drop for LightningError {
8906         fn drop(&mut self) {
8907                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
8908                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8909                 }
8910         }
8911 }
8912 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
8913 #[no_mangle]
8914 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
8915 #[allow(unused)]
8916 /// Used only if an object of this type is returned as a trait impl by a method
8917 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
8918         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
8919 }
8920 #[allow(unused)]
8921 impl LightningError {
8922         pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
8923                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8924         }
8925         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
8926                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8927         }
8928         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8929         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
8930                 assert!(self.is_owned);
8931                 let ret = ObjOps::untweak_ptr(self.inner);
8932                 self.inner = core::ptr::null_mut();
8933                 ret
8934         }
8935 }
8936 /// A human-readable message describing the error
8937 #[no_mangle]
8938 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
8939         let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
8940         inner_val.as_str().into()
8941 }
8942 /// A human-readable message describing the error
8943 #[no_mangle]
8944 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
8945         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
8946 }
8947 /// The action which should be taken against the offending peer.
8948 #[no_mangle]
8949 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
8950         let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
8951         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
8952 }
8953 /// The action which should be taken against the offending peer.
8954 #[no_mangle]
8955 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
8956         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
8957 }
8958 /// Constructs a new LightningError given each field
8959 #[must_use]
8960 #[no_mangle]
8961 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
8962         LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
8963                 err: err_arg.into_string(),
8964                 action: action_arg.into_native(),
8965         }), is_owned: true }
8966 }
8967 impl Clone for LightningError {
8968         fn clone(&self) -> Self {
8969                 Self {
8970                         inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
8971                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8972                         is_owned: true,
8973                 }
8974         }
8975 }
8976 #[allow(unused)]
8977 /// Used only if an object of this type is returned as a trait impl by a method
8978 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
8979         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLightningError)).clone() })) as *mut c_void
8980 }
8981 #[no_mangle]
8982 /// Creates a copy of the LightningError
8983 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
8984         orig.clone()
8985 }
8986 /// Get a string which allows debug introspection of a LightningError object
8987 pub extern "C" fn LightningError_debug_str_void(o: *const c_void) -> Str {
8988         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::LightningError }).into()}
8989
8990 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
8991 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
8992
8993 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
8994 /// transaction updates if they were pending.
8995 #[must_use]
8996 #[repr(C)]
8997 pub struct CommitmentUpdate {
8998         /// A pointer to the opaque Rust object.
8999
9000         /// Nearly everywhere, inner must be non-null, however in places where
9001         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9002         pub inner: *mut nativeCommitmentUpdate,
9003         /// Indicates that this is the only struct which contains the same pointer.
9004
9005         /// Rust functions which take ownership of an object provided via an argument require
9006         /// this to be true and invalidate the object pointed to by inner.
9007         pub is_owned: bool,
9008 }
9009
9010 impl Drop for CommitmentUpdate {
9011         fn drop(&mut self) {
9012                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
9013                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9014                 }
9015         }
9016 }
9017 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
9018 #[no_mangle]
9019 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
9020 #[allow(unused)]
9021 /// Used only if an object of this type is returned as a trait impl by a method
9022 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
9023         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
9024 }
9025 #[allow(unused)]
9026 impl CommitmentUpdate {
9027         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
9028                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9029         }
9030         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
9031                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9032         }
9033         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9034         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
9035                 assert!(self.is_owned);
9036                 let ret = ObjOps::untweak_ptr(self.inner);
9037                 self.inner = core::ptr::null_mut();
9038                 ret
9039         }
9040 }
9041 /// `update_add_htlc` messages which should be sent
9042 #[no_mangle]
9043 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
9044         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
9045         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 } }); };
9046         local_inner_val.into()
9047 }
9048 /// `update_add_htlc` messages which should be sent
9049 #[no_mangle]
9050 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
9051         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9052         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
9053 }
9054 /// `update_fulfill_htlc` messages which should be sent
9055 #[no_mangle]
9056 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
9057         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
9058         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 } }); };
9059         local_inner_val.into()
9060 }
9061 /// `update_fulfill_htlc` messages which should be sent
9062 #[no_mangle]
9063 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
9064         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9065         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
9066 }
9067 /// `update_fail_htlc` messages which should be sent
9068 #[no_mangle]
9069 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
9070         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
9071         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 } }); };
9072         local_inner_val.into()
9073 }
9074 /// `update_fail_htlc` messages which should be sent
9075 #[no_mangle]
9076 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
9077         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9078         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
9079 }
9080 /// `update_fail_malformed_htlc` messages which should be sent
9081 #[no_mangle]
9082 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
9083         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
9084         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 } }); };
9085         local_inner_val.into()
9086 }
9087 /// `update_fail_malformed_htlc` messages which should be sent
9088 #[no_mangle]
9089 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
9090         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9091         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
9092 }
9093 /// An `update_fee` message which should be sent
9094 ///
9095 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9096 #[no_mangle]
9097 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
9098         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
9099         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 };
9100         local_inner_val
9101 }
9102 /// An `update_fee` message which should be sent
9103 ///
9104 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
9105 #[no_mangle]
9106 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
9107         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
9108         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
9109 }
9110 /// A `commitment_signed` message which should be sent
9111 #[no_mangle]
9112 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
9113         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
9114         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 }
9115 }
9116 /// A `commitment_signed` message which should be sent
9117 #[no_mangle]
9118 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
9119         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
9120 }
9121 /// Constructs a new CommitmentUpdate given each field
9122 ///
9123 /// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
9124 #[must_use]
9125 #[no_mangle]
9126 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 {
9127         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()) } }); };
9128         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()) } }); };
9129         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()) } }); };
9130         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()) } }); };
9131         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()) } }) };
9132         CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
9133                 update_add_htlcs: local_update_add_htlcs_arg,
9134                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
9135                 update_fail_htlcs: local_update_fail_htlcs_arg,
9136                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
9137                 update_fee: local_update_fee_arg,
9138                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
9139         }), is_owned: true }
9140 }
9141 impl Clone for CommitmentUpdate {
9142         fn clone(&self) -> Self {
9143                 Self {
9144                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
9145                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9146                         is_owned: true,
9147                 }
9148         }
9149 }
9150 #[allow(unused)]
9151 /// Used only if an object of this type is returned as a trait impl by a method
9152 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
9153         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentUpdate)).clone() })) as *mut c_void
9154 }
9155 #[no_mangle]
9156 /// Creates a copy of the CommitmentUpdate
9157 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
9158         orig.clone()
9159 }
9160 /// Get a string which allows debug introspection of a CommitmentUpdate object
9161 pub extern "C" fn CommitmentUpdate_debug_str_void(o: *const c_void) -> Str {
9162         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentUpdate }).into()}
9163 /// Generates a non-cryptographic 64-bit hash of the CommitmentUpdate.
9164 #[no_mangle]
9165 pub extern "C" fn CommitmentUpdate_hash(o: &CommitmentUpdate) -> u64 {
9166         if o.inner.is_null() { return 0; }
9167         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
9168         #[allow(deprecated)]
9169         let mut hasher = core::hash::SipHasher::new();
9170         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
9171         core::hash::Hasher::finish(&hasher)
9172 }
9173 /// Checks if two CommitmentUpdates contain equal inner contents.
9174 /// This ignores pointers and is_owned flags and looks at the values in fields.
9175 /// Two objects with NULL inner values will be considered "equal" here.
9176 #[no_mangle]
9177 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
9178         if a.inner == b.inner { return true; }
9179         if a.inner.is_null() || b.inner.is_null() { return false; }
9180         if a.get_native_ref() == b.get_native_ref() { true } else { false }
9181 }
9182 /// A trait to describe an object which can receive channel messages.
9183 ///
9184 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
9185 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
9186 #[repr(C)]
9187 pub struct ChannelMessageHandler {
9188         /// An opaque pointer which is passed to your function implementations as an argument.
9189         /// This has no meaning in the LDK, and can be NULL or any other value.
9190         pub this_arg: *mut c_void,
9191         /// Handle an incoming `open_channel` message from the given peer.
9192         pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel),
9193         /// Handle an incoming `open_channel2` message from the given peer.
9194         pub handle_open_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2),
9195         /// Handle an incoming `accept_channel` message from the given peer.
9196         pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel),
9197         /// Handle an incoming `accept_channel2` message from the given peer.
9198         pub handle_accept_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2),
9199         /// Handle an incoming `funding_created` message from the given peer.
9200         pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated),
9201         /// Handle an incoming `funding_signed` message from the given peer.
9202         pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned),
9203         /// Handle an incoming `channel_ready` message from the given peer.
9204         pub handle_channel_ready: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady),
9205         /// Handle an incoming `shutdown` message from the given peer.
9206         pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
9207         /// Handle an incoming `closing_signed` message from the given peer.
9208         pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned),
9209         /// Handle an incoming `stfu` message from the given peer.
9210         pub handle_stfu: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Stfu),
9211         /// Handle an incoming `tx_add_input message` from the given peer.
9212         pub handle_tx_add_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput),
9213         /// Handle an incoming `tx_add_output` message from the given peer.
9214         pub handle_tx_add_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput),
9215         /// Handle an incoming `tx_remove_input` message from the given peer.
9216         pub handle_tx_remove_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput),
9217         /// Handle an incoming `tx_remove_output` message from the given peer.
9218         pub handle_tx_remove_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput),
9219         /// Handle an incoming `tx_complete message` from the given peer.
9220         pub handle_tx_complete: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete),
9221         /// Handle an incoming `tx_signatures` message from the given peer.
9222         pub handle_tx_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures),
9223         /// Handle an incoming `tx_init_rbf` message from the given peer.
9224         pub handle_tx_init_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf),
9225         /// Handle an incoming `tx_ack_rbf` message from the given peer.
9226         pub handle_tx_ack_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf),
9227         /// Handle an incoming `tx_abort message` from the given peer.
9228         pub handle_tx_abort: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort),
9229         /// Handle an incoming `update_add_htlc` message from the given peer.
9230         pub handle_update_add_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC),
9231         /// Handle an incoming `update_fulfill_htlc` message from the given peer.
9232         pub handle_update_fulfill_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC),
9233         /// Handle an incoming `update_fail_htlc` message from the given peer.
9234         pub handle_update_fail_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC),
9235         /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
9236         pub handle_update_fail_malformed_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC),
9237         /// Handle an incoming `commitment_signed` message from the given peer.
9238         pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned),
9239         /// Handle an incoming `revoke_and_ack` message from the given peer.
9240         pub handle_revoke_and_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK),
9241         /// Handle an incoming `update_fee` message from the given peer.
9242         pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee),
9243         /// Handle an incoming `announcement_signatures` message from the given peer.
9244         pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures),
9245         /// Indicates a connection to the peer failed/an existing connection was lost.
9246         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9247         /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
9248         ///
9249         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9250         /// with us. Implementors should be somewhat conservative about doing so, however, as other
9251         /// message handlers may still wish to communicate with this peer.
9252         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
9253         /// Handle an incoming `channel_reestablish` message from the given peer.
9254         pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish),
9255         /// Handle an incoming `channel_update` message from the given peer.
9256         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate),
9257         /// Handle an incoming `error` message from the given peer.
9258         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
9259         /// Gets the node feature flags which this handler itself supports. All available handlers are
9260         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9261         /// which are broadcasted in our [`NodeAnnouncement`] message.
9262         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9263         /// Gets the init feature flags which should be sent to the given peer. All available handlers
9264         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9265         /// which are sent in our [`Init`] message.
9266         ///
9267         /// Note that this method is called before [`Self::peer_connected`].
9268         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9269         /// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
9270         ///
9271         /// If it's `None`, then no particular network chain hash compatibility will be enforced when
9272         /// connecting to peers.
9273         pub get_chain_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ,
9274         /// Implementation of MessageSendEventsProvider for this object.
9275         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9276         /// Frees any resources associated with this object given its this_arg pointer.
9277         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9278         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9279 }
9280 unsafe impl Send for ChannelMessageHandler {}
9281 unsafe impl Sync for ChannelMessageHandler {}
9282 #[allow(unused)]
9283 pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
9284         ChannelMessageHandler {
9285                 this_arg: orig.this_arg,
9286                 handle_open_channel: Clone::clone(&orig.handle_open_channel),
9287                 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
9288                 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
9289                 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
9290                 handle_funding_created: Clone::clone(&orig.handle_funding_created),
9291                 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
9292                 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
9293                 handle_shutdown: Clone::clone(&orig.handle_shutdown),
9294                 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
9295                 handle_stfu: Clone::clone(&orig.handle_stfu),
9296                 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
9297                 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
9298                 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
9299                 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
9300                 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
9301                 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
9302                 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
9303                 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
9304                 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
9305                 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
9306                 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
9307                 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
9308                 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
9309                 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
9310                 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
9311                 handle_update_fee: Clone::clone(&orig.handle_update_fee),
9312                 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
9313                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9314                 peer_connected: Clone::clone(&orig.peer_connected),
9315                 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
9316                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9317                 handle_error: Clone::clone(&orig.handle_error),
9318                 provided_node_features: Clone::clone(&orig.provided_node_features),
9319                 provided_init_features: Clone::clone(&orig.provided_init_features),
9320                 get_chain_hashes: Clone::clone(&orig.get_chain_hashes),
9321                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9322                 free: Clone::clone(&orig.free),
9323         }
9324 }
9325 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
9326         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9327                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9328                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9329                 local_ret
9330         }
9331 }
9332
9333 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
9334 impl rustChannelMessageHandler for ChannelMessageHandler {
9335         fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
9336                 (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false })
9337         }
9338         fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
9339                 (self.handle_open_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannelV2<>) as *mut _) }, is_owned: false })
9340         }
9341         fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
9342                 (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false })
9343         }
9344         fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
9345                 (self.handle_accept_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannelV2<>) as *mut _) }, is_owned: false })
9346         }
9347         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
9348                 (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingCreated<>) as *mut _) }, is_owned: false })
9349         }
9350         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
9351                 (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingSigned<>) as *mut _) }, is_owned: false })
9352         }
9353         fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
9354                 (self.handle_channel_ready)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReady { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReady<>) as *mut _) }, is_owned: false })
9355         }
9356         fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
9357                 (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false })
9358         }
9359         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
9360                 (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ClosingSigned<>) as *mut _) }, is_owned: false })
9361         }
9362         fn handle_stfu(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Stfu) {
9363                 (self.handle_stfu)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Stfu { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Stfu<>) as *mut _) }, is_owned: false })
9364         }
9365         fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
9366                 (self.handle_tx_add_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddInput<>) as *mut _) }, is_owned: false })
9367         }
9368         fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
9369                 (self.handle_tx_add_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddOutput<>) as *mut _) }, is_owned: false })
9370         }
9371         fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
9372                 (self.handle_tx_remove_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveInput<>) as *mut _) }, is_owned: false })
9373         }
9374         fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
9375                 (self.handle_tx_remove_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveOutput<>) as *mut _) }, is_owned: false })
9376         }
9377         fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
9378                 (self.handle_tx_complete)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxComplete { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxComplete<>) as *mut _) }, is_owned: false })
9379         }
9380         fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
9381                 (self.handle_tx_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxSignatures<>) as *mut _) }, is_owned: false })
9382         }
9383         fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
9384                 (self.handle_tx_init_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxInitRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxInitRbf<>) as *mut _) }, is_owned: false })
9385         }
9386         fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
9387                 (self.handle_tx_ack_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAckRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAckRbf<>) as *mut _) }, is_owned: false })
9388         }
9389         fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
9390                 (self.handle_tx_abort)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAbort { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAbort<>) as *mut _) }, is_owned: false })
9391         }
9392         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
9393                 (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false })
9394         }
9395         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
9396                 (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false })
9397         }
9398         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
9399                 (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false })
9400         }
9401         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
9402                 (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false })
9403         }
9404         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
9405                 (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false })
9406         }
9407         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
9408                 (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::RevokeAndACK<>) as *mut _) }, is_owned: false })
9409         }
9410         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
9411                 (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFee<>) as *mut _) }, is_owned: false })
9412         }
9413         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
9414                 (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AnnouncementSignatures<>) as *mut _) }, is_owned: false })
9415         }
9416         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9417                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9418         }
9419         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9420                 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
9421                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
9422                 local_ret
9423         }
9424         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
9425                 (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReestablish<>) as *mut _) }, is_owned: false })
9426         }
9427         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
9428                 (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false })
9429         }
9430         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
9431                 (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false })
9432         }
9433         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9434                 let mut ret = (self.provided_node_features)(self.this_arg);
9435                 *unsafe { Box::from_raw(ret.take_inner()) }
9436         }
9437         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9438                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9439                 *unsafe { Box::from_raw(ret.take_inner()) }
9440         }
9441         fn get_chain_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
9442                 let mut ret = (self.get_chain_hashes)(self.this_arg);
9443                 let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { let mut local_ret_0 = Vec::new(); for mut item in { ret_opt.take() }.into_rust().drain(..) { local_ret_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_ret_0 }})} };
9444                 local_ret
9445         }
9446 }
9447
9448 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9449 // directly as a Deref trait in higher-level structs:
9450 impl core::ops::Deref for ChannelMessageHandler {
9451         type Target = Self;
9452         fn deref(&self) -> &Self {
9453                 self
9454         }
9455 }
9456 impl core::ops::DerefMut for ChannelMessageHandler {
9457         fn deref_mut(&mut self) -> &mut Self {
9458                 self
9459         }
9460 }
9461 /// Calls the free function if one is set
9462 #[no_mangle]
9463 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
9464 impl Drop for ChannelMessageHandler {
9465         fn drop(&mut self) {
9466                 if let Some(f) = self.free {
9467                         f(self.this_arg);
9468                 }
9469         }
9470 }
9471 /// A trait to describe an object which can receive routing messages.
9472 ///
9473 /// # Implementor DoS Warnings
9474 ///
9475 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
9476 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
9477 /// repeated disk I/O for queries accessing different parts of the network graph.
9478 #[repr(C)]
9479 pub struct RoutingMessageHandler {
9480         /// An opaque pointer which is passed to your function implementations as an argument.
9481         /// This has no meaning in the LDK, and can be NULL or any other value.
9482         pub this_arg: *mut c_void,
9483         /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
9484         /// `false` or returning an `Err` otherwise.
9485         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9486         /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
9487         /// or returning an `Err` otherwise.
9488         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9489         /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
9490         /// `false` or returning an `Err` otherwise.
9491         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9492         /// Gets channel announcements and updates required to dump our routing table to a remote node,
9493         /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
9494         /// for a single channel.
9495         pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
9496         /// Gets a node announcement required to dump our routing table to a remote node, starting at
9497         /// the node *after* the provided pubkey and including up to one announcement immediately
9498         /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
9499         /// If `None` is provided for `starting_point`, we start at the first node.
9500         ///
9501         /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
9502         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9503         pub get_next_node_announcement: extern "C" fn (this_arg: *const c_void, starting_point: crate::lightning::routing::gossip::NodeId) -> crate::lightning::ln::msgs::NodeAnnouncement,
9504         /// Called when a connection is established with a peer. This can be used to
9505         /// perform routing table synchronization using a strategy defined by the
9506         /// implementor.
9507         ///
9508         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9509         /// with us. Implementors should be somewhat conservative about doing so, however, as other
9510         /// message handlers may still wish to communicate with this peer.
9511         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
9512         /// Handles the reply of a query we initiated to learn about channels
9513         /// for a given range of blocks. We can expect to receive one or more
9514         /// replies to a single query.
9515         pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9516         /// Handles the reply of a query we initiated asking for routing gossip
9517         /// messages for a list of channels. We should receive this message when
9518         /// a node has completed its best effort to send us the pertaining routing
9519         /// gossip messages.
9520         pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9521         /// Handles when a peer asks us to send a list of `short_channel_id`s
9522         /// for the requested range of blocks.
9523         pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9524         /// Handles when a peer asks us to send routing gossip messages for a
9525         /// list of `short_channel_id`s.
9526         pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9527         /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
9528         /// pending some async action. While there is no guarantee of the rate of future messages, the
9529         /// caller should seek to reduce the rate of new gossip messages handled, especially
9530         /// [`ChannelAnnouncement`]s.
9531         pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
9532         /// Gets the node feature flags which this handler itself supports. All available handlers are
9533         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9534         /// which are broadcasted in our [`NodeAnnouncement`] message.
9535         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9536         /// Gets the init feature flags which should be sent to the given peer. All available handlers
9537         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9538         /// which are sent in our [`Init`] message.
9539         ///
9540         /// Note that this method is called before [`Self::peer_connected`].
9541         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9542         /// Implementation of MessageSendEventsProvider for this object.
9543         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9544         /// Frees any resources associated with this object given its this_arg pointer.
9545         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9546         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9547 }
9548 unsafe impl Send for RoutingMessageHandler {}
9549 unsafe impl Sync for RoutingMessageHandler {}
9550 #[allow(unused)]
9551 pub(crate) fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
9552         RoutingMessageHandler {
9553                 this_arg: orig.this_arg,
9554                 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
9555                 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
9556                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9557                 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
9558                 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
9559                 peer_connected: Clone::clone(&orig.peer_connected),
9560                 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
9561                 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
9562                 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
9563                 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
9564                 processing_queue_high: Clone::clone(&orig.processing_queue_high),
9565                 provided_node_features: Clone::clone(&orig.provided_node_features),
9566                 provided_init_features: Clone::clone(&orig.provided_init_features),
9567                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9568                 free: Clone::clone(&orig.free),
9569         }
9570 }
9571 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
9572         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9573                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9574                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9575                 local_ret
9576         }
9577 }
9578
9579 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
9580 impl rustRoutingMessageHandler for RoutingMessageHandler {
9581         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9582                 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _) }, is_owned: false });
9583                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9584                 local_ret
9585         }
9586         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9587                 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelAnnouncement<>) as *mut _) }, is_owned: false });
9588                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9589                 local_ret
9590         }
9591         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
9592                 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false });
9593                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9594                 local_ret
9595         }
9596         fn get_next_channel_announcement(&self, mut starting_point: u64) -> Option<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
9597                 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
9598                 let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = ret.take().to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }) } else { None };
9599                 local_ret
9600         }
9601         fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
9602                 let mut local_starting_point = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if starting_point.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (starting_point.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false };
9603                 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
9604                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9605                 local_ret
9606         }
9607         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9608                 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
9609                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
9610                 local_ret
9611         }
9612         fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9613                 let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true });
9614                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9615                 local_ret
9616         }
9617         fn handle_reply_short_channel_ids_end(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> {
9618                 let mut ret = (self.handle_reply_short_channel_ids_end)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(msg), is_owned: true });
9619                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9620                 local_ret
9621         }
9622         fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9623                 let mut ret = (self.handle_query_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true });
9624                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9625                 local_ret
9626         }
9627         fn handle_query_short_channel_ids(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
9628                 let mut ret = (self.handle_query_short_channel_ids)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true });
9629                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9630                 local_ret
9631         }
9632         fn processing_queue_high(&self) -> bool {
9633                 let mut ret = (self.processing_queue_high)(self.this_arg);
9634                 ret
9635         }
9636         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9637                 let mut ret = (self.provided_node_features)(self.this_arg);
9638                 *unsafe { Box::from_raw(ret.take_inner()) }
9639         }
9640         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9641                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9642                 *unsafe { Box::from_raw(ret.take_inner()) }
9643         }
9644 }
9645
9646 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9647 // directly as a Deref trait in higher-level structs:
9648 impl core::ops::Deref for RoutingMessageHandler {
9649         type Target = Self;
9650         fn deref(&self) -> &Self {
9651                 self
9652         }
9653 }
9654 impl core::ops::DerefMut for RoutingMessageHandler {
9655         fn deref_mut(&mut self) -> &mut Self {
9656                 self
9657         }
9658 }
9659 /// Calls the free function if one is set
9660 #[no_mangle]
9661 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
9662 impl Drop for RoutingMessageHandler {
9663         fn drop(&mut self) {
9664                 if let Some(f) = self.free {
9665                         f(self.this_arg);
9666                 }
9667         }
9668 }
9669 /// A handler for received [`OnionMessage`]s and for providing generated ones to send.
9670 #[repr(C)]
9671 pub struct OnionMessageHandler {
9672         /// An opaque pointer which is passed to your function implementations as an argument.
9673         /// This has no meaning in the LDK, and can be NULL or any other value.
9674         pub this_arg: *mut c_void,
9675         /// Because much of the lightning network does not yet support forwarding onion messages, we
9676         /// may need to directly connect to a node which will forward a message for us. In such a case,
9677         /// this method will return the set of nodes which need connection by node_id and the
9678         /// corresponding socket addresses where they may accept incoming connections.
9679         ///
9680         /// Thus, this method should be polled regularly to detect messages await such a direct
9681         /// connection.
9682         pub get_and_clear_connections_needed: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ,
9683         /// Handle an incoming `onion_message` message from the given peer.
9684         pub handle_onion_message: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage),
9685         /// Returns the next pending onion message for the peer with the given node id.
9686         ///
9687         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9688         pub next_onion_message_for_peer: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage,
9689         /// Called when a connection is established with a peer. Can be used to track which peers
9690         /// advertise onion message support and are online.
9691         ///
9692         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9693         /// with us. Implementors should be somewhat conservative about doing so, however, as other
9694         /// message handlers may still wish to communicate with this peer.
9695         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
9696         /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
9697         /// drop and refuse to forward onion messages to this peer.
9698         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9699         /// Performs actions that should happen roughly every ten seconds after startup. Allows handlers
9700         /// to drop any buffered onion messages intended for prospective peers.
9701         pub timer_tick_occurred: extern "C" fn (this_arg: *const c_void),
9702         /// Gets the node feature flags which this handler itself supports. All available handlers are
9703         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9704         /// which are broadcasted in our [`NodeAnnouncement`] message.
9705         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9706         /// Gets the init feature flags which should be sent to the given peer. All available handlers
9707         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9708         /// which are sent in our [`Init`] message.
9709         ///
9710         /// Note that this method is called before [`Self::peer_connected`].
9711         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9712         /// Frees any resources associated with this object given its this_arg pointer.
9713         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9714         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9715 }
9716 unsafe impl Send for OnionMessageHandler {}
9717 unsafe impl Sync for OnionMessageHandler {}
9718 #[allow(unused)]
9719 pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
9720         OnionMessageHandler {
9721                 this_arg: orig.this_arg,
9722                 get_and_clear_connections_needed: Clone::clone(&orig.get_and_clear_connections_needed),
9723                 handle_onion_message: Clone::clone(&orig.handle_onion_message),
9724                 next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
9725                 peer_connected: Clone::clone(&orig.peer_connected),
9726                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9727                 timer_tick_occurred: Clone::clone(&orig.timer_tick_occurred),
9728                 provided_node_features: Clone::clone(&orig.provided_node_features),
9729                 provided_init_features: Clone::clone(&orig.provided_init_features),
9730                 free: Clone::clone(&orig.free),
9731         }
9732 }
9733
9734 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
9735 impl rustOnionMessageHandler for OnionMessageHandler {
9736         fn get_and_clear_connections_needed(&self) -> Vec<(bitcoin::secp256k1::PublicKey, Vec<lightning::ln::msgs::SocketAddress>)> {
9737                 let mut ret = (self.get_and_clear_connections_needed)(self.this_arg);
9738                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_native() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }); };
9739                 local_ret
9740         }
9741         fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
9742                 (self.handle_onion_message)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id), &crate::lightning::ln::msgs::OnionMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OnionMessage<>) as *mut _) }, is_owned: false })
9743         }
9744         fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
9745                 let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
9746                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9747                 local_ret
9748         }
9749         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9750                 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
9751                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
9752                 local_ret
9753         }
9754         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9755                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9756         }
9757         fn timer_tick_occurred(&self) {
9758                 (self.timer_tick_occurred)(self.this_arg)
9759         }
9760         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9761                 let mut ret = (self.provided_node_features)(self.this_arg);
9762                 *unsafe { Box::from_raw(ret.take_inner()) }
9763         }
9764         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9765                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9766                 *unsafe { Box::from_raw(ret.take_inner()) }
9767         }
9768 }
9769
9770 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9771 // directly as a Deref trait in higher-level structs:
9772 impl core::ops::Deref for OnionMessageHandler {
9773         type Target = Self;
9774         fn deref(&self) -> &Self {
9775                 self
9776         }
9777 }
9778 impl core::ops::DerefMut for OnionMessageHandler {
9779         fn deref_mut(&mut self) -> &mut Self {
9780                 self
9781         }
9782 }
9783 /// Calls the free function if one is set
9784 #[no_mangle]
9785 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
9786 impl Drop for OnionMessageHandler {
9787         fn drop(&mut self) {
9788                 if let Some(f) = self.free {
9789                         f(self.this_arg);
9790                 }
9791         }
9792 }
9793
9794 use lightning::ln::msgs::FinalOnionHopData as nativeFinalOnionHopDataImport;
9795 pub(crate) type nativeFinalOnionHopData = nativeFinalOnionHopDataImport;
9796
9797 /// Information communicated in the onion to the recipient for multi-part tracking and proof that
9798 /// the payment is associated with an invoice.
9799 #[must_use]
9800 #[repr(C)]
9801 pub struct FinalOnionHopData {
9802         /// A pointer to the opaque Rust object.
9803
9804         /// Nearly everywhere, inner must be non-null, however in places where
9805         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9806         pub inner: *mut nativeFinalOnionHopData,
9807         /// Indicates that this is the only struct which contains the same pointer.
9808
9809         /// Rust functions which take ownership of an object provided via an argument require
9810         /// this to be true and invalidate the object pointed to by inner.
9811         pub is_owned: bool,
9812 }
9813
9814 impl Drop for FinalOnionHopData {
9815         fn drop(&mut self) {
9816                 if self.is_owned && !<*mut nativeFinalOnionHopData>::is_null(self.inner) {
9817                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9818                 }
9819         }
9820 }
9821 /// Frees any resources used by the FinalOnionHopData, if is_owned is set and inner is non-NULL.
9822 #[no_mangle]
9823 pub extern "C" fn FinalOnionHopData_free(this_obj: FinalOnionHopData) { }
9824 #[allow(unused)]
9825 /// Used only if an object of this type is returned as a trait impl by a method
9826 pub(crate) extern "C" fn FinalOnionHopData_free_void(this_ptr: *mut c_void) {
9827         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFinalOnionHopData) };
9828 }
9829 #[allow(unused)]
9830 impl FinalOnionHopData {
9831         pub(crate) fn get_native_ref(&self) -> &'static nativeFinalOnionHopData {
9832                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9833         }
9834         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFinalOnionHopData {
9835                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9836         }
9837         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9838         pub(crate) fn take_inner(mut self) -> *mut nativeFinalOnionHopData {
9839                 assert!(self.is_owned);
9840                 let ret = ObjOps::untweak_ptr(self.inner);
9841                 self.inner = core::ptr::null_mut();
9842                 ret
9843         }
9844 }
9845 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9846 /// Because it is generated by the recipient and included in the invoice, it also provides
9847 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9848 #[no_mangle]
9849 pub extern "C" fn FinalOnionHopData_get_payment_secret(this_ptr: &FinalOnionHopData) -> *const [u8; 32] {
9850         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret;
9851         &inner_val.0
9852 }
9853 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9854 /// Because it is generated by the recipient and included in the invoice, it also provides
9855 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9856 #[no_mangle]
9857 pub extern "C" fn FinalOnionHopData_set_payment_secret(this_ptr: &mut FinalOnionHopData, mut val: crate::c_types::ThirtyTwoBytes) {
9858         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::types::PaymentSecret(val.data);
9859 }
9860 /// The intended total amount that this payment is for.
9861 ///
9862 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9863 #[no_mangle]
9864 pub extern "C" fn FinalOnionHopData_get_total_msat(this_ptr: &FinalOnionHopData) -> u64 {
9865         let mut inner_val = &mut this_ptr.get_native_mut_ref().total_msat;
9866         *inner_val
9867 }
9868 /// The intended total amount that this payment is for.
9869 ///
9870 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9871 #[no_mangle]
9872 pub extern "C" fn FinalOnionHopData_set_total_msat(this_ptr: &mut FinalOnionHopData, mut val: u64) {
9873         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.total_msat = val;
9874 }
9875 /// Constructs a new FinalOnionHopData given each field
9876 #[must_use]
9877 #[no_mangle]
9878 pub extern "C" fn FinalOnionHopData_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut total_msat_arg: u64) -> FinalOnionHopData {
9879         FinalOnionHopData { inner: ObjOps::heap_alloc(nativeFinalOnionHopData {
9880                 payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret_arg.data),
9881                 total_msat: total_msat_arg,
9882         }), is_owned: true }
9883 }
9884 impl Clone for FinalOnionHopData {
9885         fn clone(&self) -> Self {
9886                 Self {
9887                         inner: if <*mut nativeFinalOnionHopData>::is_null(self.inner) { core::ptr::null_mut() } else {
9888                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9889                         is_owned: true,
9890                 }
9891         }
9892 }
9893 #[allow(unused)]
9894 /// Used only if an object of this type is returned as a trait impl by a method
9895 pub(crate) extern "C" fn FinalOnionHopData_clone_void(this_ptr: *const c_void) -> *mut c_void {
9896         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFinalOnionHopData)).clone() })) as *mut c_void
9897 }
9898 #[no_mangle]
9899 /// Creates a copy of the FinalOnionHopData
9900 pub extern "C" fn FinalOnionHopData_clone(orig: &FinalOnionHopData) -> FinalOnionHopData {
9901         orig.clone()
9902 }
9903 mod fuzzy_internal_msgs {
9904
9905 use alloc::str::FromStr;
9906 use alloc::string::String;
9907 use core::ffi::c_void;
9908 use core::convert::Infallible;
9909 use bitcoin::hashes::Hash;
9910 use crate::c_types::*;
9911 #[cfg(feature="no-std")]
9912 use alloc::{vec::Vec, boxed::Box};
9913
9914 }
9915
9916 use lightning::ln::msgs::OnionPacket as nativeOnionPacketImport;
9917 pub(crate) type nativeOnionPacket = nativeOnionPacketImport;
9918
9919 /// BOLT 4 onion packet including hop data for the next peer.
9920 #[must_use]
9921 #[repr(C)]
9922 pub struct OnionPacket {
9923         /// A pointer to the opaque Rust object.
9924
9925         /// Nearly everywhere, inner must be non-null, however in places where
9926         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9927         pub inner: *mut nativeOnionPacket,
9928         /// Indicates that this is the only struct which contains the same pointer.
9929
9930         /// Rust functions which take ownership of an object provided via an argument require
9931         /// this to be true and invalidate the object pointed to by inner.
9932         pub is_owned: bool,
9933 }
9934
9935 impl Drop for OnionPacket {
9936         fn drop(&mut self) {
9937                 if self.is_owned && !<*mut nativeOnionPacket>::is_null(self.inner) {
9938                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9939                 }
9940         }
9941 }
9942 /// Frees any resources used by the OnionPacket, if is_owned is set and inner is non-NULL.
9943 #[no_mangle]
9944 pub extern "C" fn OnionPacket_free(this_obj: OnionPacket) { }
9945 #[allow(unused)]
9946 /// Used only if an object of this type is returned as a trait impl by a method
9947 pub(crate) extern "C" fn OnionPacket_free_void(this_ptr: *mut c_void) {
9948         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionPacket) };
9949 }
9950 #[allow(unused)]
9951 impl OnionPacket {
9952         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionPacket {
9953                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9954         }
9955         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionPacket {
9956                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9957         }
9958         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9959         pub(crate) fn take_inner(mut self) -> *mut nativeOnionPacket {
9960                 assert!(self.is_owned);
9961                 let ret = ObjOps::untweak_ptr(self.inner);
9962                 self.inner = core::ptr::null_mut();
9963                 ret
9964         }
9965 }
9966 /// BOLT 4 version number.
9967 #[no_mangle]
9968 pub extern "C" fn OnionPacket_get_version(this_ptr: &OnionPacket) -> u8 {
9969         let mut inner_val = &mut this_ptr.get_native_mut_ref().version;
9970         *inner_val
9971 }
9972 /// BOLT 4 version number.
9973 #[no_mangle]
9974 pub extern "C" fn OnionPacket_set_version(this_ptr: &mut OnionPacket, mut val: u8) {
9975         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val;
9976 }
9977 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
9978 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
9979 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
9980 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
9981 /// like.
9982 ///
9983 /// Returns a copy of the field.
9984 #[no_mangle]
9985 pub extern "C" fn OnionPacket_get_public_key(this_ptr: &OnionPacket) -> crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ {
9986         let mut inner_val = this_ptr.get_native_mut_ref().public_key.clone();
9987         let mut local_inner_val = match inner_val { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
9988         local_inner_val
9989 }
9990 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
9991 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
9992 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
9993 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
9994 /// like.
9995 #[no_mangle]
9996 pub extern "C" fn OnionPacket_set_public_key(this_ptr: &mut OnionPacket, mut val: crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ) {
9997         let mut local_val = match val.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut val.contents.result)) }).into_rust() }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut val.contents.err)) }).into_rust() })};
9998         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = local_val;
9999 }
10000 /// HMAC to verify the integrity of hop_data.
10001 #[no_mangle]
10002 pub extern "C" fn OnionPacket_get_hmac(this_ptr: &OnionPacket) -> *const [u8; 32] {
10003         let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac;
10004         inner_val
10005 }
10006 /// HMAC to verify the integrity of hop_data.
10007 #[no_mangle]
10008 pub extern "C" fn OnionPacket_set_hmac(this_ptr: &mut OnionPacket, mut val: crate::c_types::ThirtyTwoBytes) {
10009         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data;
10010 }
10011 impl Clone for OnionPacket {
10012         fn clone(&self) -> Self {
10013                 Self {
10014                         inner: if <*mut nativeOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else {
10015                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
10016                         is_owned: true,
10017                 }
10018         }
10019 }
10020 #[allow(unused)]
10021 /// Used only if an object of this type is returned as a trait impl by a method
10022 pub(crate) extern "C" fn OnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void {
10023         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionPacket)).clone() })) as *mut c_void
10024 }
10025 #[no_mangle]
10026 /// Creates a copy of the OnionPacket
10027 pub extern "C" fn OnionPacket_clone(orig: &OnionPacket) -> OnionPacket {
10028         orig.clone()
10029 }
10030 /// Generates a non-cryptographic 64-bit hash of the OnionPacket.
10031 #[no_mangle]
10032 pub extern "C" fn OnionPacket_hash(o: &OnionPacket) -> u64 {
10033         if o.inner.is_null() { return 0; }
10034         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
10035         #[allow(deprecated)]
10036         let mut hasher = core::hash::SipHasher::new();
10037         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
10038         core::hash::Hasher::finish(&hasher)
10039 }
10040 /// Checks if two OnionPackets contain equal inner contents.
10041 /// This ignores pointers and is_owned flags and looks at the values in fields.
10042 /// Two objects with NULL inner values will be considered "equal" here.
10043 #[no_mangle]
10044 pub extern "C" fn OnionPacket_eq(a: &OnionPacket, b: &OnionPacket) -> bool {
10045         if a.inner == b.inner { return true; }
10046         if a.inner.is_null() || b.inner.is_null() { return false; }
10047         if a.get_native_ref() == b.get_native_ref() { true } else { false }
10048 }
10049 /// Get a string which allows debug introspection of a OnionPacket object
10050 pub extern "C" fn OnionPacket_debug_str_void(o: *const c_void) -> Str {
10051         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionPacket }).into()}
10052
10053 use lightning::ln::msgs::TrampolineOnionPacket as nativeTrampolineOnionPacketImport;
10054 pub(crate) type nativeTrampolineOnionPacket = nativeTrampolineOnionPacketImport;
10055
10056 /// BOLT 4 onion packet including hop data for the next peer.
10057 #[must_use]
10058 #[repr(C)]
10059 pub struct TrampolineOnionPacket {
10060         /// A pointer to the opaque Rust object.
10061
10062         /// Nearly everywhere, inner must be non-null, however in places where
10063         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
10064         pub inner: *mut nativeTrampolineOnionPacket,
10065         /// Indicates that this is the only struct which contains the same pointer.
10066
10067         /// Rust functions which take ownership of an object provided via an argument require
10068         /// this to be true and invalidate the object pointed to by inner.
10069         pub is_owned: bool,
10070 }
10071
10072 impl Drop for TrampolineOnionPacket {
10073         fn drop(&mut self) {
10074                 if self.is_owned && !<*mut nativeTrampolineOnionPacket>::is_null(self.inner) {
10075                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
10076                 }
10077         }
10078 }
10079 /// Frees any resources used by the TrampolineOnionPacket, if is_owned is set and inner is non-NULL.
10080 #[no_mangle]
10081 pub extern "C" fn TrampolineOnionPacket_free(this_obj: TrampolineOnionPacket) { }
10082 #[allow(unused)]
10083 /// Used only if an object of this type is returned as a trait impl by a method
10084 pub(crate) extern "C" fn TrampolineOnionPacket_free_void(this_ptr: *mut c_void) {
10085         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTrampolineOnionPacket) };
10086 }
10087 #[allow(unused)]
10088 impl TrampolineOnionPacket {
10089         pub(crate) fn get_native_ref(&self) -> &'static nativeTrampolineOnionPacket {
10090                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
10091         }
10092         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTrampolineOnionPacket {
10093                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
10094         }
10095         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
10096         pub(crate) fn take_inner(mut self) -> *mut nativeTrampolineOnionPacket {
10097                 assert!(self.is_owned);
10098                 let ret = ObjOps::untweak_ptr(self.inner);
10099                 self.inner = core::ptr::null_mut();
10100                 ret
10101         }
10102 }
10103 /// Bolt 04 version number
10104 #[no_mangle]
10105 pub extern "C" fn TrampolineOnionPacket_get_version(this_ptr: &TrampolineOnionPacket) -> u8 {
10106         let mut inner_val = &mut this_ptr.get_native_mut_ref().version;
10107         *inner_val
10108 }
10109 /// Bolt 04 version number
10110 #[no_mangle]
10111 pub extern "C" fn TrampolineOnionPacket_set_version(this_ptr: &mut TrampolineOnionPacket, mut val: u8) {
10112         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val;
10113 }
10114 /// A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
10115 #[no_mangle]
10116 pub extern "C" fn TrampolineOnionPacket_get_public_key(this_ptr: &TrampolineOnionPacket) -> crate::c_types::PublicKey {
10117         let mut inner_val = &mut this_ptr.get_native_mut_ref().public_key;
10118         crate::c_types::PublicKey::from_rust(&inner_val)
10119 }
10120 /// A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
10121 #[no_mangle]
10122 pub extern "C" fn TrampolineOnionPacket_set_public_key(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::PublicKey) {
10123         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = val.into_rust();
10124 }
10125 /// Encrypted payload for the next hop
10126 ///
10127 /// Returns a copy of the field.
10128 #[no_mangle]
10129 pub extern "C" fn TrampolineOnionPacket_get_hop_data(this_ptr: &TrampolineOnionPacket) -> crate::c_types::derived::CVec_u8Z {
10130         let mut inner_val = this_ptr.get_native_mut_ref().hop_data.clone();
10131         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
10132         local_inner_val.into()
10133 }
10134 /// Encrypted payload for the next hop
10135 #[no_mangle]
10136 pub extern "C" fn TrampolineOnionPacket_set_hop_data(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::derived::CVec_u8Z) {
10137         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
10138         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hop_data = local_val;
10139 }
10140 /// HMAC to verify the integrity of hop_data
10141 #[no_mangle]
10142 pub extern "C" fn TrampolineOnionPacket_get_hmac(this_ptr: &TrampolineOnionPacket) -> *const [u8; 32] {
10143         let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac;
10144         inner_val
10145 }
10146 /// HMAC to verify the integrity of hop_data
10147 #[no_mangle]
10148 pub extern "C" fn TrampolineOnionPacket_set_hmac(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::ThirtyTwoBytes) {
10149         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data;
10150 }
10151 /// Constructs a new TrampolineOnionPacket given each field
10152 #[must_use]
10153 #[no_mangle]
10154 pub extern "C" fn TrampolineOnionPacket_new(mut version_arg: u8, mut public_key_arg: crate::c_types::PublicKey, mut hop_data_arg: crate::c_types::derived::CVec_u8Z, mut hmac_arg: crate::c_types::ThirtyTwoBytes) -> TrampolineOnionPacket {
10155         let mut local_hop_data_arg = Vec::new(); for mut item in hop_data_arg.into_rust().drain(..) { local_hop_data_arg.push( { item }); };
10156         TrampolineOnionPacket { inner: ObjOps::heap_alloc(nativeTrampolineOnionPacket {
10157                 version: version_arg,
10158                 public_key: public_key_arg.into_rust(),
10159                 hop_data: local_hop_data_arg,
10160                 hmac: hmac_arg.data,
10161         }), is_owned: true }
10162 }
10163 impl Clone for TrampolineOnionPacket {
10164         fn clone(&self) -> Self {
10165                 Self {
10166                         inner: if <*mut nativeTrampolineOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else {
10167                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
10168                         is_owned: true,
10169                 }
10170         }
10171 }
10172 #[allow(unused)]
10173 /// Used only if an object of this type is returned as a trait impl by a method
10174 pub(crate) extern "C" fn TrampolineOnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void {
10175         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTrampolineOnionPacket)).clone() })) as *mut c_void
10176 }
10177 #[no_mangle]
10178 /// Creates a copy of the TrampolineOnionPacket
10179 pub extern "C" fn TrampolineOnionPacket_clone(orig: &TrampolineOnionPacket) -> TrampolineOnionPacket {
10180         orig.clone()
10181 }
10182 /// Generates a non-cryptographic 64-bit hash of the TrampolineOnionPacket.
10183 #[no_mangle]
10184 pub extern "C" fn TrampolineOnionPacket_hash(o: &TrampolineOnionPacket) -> u64 {
10185         if o.inner.is_null() { return 0; }
10186         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
10187         #[allow(deprecated)]
10188         let mut hasher = core::hash::SipHasher::new();
10189         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
10190         core::hash::Hasher::finish(&hasher)
10191 }
10192 /// Checks if two TrampolineOnionPackets contain equal inner contents.
10193 /// This ignores pointers and is_owned flags and looks at the values in fields.
10194 /// Two objects with NULL inner values will be considered "equal" here.
10195 #[no_mangle]
10196 pub extern "C" fn TrampolineOnionPacket_eq(a: &TrampolineOnionPacket, b: &TrampolineOnionPacket) -> bool {
10197         if a.inner == b.inner { return true; }
10198         if a.inner.is_null() || b.inner.is_null() { return false; }
10199         if a.get_native_ref() == b.get_native_ref() { true } else { false }
10200 }
10201 #[no_mangle]
10202 /// Serialize the TrampolineOnionPacket object into a byte array which can be read by TrampolineOnionPacket_read
10203 pub extern "C" fn TrampolineOnionPacket_write(obj: &crate::lightning::ln::msgs::TrampolineOnionPacket) -> crate::c_types::derived::CVec_u8Z {
10204         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10205 }
10206 #[allow(unused)]
10207 pub(crate) extern "C" fn TrampolineOnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10208         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTrampolineOnionPacket) })
10209 }
10210 /// Get a string which allows debug introspection of a TrampolineOnionPacket object
10211 pub extern "C" fn TrampolineOnionPacket_debug_str_void(o: *const c_void) -> Str {
10212         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TrampolineOnionPacket }).into()}
10213 #[no_mangle]
10214 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
10215 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
10216         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10217 }
10218 #[allow(unused)]
10219 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10220         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
10221 }
10222 #[no_mangle]
10223 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
10224 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
10225         let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10226         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10227         local_res
10228 }
10229 #[no_mangle]
10230 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
10231 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
10232         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10233 }
10234 #[allow(unused)]
10235 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10236         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
10237 }
10238 #[no_mangle]
10239 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
10240 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
10241         let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10242         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10243         local_res
10244 }
10245 #[no_mangle]
10246 /// Serialize the Stfu object into a byte array which can be read by Stfu_read
10247 pub extern "C" fn Stfu_write(obj: &crate::lightning::ln::msgs::Stfu) -> crate::c_types::derived::CVec_u8Z {
10248         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10249 }
10250 #[allow(unused)]
10251 pub(crate) extern "C" fn Stfu_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10252         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStfu) })
10253 }
10254 #[no_mangle]
10255 /// Read a Stfu from a byte array, created by Stfu_write
10256 pub extern "C" fn Stfu_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_StfuDecodeErrorZ {
10257         let res: Result<lightning::ln::msgs::Stfu, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10258         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Stfu { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10259         local_res
10260 }
10261 #[no_mangle]
10262 /// Serialize the Splice object into a byte array which can be read by Splice_read
10263 pub extern "C" fn Splice_write(obj: &crate::lightning::ln::msgs::Splice) -> crate::c_types::derived::CVec_u8Z {
10264         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10265 }
10266 #[allow(unused)]
10267 pub(crate) extern "C" fn Splice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10268         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSplice) })
10269 }
10270 #[no_mangle]
10271 /// Read a Splice from a byte array, created by Splice_write
10272 pub extern "C" fn Splice_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceDecodeErrorZ {
10273         let res: Result<lightning::ln::msgs::Splice, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10274         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Splice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10275         local_res
10276 }
10277 #[no_mangle]
10278 /// Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read
10279 pub extern "C" fn SpliceAck_write(obj: &crate::lightning::ln::msgs::SpliceAck) -> crate::c_types::derived::CVec_u8Z {
10280         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10281 }
10282 #[allow(unused)]
10283 pub(crate) extern "C" fn SpliceAck_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10284         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceAck) })
10285 }
10286 #[no_mangle]
10287 /// Read a SpliceAck from a byte array, created by SpliceAck_write
10288 pub extern "C" fn SpliceAck_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceAckDecodeErrorZ {
10289         let res: Result<lightning::ln::msgs::SpliceAck, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10290         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SpliceAck { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10291         local_res
10292 }
10293 #[no_mangle]
10294 /// Serialize the SpliceLocked object into a byte array which can be read by SpliceLocked_read
10295 pub extern "C" fn SpliceLocked_write(obj: &crate::lightning::ln::msgs::SpliceLocked) -> crate::c_types::derived::CVec_u8Z {
10296         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10297 }
10298 #[allow(unused)]
10299 pub(crate) extern "C" fn SpliceLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10300         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceLocked) })
10301 }
10302 #[no_mangle]
10303 /// Read a SpliceLocked from a byte array, created by SpliceLocked_write
10304 pub extern "C" fn SpliceLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceLockedDecodeErrorZ {
10305         let res: Result<lightning::ln::msgs::SpliceLocked, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10306         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SpliceLocked { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10307         local_res
10308 }
10309 #[no_mangle]
10310 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
10311 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
10312         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10313 }
10314 #[allow(unused)]
10315 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10316         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
10317 }
10318 #[no_mangle]
10319 /// Read a TxAddInput from a byte array, created by TxAddInput_write
10320 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
10321         let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10322         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10323         local_res
10324 }
10325 #[no_mangle]
10326 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
10327 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
10328         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10329 }
10330 #[allow(unused)]
10331 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10332         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
10333 }
10334 #[no_mangle]
10335 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
10336 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
10337         let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10338         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10339         local_res
10340 }
10341 #[no_mangle]
10342 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
10343 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
10344         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10345 }
10346 #[allow(unused)]
10347 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10348         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
10349 }
10350 #[no_mangle]
10351 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
10352 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
10353         let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10354         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10355         local_res
10356 }
10357 #[no_mangle]
10358 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
10359 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
10360         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10361 }
10362 #[allow(unused)]
10363 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10364         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
10365 }
10366 #[no_mangle]
10367 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
10368 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
10369         let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10370         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10371         local_res
10372 }
10373 #[no_mangle]
10374 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
10375 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
10376         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10377 }
10378 #[allow(unused)]
10379 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10380         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
10381 }
10382 #[no_mangle]
10383 /// Read a TxComplete from a byte array, created by TxComplete_write
10384 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
10385         let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10386         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10387         local_res
10388 }
10389 #[no_mangle]
10390 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
10391 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
10392         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10393 }
10394 #[allow(unused)]
10395 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10396         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
10397 }
10398 #[no_mangle]
10399 /// Read a TxSignatures from a byte array, created by TxSignatures_write
10400 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
10401         let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10402         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10403         local_res
10404 }
10405 #[no_mangle]
10406 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
10407 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
10408         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10409 }
10410 #[allow(unused)]
10411 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10412         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
10413 }
10414 #[no_mangle]
10415 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
10416 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
10417         let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10418         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10419         local_res
10420 }
10421 #[no_mangle]
10422 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
10423 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
10424         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10425 }
10426 #[allow(unused)]
10427 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10428         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
10429 }
10430 #[no_mangle]
10431 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
10432 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
10433         let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10434         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10435         local_res
10436 }
10437 #[no_mangle]
10438 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
10439 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
10440         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10441 }
10442 #[allow(unused)]
10443 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10444         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
10445 }
10446 #[no_mangle]
10447 /// Read a TxAbort from a byte array, created by TxAbort_write
10448 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
10449         let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10450         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10451         local_res
10452 }
10453 #[no_mangle]
10454 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
10455 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
10456         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10457 }
10458 #[allow(unused)]
10459 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10460         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
10461 }
10462 #[no_mangle]
10463 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
10464 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
10465         let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10466         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10467         local_res
10468 }
10469 #[no_mangle]
10470 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
10471 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
10472         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10473 }
10474 #[allow(unused)]
10475 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10476         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
10477 }
10478 #[no_mangle]
10479 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
10480 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
10481         let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10482         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10483         local_res
10484 }
10485 #[no_mangle]
10486 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
10487 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
10488         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10489 }
10490 #[allow(unused)]
10491 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10492         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
10493 }
10494 #[no_mangle]
10495 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
10496 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
10497         let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10498         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10499         local_res
10500 }
10501 #[no_mangle]
10502 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
10503 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
10504         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10505 }
10506 #[allow(unused)]
10507 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10508         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
10509 }
10510 #[no_mangle]
10511 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
10512 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
10513         let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10514         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10515         local_res
10516 }
10517 #[no_mangle]
10518 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
10519 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
10520         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10521 }
10522 #[allow(unused)]
10523 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10524         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
10525 }
10526 #[no_mangle]
10527 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
10528 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
10529         let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10530         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::CommitmentSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10531         local_res
10532 }
10533 #[no_mangle]
10534 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
10535 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
10536         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10537 }
10538 #[allow(unused)]
10539 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10540         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
10541 }
10542 #[no_mangle]
10543 /// Read a FundingCreated from a byte array, created by FundingCreated_write
10544 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
10545         let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10546         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10547         local_res
10548 }
10549 #[no_mangle]
10550 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
10551 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
10552         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10553 }
10554 #[allow(unused)]
10555 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10556         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
10557 }
10558 #[no_mangle]
10559 /// Read a FundingSigned from a byte array, created by FundingSigned_write
10560 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
10561         let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10562         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10563         local_res
10564 }
10565 #[no_mangle]
10566 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
10567 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
10568         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10569 }
10570 #[allow(unused)]
10571 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10572         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
10573 }
10574 #[no_mangle]
10575 /// Read a ChannelReady from a byte array, created by ChannelReady_write
10576 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
10577         let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10578         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10579         local_res
10580 }
10581 #[no_mangle]
10582 /// Serialize the Init object into a byte array which can be read by Init_read
10583 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
10584         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10585 }
10586 #[allow(unused)]
10587 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10588         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
10589 }
10590 #[no_mangle]
10591 /// Read a Init from a byte array, created by Init_write
10592 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
10593         let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10594         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Init { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10595         local_res
10596 }
10597 #[no_mangle]
10598 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
10599 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
10600         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10601 }
10602 #[allow(unused)]
10603 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10604         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
10605 }
10606 #[no_mangle]
10607 /// Read a OpenChannel from a byte array, created by OpenChannel_write
10608 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
10609         let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10610         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10611         local_res
10612 }
10613 #[no_mangle]
10614 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
10615 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
10616         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10617 }
10618 #[allow(unused)]
10619 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10620         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
10621 }
10622 #[no_mangle]
10623 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
10624 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
10625         let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10626         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10627         local_res
10628 }
10629 #[no_mangle]
10630 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
10631 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
10632         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10633 }
10634 #[allow(unused)]
10635 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10636         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
10637 }
10638 #[no_mangle]
10639 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
10640 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
10641         let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10642         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10643         local_res
10644 }
10645 #[no_mangle]
10646 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
10647 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
10648         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10649 }
10650 #[allow(unused)]
10651 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10652         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
10653 }
10654 #[no_mangle]
10655 /// Read a Shutdown from a byte array, created by Shutdown_write
10656 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
10657         let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10658         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10659         local_res
10660 }
10661 #[no_mangle]
10662 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
10663 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
10664         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10665 }
10666 #[allow(unused)]
10667 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10668         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
10669 }
10670 #[no_mangle]
10671 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
10672 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
10673         let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10674         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10675         local_res
10676 }
10677 #[no_mangle]
10678 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
10679 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
10680         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10681 }
10682 #[allow(unused)]
10683 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10684         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
10685 }
10686 #[no_mangle]
10687 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
10688 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
10689         let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10690         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10691         local_res
10692 }
10693 #[no_mangle]
10694 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
10695 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
10696         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10697 }
10698 #[allow(unused)]
10699 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10700         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
10701 }
10702 #[no_mangle]
10703 /// Read a UpdateFee from a byte array, created by UpdateFee_write
10704 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
10705         let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10706         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFee { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10707         local_res
10708 }
10709 #[no_mangle]
10710 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
10711 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
10712         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10713 }
10714 #[allow(unused)]
10715 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10716         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
10717 }
10718 #[no_mangle]
10719 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
10720 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
10721         let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10722         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10723         local_res
10724 }
10725 #[no_mangle]
10726 /// Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read
10727 pub extern "C" fn OnionPacket_write(obj: &crate::lightning::ln::msgs::OnionPacket) -> crate::c_types::derived::CVec_u8Z {
10728         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10729 }
10730 #[allow(unused)]
10731 pub(crate) extern "C" fn OnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10732         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionPacket) })
10733 }
10734 #[no_mangle]
10735 /// Read a OnionPacket from a byte array, created by OnionPacket_write
10736 pub extern "C" fn OnionPacket_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionPacketDecodeErrorZ {
10737         let res: Result<lightning::ln::msgs::OnionPacket, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10738         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OnionPacket { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10739         local_res
10740 }
10741 #[no_mangle]
10742 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
10743 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
10744         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10745 }
10746 #[allow(unused)]
10747 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10748         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
10749 }
10750 #[no_mangle]
10751 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
10752 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
10753         let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10754         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10755         local_res
10756 }
10757 #[no_mangle]
10758 /// Read a OnionMessage from a byte array, created by OnionMessage_write
10759 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
10760         let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10761         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10762         local_res
10763 }
10764 #[no_mangle]
10765 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
10766 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
10767         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10768 }
10769 #[allow(unused)]
10770 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10771         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
10772 }
10773 #[no_mangle]
10774 /// Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read
10775 pub extern "C" fn FinalOnionHopData_write(obj: &crate::lightning::ln::msgs::FinalOnionHopData) -> crate::c_types::derived::CVec_u8Z {
10776         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10777 }
10778 #[allow(unused)]
10779 pub(crate) extern "C" fn FinalOnionHopData_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10780         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFinalOnionHopData) })
10781 }
10782 #[no_mangle]
10783 /// Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write
10784 pub extern "C" fn FinalOnionHopData_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FinalOnionHopDataDecodeErrorZ {
10785         let res: Result<lightning::ln::msgs::FinalOnionHopData, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10786         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FinalOnionHopData { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10787         local_res
10788 }
10789 #[no_mangle]
10790 /// Serialize the Ping object into a byte array which can be read by Ping_read
10791 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
10792         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10793 }
10794 #[allow(unused)]
10795 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10796         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
10797 }
10798 #[no_mangle]
10799 /// Read a Ping from a byte array, created by Ping_write
10800 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
10801         let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10802         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Ping { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10803         local_res
10804 }
10805 #[no_mangle]
10806 /// Serialize the Pong object into a byte array which can be read by Pong_read
10807 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
10808         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10809 }
10810 #[allow(unused)]
10811 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10812         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
10813 }
10814 #[no_mangle]
10815 /// Read a Pong from a byte array, created by Pong_write
10816 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
10817         let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10818         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Pong { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10819         local_res
10820 }
10821 #[no_mangle]
10822 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
10823 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10824         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10825 }
10826 #[allow(unused)]
10827 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10828         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
10829 }
10830 #[no_mangle]
10831 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
10832 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
10833         let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10834         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10835         local_res
10836 }
10837 #[no_mangle]
10838 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
10839 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10840         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10841 }
10842 #[allow(unused)]
10843 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10844         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
10845 }
10846 #[no_mangle]
10847 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
10848 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
10849         let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10850         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10851         local_res
10852 }
10853 #[no_mangle]
10854 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
10855 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10856         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10857 }
10858 #[allow(unused)]
10859 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10860         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
10861 }
10862 #[no_mangle]
10863 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
10864 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
10865         let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10866         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10867         local_res
10868 }
10869 #[no_mangle]
10870 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
10871 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10872         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10873 }
10874 #[allow(unused)]
10875 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10876         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
10877 }
10878 #[no_mangle]
10879 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
10880 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
10881         let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10882         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10883         local_res
10884 }
10885 #[no_mangle]
10886 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
10887 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
10888         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10889 }
10890 #[allow(unused)]
10891 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10892         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
10893 }
10894 #[no_mangle]
10895 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
10896 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
10897         let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10898         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10899         local_res
10900 }
10901 #[no_mangle]
10902 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
10903 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
10904         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10905 }
10906 #[allow(unused)]
10907 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10908         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
10909 }
10910 #[no_mangle]
10911 /// Read a WarningMessage from a byte array, created by WarningMessage_write
10912 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
10913         let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10914         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10915         local_res
10916 }
10917 #[no_mangle]
10918 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
10919 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10920         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10921 }
10922 #[allow(unused)]
10923 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10924         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
10925 }
10926 #[no_mangle]
10927 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
10928 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
10929         let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10930         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10931         local_res
10932 }
10933 #[no_mangle]
10934 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
10935 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10936         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10937 }
10938 #[allow(unused)]
10939 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10940         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
10941 }
10942 #[no_mangle]
10943 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
10944 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
10945         let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10946         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10947         local_res
10948 }
10949 #[no_mangle]
10950 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
10951 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
10952         let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10953         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10954         local_res
10955 }
10956 #[no_mangle]
10957 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
10958 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
10959         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10960 }
10961 #[allow(unused)]
10962 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10963         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
10964 }
10965 #[no_mangle]
10966 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
10967 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
10968         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10969 }
10970 #[allow(unused)]
10971 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10972         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
10973 }
10974 #[no_mangle]
10975 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
10976 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
10977         let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10978         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10979         local_res
10980 }
10981 /// Calculates the overflow safe ending block height for the query.
10982 ///
10983 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
10984 #[must_use]
10985 #[no_mangle]
10986 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
10987         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
10988         ret
10989 }
10990
10991 #[no_mangle]
10992 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
10993 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
10994         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10995 }
10996 #[allow(unused)]
10997 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10998         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
10999 }
11000 #[no_mangle]
11001 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
11002 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
11003         let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11004         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
11005         local_res
11006 }
11007 #[no_mangle]
11008 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
11009 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
11010         let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11011         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
11012         local_res
11013 }
11014 #[no_mangle]
11015 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
11016 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
11017         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
11018 }
11019 #[allow(unused)]
11020 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
11021         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
11022 }
11023 #[no_mangle]
11024 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
11025 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
11026         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
11027 }
11028 #[allow(unused)]
11029 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
11030         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
11031 }
11032 #[no_mangle]
11033 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
11034 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
11035         let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11036         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
11037         local_res
11038 }