Update auto-generated bindings
[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 core::ffi::c_void;
28 use core::convert::Infallible;
29 use bitcoin::hashes::Hash;
30 use crate::c_types::*;
31 #[cfg(feature="no-std")]
32 use alloc::{vec::Vec, boxed::Box};
33
34 /// An error in decoding a message or struct.
35 #[derive(Clone)]
36 #[must_use]
37 #[repr(C)]
38 pub enum DecodeError {
39         /// A version byte specified something we don't know how to handle.
40         ///
41         /// Includes unknown realm byte in an onion hop data packet.
42         UnknownVersion,
43         /// Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type)
44         UnknownRequiredFeature,
45         /// Value was invalid.
46         ///
47         /// For example, a byte which was supposed to be a bool was something other than a 0
48         /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
49         /// syntactically incorrect, etc.
50         InvalidValue,
51         /// The buffer to be read was too short.
52         ShortRead,
53         /// A length descriptor in the packet didn't describe the later data correctly.
54         BadLengthDescriptor,
55         /// Error from [`std::io`].
56         Io(
57                 crate::c_types::IOError),
58         /// The message included zlib-compressed values, which we don't support.
59         UnsupportedCompression,
60 }
61 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
62 pub(crate) type nativeDecodeError = DecodeErrorImport;
63
64 impl DecodeError {
65         #[allow(unused)]
66         pub(crate) fn to_native(&self) -> nativeDecodeError {
67                 match self {
68                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
69                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
70                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
71                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
72                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
73                         DecodeError::Io (ref a, ) => {
74                                 let mut a_nonref = Clone::clone(a);
75                                 nativeDecodeError::Io (
76                                         a_nonref.to_rust_kind(),
77                                 )
78                         },
79                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
80                 }
81         }
82         #[allow(unused)]
83         pub(crate) fn into_native(self) -> nativeDecodeError {
84                 match self {
85                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
86                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
87                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
88                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
89                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
90                         DecodeError::Io (mut a, ) => {
91                                 nativeDecodeError::Io (
92                                         a.to_rust_kind(),
93                                 )
94                         },
95                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
96                 }
97         }
98         #[allow(unused)]
99         pub(crate) fn from_native(native: &nativeDecodeError) -> Self {
100                 match native {
101                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
102                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
103                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
104                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
105                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
106                         nativeDecodeError::Io (ref a, ) => {
107                                 let mut a_nonref = Clone::clone(a);
108                                 DecodeError::Io (
109                                         crate::c_types::IOError::from_rust_kind(a_nonref),
110                                 )
111                         },
112                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
113                 }
114         }
115         #[allow(unused)]
116         pub(crate) fn native_into(native: nativeDecodeError) -> Self {
117                 match native {
118                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
119                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
120                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
121                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
122                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
123                         nativeDecodeError::Io (mut a, ) => {
124                                 DecodeError::Io (
125                                         crate::c_types::IOError::from_rust_kind(a),
126                                 )
127                         },
128                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
129                 }
130         }
131 }
132 /// Frees any resources used by the DecodeError
133 #[no_mangle]
134 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
135 /// Creates a copy of the DecodeError
136 #[no_mangle]
137 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
138         orig.clone()
139 }
140 #[no_mangle]
141 /// Utility method to constructs a new UnknownVersion-variant DecodeError
142 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
143         DecodeError::UnknownVersion}
144 #[no_mangle]
145 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
146 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
147         DecodeError::UnknownRequiredFeature}
148 #[no_mangle]
149 /// Utility method to constructs a new InvalidValue-variant DecodeError
150 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
151         DecodeError::InvalidValue}
152 #[no_mangle]
153 /// Utility method to constructs a new ShortRead-variant DecodeError
154 pub extern "C" fn DecodeError_short_read() -> DecodeError {
155         DecodeError::ShortRead}
156 #[no_mangle]
157 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
158 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
159         DecodeError::BadLengthDescriptor}
160 #[no_mangle]
161 /// Utility method to constructs a new Io-variant DecodeError
162 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
163         DecodeError::Io(a, )
164 }
165 #[no_mangle]
166 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
167 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
168         DecodeError::UnsupportedCompression}
169 /// Checks if two DecodeErrors contain equal inner contents.
170 /// This ignores pointers and is_owned flags and looks at the values in fields.
171 #[no_mangle]
172 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
173         if &a.to_native() == &b.to_native() { true } else { false }
174 }
175
176 use lightning::ln::msgs::Init as nativeInitImport;
177 pub(crate) type nativeInit = nativeInitImport;
178
179 /// An [`init`] message to be sent to or received from a peer.
180 ///
181 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
182 #[must_use]
183 #[repr(C)]
184 pub struct Init {
185         /// A pointer to the opaque Rust object.
186
187         /// Nearly everywhere, inner must be non-null, however in places where
188         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
189         pub inner: *mut nativeInit,
190         /// Indicates that this is the only struct which contains the same pointer.
191
192         /// Rust functions which take ownership of an object provided via an argument require
193         /// this to be true and invalidate the object pointed to by inner.
194         pub is_owned: bool,
195 }
196
197 impl Drop for Init {
198         fn drop(&mut self) {
199                 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
200                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
201                 }
202         }
203 }
204 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
205 #[no_mangle]
206 pub extern "C" fn Init_free(this_obj: Init) { }
207 #[allow(unused)]
208 /// Used only if an object of this type is returned as a trait impl by a method
209 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
210         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
211 }
212 #[allow(unused)]
213 impl Init {
214         pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
215                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
216         }
217         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
218                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
219         }
220         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
221         pub(crate) fn take_inner(mut self) -> *mut nativeInit {
222                 assert!(self.is_owned);
223                 let ret = ObjOps::untweak_ptr(self.inner);
224                 self.inner = core::ptr::null_mut();
225                 ret
226         }
227 }
228 /// The relevant features which the sender supports.
229 #[no_mangle]
230 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
231         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
232         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 }
233 }
234 /// The relevant features which the sender supports.
235 #[no_mangle]
236 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
237         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
238 }
239 /// The receipient's network address.
240 ///
241 /// This adds the option to report a remote IP address back to a connecting peer using the init
242 /// message. A node can decide to use that information to discover a potential update to its
243 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
244 /// the new address.
245 #[no_mangle]
246 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_NetAddressZ {
247         let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
248         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NetAddressZ::None } else { crate::c_types::derived::COption_NetAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::msgs::NetAddress::native_into(inner_val.clone().unwrap()) }) };
249         local_inner_val
250 }
251 /// The receipient's network address.
252 ///
253 /// This adds the option to report a remote IP address back to a connecting peer using the init
254 /// message. A node can decide to use that information to discover a potential update to its
255 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
256 /// the new address.
257 #[no_mangle]
258 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_NetAddressZ) {
259         let mut local_val = { /* val*/ let val_opt = val; { } if val_opt.is_none() { None } else { Some({ val_opt.take().into_native() }) } };
260         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
261 }
262 /// Constructs a new Init given each field
263 #[must_use]
264 #[no_mangle]
265 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init {
266         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() }) } };
267         Init { inner: ObjOps::heap_alloc(nativeInit {
268                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
269                 remote_network_address: local_remote_network_address_arg,
270         }), is_owned: true }
271 }
272 impl Clone for Init {
273         fn clone(&self) -> Self {
274                 Self {
275                         inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
276                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
277                         is_owned: true,
278                 }
279         }
280 }
281 #[allow(unused)]
282 /// Used only if an object of this type is returned as a trait impl by a method
283 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
284         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
285 }
286 #[no_mangle]
287 /// Creates a copy of the Init
288 pub extern "C" fn Init_clone(orig: &Init) -> Init {
289         orig.clone()
290 }
291 /// Checks if two Inits contain equal inner contents.
292 /// This ignores pointers and is_owned flags and looks at the values in fields.
293 /// Two objects with NULL inner values will be considered "equal" here.
294 #[no_mangle]
295 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
296         if a.inner == b.inner { return true; }
297         if a.inner.is_null() || b.inner.is_null() { return false; }
298         if a.get_native_ref() == b.get_native_ref() { true } else { false }
299 }
300
301 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
302 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
303
304 /// An [`error`] message to be sent to or received from a peer.
305 ///
306 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
307 #[must_use]
308 #[repr(C)]
309 pub struct ErrorMessage {
310         /// A pointer to the opaque Rust object.
311
312         /// Nearly everywhere, inner must be non-null, however in places where
313         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
314         pub inner: *mut nativeErrorMessage,
315         /// Indicates that this is the only struct which contains the same pointer.
316
317         /// Rust functions which take ownership of an object provided via an argument require
318         /// this to be true and invalidate the object pointed to by inner.
319         pub is_owned: bool,
320 }
321
322 impl Drop for ErrorMessage {
323         fn drop(&mut self) {
324                 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
325                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
326                 }
327         }
328 }
329 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
330 #[no_mangle]
331 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
332 #[allow(unused)]
333 /// Used only if an object of this type is returned as a trait impl by a method
334 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
335         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
336 }
337 #[allow(unused)]
338 impl ErrorMessage {
339         pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
340                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
341         }
342         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
343                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
344         }
345         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
346         pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
347                 assert!(self.is_owned);
348                 let ret = ObjOps::untweak_ptr(self.inner);
349                 self.inner = core::ptr::null_mut();
350                 ret
351         }
352 }
353 /// The channel ID involved in the error.
354 ///
355 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
356 /// with the sending peer should be closed.
357 #[no_mangle]
358 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
359         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
360         inner_val
361 }
362 /// The channel ID involved in the error.
363 ///
364 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
365 /// with the sending peer should be closed.
366 #[no_mangle]
367 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
368         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
369 }
370 /// A possibly human-readable error description.
371 ///
372 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
373 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
374 /// the terminal emulator or the logging subsystem.
375 #[no_mangle]
376 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
377         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
378         inner_val.as_str().into()
379 }
380 /// A possibly human-readable error description.
381 ///
382 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
383 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
384 /// the terminal emulator or the logging subsystem.
385 #[no_mangle]
386 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
387         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
388 }
389 /// Constructs a new ErrorMessage given each field
390 #[must_use]
391 #[no_mangle]
392 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
393         ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
394                 channel_id: channel_id_arg.data,
395                 data: data_arg.into_string(),
396         }), is_owned: true }
397 }
398 impl Clone for ErrorMessage {
399         fn clone(&self) -> Self {
400                 Self {
401                         inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
402                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
403                         is_owned: true,
404                 }
405         }
406 }
407 #[allow(unused)]
408 /// Used only if an object of this type is returned as a trait impl by a method
409 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
410         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
411 }
412 #[no_mangle]
413 /// Creates a copy of the ErrorMessage
414 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
415         orig.clone()
416 }
417 /// Checks if two ErrorMessages contain equal inner contents.
418 /// This ignores pointers and is_owned flags and looks at the values in fields.
419 /// Two objects with NULL inner values will be considered "equal" here.
420 #[no_mangle]
421 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
422         if a.inner == b.inner { return true; }
423         if a.inner.is_null() || b.inner.is_null() { return false; }
424         if a.get_native_ref() == b.get_native_ref() { true } else { false }
425 }
426
427 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
428 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
429
430 /// A [`warning`] message to be sent to or received from a peer.
431 ///
432 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
433 #[must_use]
434 #[repr(C)]
435 pub struct WarningMessage {
436         /// A pointer to the opaque Rust object.
437
438         /// Nearly everywhere, inner must be non-null, however in places where
439         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
440         pub inner: *mut nativeWarningMessage,
441         /// Indicates that this is the only struct which contains the same pointer.
442
443         /// Rust functions which take ownership of an object provided via an argument require
444         /// this to be true and invalidate the object pointed to by inner.
445         pub is_owned: bool,
446 }
447
448 impl Drop for WarningMessage {
449         fn drop(&mut self) {
450                 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
451                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
452                 }
453         }
454 }
455 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
456 #[no_mangle]
457 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
458 #[allow(unused)]
459 /// Used only if an object of this type is returned as a trait impl by a method
460 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
461         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
462 }
463 #[allow(unused)]
464 impl WarningMessage {
465         pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
466                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
467         }
468         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
469                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
470         }
471         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
472         pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
473                 assert!(self.is_owned);
474                 let ret = ObjOps::untweak_ptr(self.inner);
475                 self.inner = core::ptr::null_mut();
476                 ret
477         }
478 }
479 /// The channel ID involved in the warning.
480 ///
481 /// All-0s indicates a warning unrelated to a specific channel.
482 #[no_mangle]
483 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
484         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
485         inner_val
486 }
487 /// The channel ID involved in the warning.
488 ///
489 /// All-0s indicates a warning unrelated to a specific channel.
490 #[no_mangle]
491 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
492         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
493 }
494 /// A possibly human-readable warning description.
495 ///
496 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
497 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
498 /// the terminal emulator or the logging subsystem.
499 #[no_mangle]
500 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
501         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
502         inner_val.as_str().into()
503 }
504 /// A possibly human-readable warning description.
505 ///
506 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
507 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
508 /// the terminal emulator or the logging subsystem.
509 #[no_mangle]
510 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
511         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
512 }
513 /// Constructs a new WarningMessage given each field
514 #[must_use]
515 #[no_mangle]
516 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
517         WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
518                 channel_id: channel_id_arg.data,
519                 data: data_arg.into_string(),
520         }), is_owned: true }
521 }
522 impl Clone for WarningMessage {
523         fn clone(&self) -> Self {
524                 Self {
525                         inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
526                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
527                         is_owned: true,
528                 }
529         }
530 }
531 #[allow(unused)]
532 /// Used only if an object of this type is returned as a trait impl by a method
533 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
534         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void
535 }
536 #[no_mangle]
537 /// Creates a copy of the WarningMessage
538 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
539         orig.clone()
540 }
541 /// Checks if two WarningMessages contain equal inner contents.
542 /// This ignores pointers and is_owned flags and looks at the values in fields.
543 /// Two objects with NULL inner values will be considered "equal" here.
544 #[no_mangle]
545 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
546         if a.inner == b.inner { return true; }
547         if a.inner.is_null() || b.inner.is_null() { return false; }
548         if a.get_native_ref() == b.get_native_ref() { true } else { false }
549 }
550
551 use lightning::ln::msgs::Ping as nativePingImport;
552 pub(crate) type nativePing = nativePingImport;
553
554 /// A [`ping`] message to be sent to or received from a peer.
555 ///
556 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
557 #[must_use]
558 #[repr(C)]
559 pub struct Ping {
560         /// A pointer to the opaque Rust object.
561
562         /// Nearly everywhere, inner must be non-null, however in places where
563         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
564         pub inner: *mut nativePing,
565         /// Indicates that this is the only struct which contains the same pointer.
566
567         /// Rust functions which take ownership of an object provided via an argument require
568         /// this to be true and invalidate the object pointed to by inner.
569         pub is_owned: bool,
570 }
571
572 impl Drop for Ping {
573         fn drop(&mut self) {
574                 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
575                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
576                 }
577         }
578 }
579 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
580 #[no_mangle]
581 pub extern "C" fn Ping_free(this_obj: Ping) { }
582 #[allow(unused)]
583 /// Used only if an object of this type is returned as a trait impl by a method
584 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
585         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
586 }
587 #[allow(unused)]
588 impl Ping {
589         pub(crate) fn get_native_ref(&self) -> &'static nativePing {
590                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
591         }
592         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
593                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
594         }
595         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
596         pub(crate) fn take_inner(mut self) -> *mut nativePing {
597                 assert!(self.is_owned);
598                 let ret = ObjOps::untweak_ptr(self.inner);
599                 self.inner = core::ptr::null_mut();
600                 ret
601         }
602 }
603 /// The desired response length.
604 #[no_mangle]
605 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
606         let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
607         *inner_val
608 }
609 /// The desired response length.
610 #[no_mangle]
611 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
612         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
613 }
614 /// The ping packet size.
615 ///
616 /// This field is not sent on the wire. byteslen zeros are sent.
617 #[no_mangle]
618 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
619         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
620         *inner_val
621 }
622 /// The ping packet size.
623 ///
624 /// This field is not sent on the wire. byteslen zeros are sent.
625 #[no_mangle]
626 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
627         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
628 }
629 /// Constructs a new Ping given each field
630 #[must_use]
631 #[no_mangle]
632 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
633         Ping { inner: ObjOps::heap_alloc(nativePing {
634                 ponglen: ponglen_arg,
635                 byteslen: byteslen_arg,
636         }), is_owned: true }
637 }
638 impl Clone for Ping {
639         fn clone(&self) -> Self {
640                 Self {
641                         inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
642                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
643                         is_owned: true,
644                 }
645         }
646 }
647 #[allow(unused)]
648 /// Used only if an object of this type is returned as a trait impl by a method
649 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
650         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
651 }
652 #[no_mangle]
653 /// Creates a copy of the Ping
654 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
655         orig.clone()
656 }
657 /// Checks if two Pings contain equal inner contents.
658 /// This ignores pointers and is_owned flags and looks at the values in fields.
659 /// Two objects with NULL inner values will be considered "equal" here.
660 #[no_mangle]
661 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
662         if a.inner == b.inner { return true; }
663         if a.inner.is_null() || b.inner.is_null() { return false; }
664         if a.get_native_ref() == b.get_native_ref() { true } else { false }
665 }
666
667 use lightning::ln::msgs::Pong as nativePongImport;
668 pub(crate) type nativePong = nativePongImport;
669
670 /// A [`pong`] message to be sent to or received from a peer.
671 ///
672 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
673 #[must_use]
674 #[repr(C)]
675 pub struct Pong {
676         /// A pointer to the opaque Rust object.
677
678         /// Nearly everywhere, inner must be non-null, however in places where
679         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
680         pub inner: *mut nativePong,
681         /// Indicates that this is the only struct which contains the same pointer.
682
683         /// Rust functions which take ownership of an object provided via an argument require
684         /// this to be true and invalidate the object pointed to by inner.
685         pub is_owned: bool,
686 }
687
688 impl Drop for Pong {
689         fn drop(&mut self) {
690                 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
691                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
692                 }
693         }
694 }
695 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
696 #[no_mangle]
697 pub extern "C" fn Pong_free(this_obj: Pong) { }
698 #[allow(unused)]
699 /// Used only if an object of this type is returned as a trait impl by a method
700 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
701         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
702 }
703 #[allow(unused)]
704 impl Pong {
705         pub(crate) fn get_native_ref(&self) -> &'static nativePong {
706                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
707         }
708         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
709                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
710         }
711         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
712         pub(crate) fn take_inner(mut self) -> *mut nativePong {
713                 assert!(self.is_owned);
714                 let ret = ObjOps::untweak_ptr(self.inner);
715                 self.inner = core::ptr::null_mut();
716                 ret
717         }
718 }
719 /// The pong packet size.
720 ///
721 /// This field is not sent on the wire. byteslen zeros are sent.
722 #[no_mangle]
723 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
724         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
725         *inner_val
726 }
727 /// The pong packet size.
728 ///
729 /// This field is not sent on the wire. byteslen zeros are sent.
730 #[no_mangle]
731 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
732         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
733 }
734 /// Constructs a new Pong given each field
735 #[must_use]
736 #[no_mangle]
737 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
738         Pong { inner: ObjOps::heap_alloc(nativePong {
739                 byteslen: byteslen_arg,
740         }), is_owned: true }
741 }
742 impl Clone for Pong {
743         fn clone(&self) -> Self {
744                 Self {
745                         inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
746                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
747                         is_owned: true,
748                 }
749         }
750 }
751 #[allow(unused)]
752 /// Used only if an object of this type is returned as a trait impl by a method
753 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
754         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
755 }
756 #[no_mangle]
757 /// Creates a copy of the Pong
758 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
759         orig.clone()
760 }
761 /// Checks if two Pongs contain equal inner contents.
762 /// This ignores pointers and is_owned flags and looks at the values in fields.
763 /// Two objects with NULL inner values will be considered "equal" here.
764 #[no_mangle]
765 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
766         if a.inner == b.inner { return true; }
767         if a.inner.is_null() || b.inner.is_null() { return false; }
768         if a.get_native_ref() == b.get_native_ref() { true } else { false }
769 }
770
771 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
772 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
773
774 /// An [`open_channel`] message to be sent to or received from a peer.
775 ///
776 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
777 #[must_use]
778 #[repr(C)]
779 pub struct OpenChannel {
780         /// A pointer to the opaque Rust object.
781
782         /// Nearly everywhere, inner must be non-null, however in places where
783         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
784         pub inner: *mut nativeOpenChannel,
785         /// Indicates that this is the only struct which contains the same pointer.
786
787         /// Rust functions which take ownership of an object provided via an argument require
788         /// this to be true and invalidate the object pointed to by inner.
789         pub is_owned: bool,
790 }
791
792 impl Drop for OpenChannel {
793         fn drop(&mut self) {
794                 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
795                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
796                 }
797         }
798 }
799 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
800 #[no_mangle]
801 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
802 #[allow(unused)]
803 /// Used only if an object of this type is returned as a trait impl by a method
804 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
805         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
806 }
807 #[allow(unused)]
808 impl OpenChannel {
809         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
810                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
811         }
812         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
813                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
814         }
815         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
816         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
817                 assert!(self.is_owned);
818                 let ret = ObjOps::untweak_ptr(self.inner);
819                 self.inner = core::ptr::null_mut();
820                 ret
821         }
822 }
823 /// The genesis hash of the blockchain where the channel is to be opened
824 #[no_mangle]
825 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
826         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
827         inner_val.as_inner()
828 }
829 /// The genesis hash of the blockchain where the channel is to be opened
830 #[no_mangle]
831 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
832         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
833 }
834 /// A temporary channel ID, until the funding outpoint is announced
835 #[no_mangle]
836 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
837         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
838         inner_val
839 }
840 /// A temporary channel ID, until the funding outpoint is announced
841 #[no_mangle]
842 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
843         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
844 }
845 /// The channel value
846 #[no_mangle]
847 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
848         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
849         *inner_val
850 }
851 /// The channel value
852 #[no_mangle]
853 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
854         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
855 }
856 /// The amount to push to the counterparty as part of the open, in milli-satoshi
857 #[no_mangle]
858 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
859         let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
860         *inner_val
861 }
862 /// The amount to push to the counterparty as part of the open, in milli-satoshi
863 #[no_mangle]
864 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
865         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
866 }
867 /// The threshold below which outputs on transactions broadcast by sender will be omitted
868 #[no_mangle]
869 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
870         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
871         *inner_val
872 }
873 /// The threshold below which outputs on transactions broadcast by sender will be omitted
874 #[no_mangle]
875 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
876         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
877 }
878 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
879 #[no_mangle]
880 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
881         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
882         *inner_val
883 }
884 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
885 #[no_mangle]
886 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
887         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
888 }
889 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
890 #[no_mangle]
891 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
892         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
893         *inner_val
894 }
895 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
896 #[no_mangle]
897 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
898         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
899 }
900 /// The minimum HTLC size incoming to sender, in milli-satoshi
901 #[no_mangle]
902 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
903         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
904         *inner_val
905 }
906 /// The minimum HTLC size incoming to sender, in milli-satoshi
907 #[no_mangle]
908 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
909         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
910 }
911 /// The feerate per 1000-weight of sender generated transactions, until updated by
912 /// [`UpdateFee`]
913 #[no_mangle]
914 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
915         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
916         *inner_val
917 }
918 /// The feerate per 1000-weight of sender generated transactions, until updated by
919 /// [`UpdateFee`]
920 #[no_mangle]
921 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
922         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
923 }
924 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
925 /// they broadcast a commitment transaction
926 #[no_mangle]
927 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
928         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
929         *inner_val
930 }
931 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
932 /// they broadcast a commitment transaction
933 #[no_mangle]
934 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
935         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
936 }
937 /// The maximum number of inbound HTLCs towards sender
938 #[no_mangle]
939 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
940         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
941         *inner_val
942 }
943 /// The maximum number of inbound HTLCs towards sender
944 #[no_mangle]
945 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
946         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
947 }
948 /// The sender's key controlling the funding transaction
949 #[no_mangle]
950 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
951         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
952         crate::c_types::PublicKey::from_rust(&inner_val)
953 }
954 /// The sender's key controlling the funding transaction
955 #[no_mangle]
956 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
957         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
958 }
959 /// Used to derive a revocation key for transactions broadcast by counterparty
960 #[no_mangle]
961 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
962         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
963         crate::c_types::PublicKey::from_rust(&inner_val)
964 }
965 /// Used to derive a revocation key for transactions broadcast by counterparty
966 #[no_mangle]
967 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
968         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
969 }
970 /// A payment key to sender for transactions broadcast by counterparty
971 #[no_mangle]
972 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
973         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
974         crate::c_types::PublicKey::from_rust(&inner_val)
975 }
976 /// A payment key to sender for transactions broadcast by counterparty
977 #[no_mangle]
978 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
979         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
980 }
981 /// Used to derive a payment key to sender for transactions broadcast by sender
982 #[no_mangle]
983 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
984         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
985         crate::c_types::PublicKey::from_rust(&inner_val)
986 }
987 /// Used to derive a payment key to sender for transactions broadcast by sender
988 #[no_mangle]
989 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
990         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
991 }
992 /// Used to derive an HTLC payment key to sender
993 #[no_mangle]
994 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
995         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
996         crate::c_types::PublicKey::from_rust(&inner_val)
997 }
998 /// Used to derive an HTLC payment key to sender
999 #[no_mangle]
1000 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1001         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1002 }
1003 /// The first to-be-broadcast-by-sender transaction's per commitment point
1004 #[no_mangle]
1005 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1006         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1007         crate::c_types::PublicKey::from_rust(&inner_val)
1008 }
1009 /// The first to-be-broadcast-by-sender transaction's per commitment point
1010 #[no_mangle]
1011 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1012         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1013 }
1014 /// The channel flags to be used
1015 #[no_mangle]
1016 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
1017         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1018         *inner_val
1019 }
1020 /// The channel flags to be used
1021 #[no_mangle]
1022 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
1023         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1024 }
1025 /// The channel type that this channel will represent
1026 ///
1027 /// If this is `None`, we derive the channel type from the intersection of our
1028 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1029 ///
1030 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1031 #[no_mangle]
1032 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1033         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1034         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 };
1035         local_inner_val
1036 }
1037 /// The channel type that this channel will represent
1038 ///
1039 /// If this is `None`, we derive the channel type from the intersection of our
1040 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1041 ///
1042 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1043 #[no_mangle]
1044 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1045         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1046         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1047 }
1048 impl Clone for OpenChannel {
1049         fn clone(&self) -> Self {
1050                 Self {
1051                         inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1052                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1053                         is_owned: true,
1054                 }
1055         }
1056 }
1057 #[allow(unused)]
1058 /// Used only if an object of this type is returned as a trait impl by a method
1059 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1060         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
1061 }
1062 #[no_mangle]
1063 /// Creates a copy of the OpenChannel
1064 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1065         orig.clone()
1066 }
1067 /// Checks if two OpenChannels contain equal inner contents.
1068 /// This ignores pointers and is_owned flags and looks at the values in fields.
1069 /// Two objects with NULL inner values will be considered "equal" here.
1070 #[no_mangle]
1071 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1072         if a.inner == b.inner { return true; }
1073         if a.inner.is_null() || b.inner.is_null() { return false; }
1074         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1075 }
1076
1077 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1078 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1079
1080 /// An [`accept_channel`] message to be sent to or received from a peer.
1081 ///
1082 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1083 #[must_use]
1084 #[repr(C)]
1085 pub struct AcceptChannel {
1086         /// A pointer to the opaque Rust object.
1087
1088         /// Nearly everywhere, inner must be non-null, however in places where
1089         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1090         pub inner: *mut nativeAcceptChannel,
1091         /// Indicates that this is the only struct which contains the same pointer.
1092
1093         /// Rust functions which take ownership of an object provided via an argument require
1094         /// this to be true and invalidate the object pointed to by inner.
1095         pub is_owned: bool,
1096 }
1097
1098 impl Drop for AcceptChannel {
1099         fn drop(&mut self) {
1100                 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1101                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1102                 }
1103         }
1104 }
1105 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1106 #[no_mangle]
1107 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1108 #[allow(unused)]
1109 /// Used only if an object of this type is returned as a trait impl by a method
1110 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1111         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1112 }
1113 #[allow(unused)]
1114 impl AcceptChannel {
1115         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1116                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1117         }
1118         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1119                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1120         }
1121         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1122         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1123                 assert!(self.is_owned);
1124                 let ret = ObjOps::untweak_ptr(self.inner);
1125                 self.inner = core::ptr::null_mut();
1126                 ret
1127         }
1128 }
1129 /// A temporary channel ID, until the funding outpoint is announced
1130 #[no_mangle]
1131 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1132         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1133         inner_val
1134 }
1135 /// A temporary channel ID, until the funding outpoint is announced
1136 #[no_mangle]
1137 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1138         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1139 }
1140 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1141 #[no_mangle]
1142 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1143         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1144         *inner_val
1145 }
1146 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1147 #[no_mangle]
1148 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1149         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1150 }
1151 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1152 #[no_mangle]
1153 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1154         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1155         *inner_val
1156 }
1157 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1158 #[no_mangle]
1159 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1160         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1161 }
1162 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1163 #[no_mangle]
1164 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1165         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1166         *inner_val
1167 }
1168 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1169 #[no_mangle]
1170 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1171         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1172 }
1173 /// The minimum HTLC size incoming to sender, in milli-satoshi
1174 #[no_mangle]
1175 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1176         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1177         *inner_val
1178 }
1179 /// The minimum HTLC size incoming to sender, in milli-satoshi
1180 #[no_mangle]
1181 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1182         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1183 }
1184 /// Minimum depth of the funding transaction before the channel is considered open
1185 #[no_mangle]
1186 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1187         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1188         *inner_val
1189 }
1190 /// Minimum depth of the funding transaction before the channel is considered open
1191 #[no_mangle]
1192 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1193         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1194 }
1195 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1196 #[no_mangle]
1197 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1198         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1199         *inner_val
1200 }
1201 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1202 #[no_mangle]
1203 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1204         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1205 }
1206 /// The maximum number of inbound HTLCs towards sender
1207 #[no_mangle]
1208 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1209         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1210         *inner_val
1211 }
1212 /// The maximum number of inbound HTLCs towards sender
1213 #[no_mangle]
1214 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1215         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1216 }
1217 /// The sender's key controlling the funding transaction
1218 #[no_mangle]
1219 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1220         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1221         crate::c_types::PublicKey::from_rust(&inner_val)
1222 }
1223 /// The sender's key controlling the funding transaction
1224 #[no_mangle]
1225 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1226         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1227 }
1228 /// Used to derive a revocation key for transactions broadcast by counterparty
1229 #[no_mangle]
1230 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1231         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1232         crate::c_types::PublicKey::from_rust(&inner_val)
1233 }
1234 /// Used to derive a revocation key for transactions broadcast by counterparty
1235 #[no_mangle]
1236 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1237         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1238 }
1239 /// A payment key to sender for transactions broadcast by counterparty
1240 #[no_mangle]
1241 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1242         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1243         crate::c_types::PublicKey::from_rust(&inner_val)
1244 }
1245 /// A payment key to sender for transactions broadcast by counterparty
1246 #[no_mangle]
1247 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1248         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1249 }
1250 /// Used to derive a payment key to sender for transactions broadcast by sender
1251 #[no_mangle]
1252 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1253         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1254         crate::c_types::PublicKey::from_rust(&inner_val)
1255 }
1256 /// Used to derive a payment key to sender for transactions broadcast by sender
1257 #[no_mangle]
1258 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1259         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1260 }
1261 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1262 #[no_mangle]
1263 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1264         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1265         crate::c_types::PublicKey::from_rust(&inner_val)
1266 }
1267 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1268 #[no_mangle]
1269 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1270         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1271 }
1272 /// The first to-be-broadcast-by-sender transaction's per commitment point
1273 #[no_mangle]
1274 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1275         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1276         crate::c_types::PublicKey::from_rust(&inner_val)
1277 }
1278 /// The first to-be-broadcast-by-sender transaction's per commitment point
1279 #[no_mangle]
1280 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1281         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1282 }
1283 /// The channel type that this channel will represent.
1284 ///
1285 /// If this is `None`, we derive the channel type from the intersection of
1286 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1287 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1288 ///
1289 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1290 #[no_mangle]
1291 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1292         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1293         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 };
1294         local_inner_val
1295 }
1296 /// The channel type that this channel will represent.
1297 ///
1298 /// If this is `None`, we derive the channel type from the intersection of
1299 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1300 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1301 ///
1302 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1303 #[no_mangle]
1304 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1305         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1306         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1307 }
1308 impl Clone for AcceptChannel {
1309         fn clone(&self) -> Self {
1310                 Self {
1311                         inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1312                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1313                         is_owned: true,
1314                 }
1315         }
1316 }
1317 #[allow(unused)]
1318 /// Used only if an object of this type is returned as a trait impl by a method
1319 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1320         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1321 }
1322 #[no_mangle]
1323 /// Creates a copy of the AcceptChannel
1324 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1325         orig.clone()
1326 }
1327 /// Checks if two AcceptChannels contain equal inner contents.
1328 /// This ignores pointers and is_owned flags and looks at the values in fields.
1329 /// Two objects with NULL inner values will be considered "equal" here.
1330 #[no_mangle]
1331 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1332         if a.inner == b.inner { return true; }
1333         if a.inner.is_null() || b.inner.is_null() { return false; }
1334         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1335 }
1336
1337 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
1338 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
1339
1340 /// A [`funding_created`] message to be sent to or received from a peer.
1341 ///
1342 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
1343 #[must_use]
1344 #[repr(C)]
1345 pub struct FundingCreated {
1346         /// A pointer to the opaque Rust object.
1347
1348         /// Nearly everywhere, inner must be non-null, however in places where
1349         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1350         pub inner: *mut nativeFundingCreated,
1351         /// Indicates that this is the only struct which contains the same pointer.
1352
1353         /// Rust functions which take ownership of an object provided via an argument require
1354         /// this to be true and invalidate the object pointed to by inner.
1355         pub is_owned: bool,
1356 }
1357
1358 impl Drop for FundingCreated {
1359         fn drop(&mut self) {
1360                 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
1361                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1362                 }
1363         }
1364 }
1365 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
1366 #[no_mangle]
1367 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
1368 #[allow(unused)]
1369 /// Used only if an object of this type is returned as a trait impl by a method
1370 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
1371         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
1372 }
1373 #[allow(unused)]
1374 impl FundingCreated {
1375         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
1376                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1377         }
1378         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
1379                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1380         }
1381         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1382         pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
1383                 assert!(self.is_owned);
1384                 let ret = ObjOps::untweak_ptr(self.inner);
1385                 self.inner = core::ptr::null_mut();
1386                 ret
1387         }
1388 }
1389 /// A temporary channel ID, until the funding is established
1390 #[no_mangle]
1391 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
1392         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1393         inner_val
1394 }
1395 /// A temporary channel ID, until the funding is established
1396 #[no_mangle]
1397 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1398         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1399 }
1400 /// The funding transaction ID
1401 #[no_mangle]
1402 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
1403         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
1404         inner_val.as_inner()
1405 }
1406 /// The funding transaction ID
1407 #[no_mangle]
1408 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1409         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1410 }
1411 /// The specific output index funding this channel
1412 #[no_mangle]
1413 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
1414         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
1415         *inner_val
1416 }
1417 /// The specific output index funding this channel
1418 #[no_mangle]
1419 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
1420         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
1421 }
1422 /// The signature of the channel initiator (funder) on the initial commitment transaction
1423 #[no_mangle]
1424 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
1425         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1426         crate::c_types::Signature::from_rust(&inner_val)
1427 }
1428 /// The signature of the channel initiator (funder) on the initial commitment transaction
1429 #[no_mangle]
1430 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
1431         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1432 }
1433 /// Constructs a new FundingCreated given each field
1434 #[must_use]
1435 #[no_mangle]
1436 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::Signature) -> FundingCreated {
1437         FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
1438                 temporary_channel_id: temporary_channel_id_arg.data,
1439                 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
1440                 funding_output_index: funding_output_index_arg,
1441                 signature: signature_arg.into_rust(),
1442         }), is_owned: true }
1443 }
1444 impl Clone for FundingCreated {
1445         fn clone(&self) -> Self {
1446                 Self {
1447                         inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
1448                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1449                         is_owned: true,
1450                 }
1451         }
1452 }
1453 #[allow(unused)]
1454 /// Used only if an object of this type is returned as a trait impl by a method
1455 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
1456         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
1457 }
1458 #[no_mangle]
1459 /// Creates a copy of the FundingCreated
1460 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
1461         orig.clone()
1462 }
1463 /// Checks if two FundingCreateds contain equal inner contents.
1464 /// This ignores pointers and is_owned flags and looks at the values in fields.
1465 /// Two objects with NULL inner values will be considered "equal" here.
1466 #[no_mangle]
1467 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
1468         if a.inner == b.inner { return true; }
1469         if a.inner.is_null() || b.inner.is_null() { return false; }
1470         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1471 }
1472
1473 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
1474 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
1475
1476 /// A [`funding_signed`] message to be sent to or received from a peer.
1477 ///
1478 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
1479 #[must_use]
1480 #[repr(C)]
1481 pub struct FundingSigned {
1482         /// A pointer to the opaque Rust object.
1483
1484         /// Nearly everywhere, inner must be non-null, however in places where
1485         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1486         pub inner: *mut nativeFundingSigned,
1487         /// Indicates that this is the only struct which contains the same pointer.
1488
1489         /// Rust functions which take ownership of an object provided via an argument require
1490         /// this to be true and invalidate the object pointed to by inner.
1491         pub is_owned: bool,
1492 }
1493
1494 impl Drop for FundingSigned {
1495         fn drop(&mut self) {
1496                 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
1497                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1498                 }
1499         }
1500 }
1501 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
1502 #[no_mangle]
1503 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
1504 #[allow(unused)]
1505 /// Used only if an object of this type is returned as a trait impl by a method
1506 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1507         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
1508 }
1509 #[allow(unused)]
1510 impl FundingSigned {
1511         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
1512                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1513         }
1514         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
1515                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1516         }
1517         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1518         pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1519                 assert!(self.is_owned);
1520                 let ret = ObjOps::untweak_ptr(self.inner);
1521                 self.inner = core::ptr::null_mut();
1522                 ret
1523         }
1524 }
1525 /// The channel ID
1526 #[no_mangle]
1527 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1528         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1529         inner_val
1530 }
1531 /// The channel ID
1532 #[no_mangle]
1533 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1534         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1535 }
1536 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1537 #[no_mangle]
1538 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1539         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1540         crate::c_types::Signature::from_rust(&inner_val)
1541 }
1542 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1543 #[no_mangle]
1544 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1545         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1546 }
1547 /// Constructs a new FundingSigned given each field
1548 #[must_use]
1549 #[no_mangle]
1550 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1551         FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
1552                 channel_id: channel_id_arg.data,
1553                 signature: signature_arg.into_rust(),
1554         }), is_owned: true }
1555 }
1556 impl Clone for FundingSigned {
1557         fn clone(&self) -> Self {
1558                 Self {
1559                         inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
1560                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1561                         is_owned: true,
1562                 }
1563         }
1564 }
1565 #[allow(unused)]
1566 /// Used only if an object of this type is returned as a trait impl by a method
1567 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1568         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1569 }
1570 #[no_mangle]
1571 /// Creates a copy of the FundingSigned
1572 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1573         orig.clone()
1574 }
1575 /// Checks if two FundingSigneds contain equal inner contents.
1576 /// This ignores pointers and is_owned flags and looks at the values in fields.
1577 /// Two objects with NULL inner values will be considered "equal" here.
1578 #[no_mangle]
1579 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
1580         if a.inner == b.inner { return true; }
1581         if a.inner.is_null() || b.inner.is_null() { return false; }
1582         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1583 }
1584
1585 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
1586 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
1587
1588 /// A [`channel_ready`] message to be sent to or received from a peer.
1589 ///
1590 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
1591 #[must_use]
1592 #[repr(C)]
1593 pub struct ChannelReady {
1594         /// A pointer to the opaque Rust object.
1595
1596         /// Nearly everywhere, inner must be non-null, however in places where
1597         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1598         pub inner: *mut nativeChannelReady,
1599         /// Indicates that this is the only struct which contains the same pointer.
1600
1601         /// Rust functions which take ownership of an object provided via an argument require
1602         /// this to be true and invalidate the object pointed to by inner.
1603         pub is_owned: bool,
1604 }
1605
1606 impl Drop for ChannelReady {
1607         fn drop(&mut self) {
1608                 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
1609                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1610                 }
1611         }
1612 }
1613 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
1614 #[no_mangle]
1615 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
1616 #[allow(unused)]
1617 /// Used only if an object of this type is returned as a trait impl by a method
1618 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
1619         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
1620 }
1621 #[allow(unused)]
1622 impl ChannelReady {
1623         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
1624                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1625         }
1626         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
1627                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1628         }
1629         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1630         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
1631                 assert!(self.is_owned);
1632                 let ret = ObjOps::untweak_ptr(self.inner);
1633                 self.inner = core::ptr::null_mut();
1634                 ret
1635         }
1636 }
1637 /// The channel ID
1638 #[no_mangle]
1639 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
1640         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1641         inner_val
1642 }
1643 /// The channel ID
1644 #[no_mangle]
1645 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
1646         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1647 }
1648 /// The per-commitment point of the second commitment transaction
1649 #[no_mangle]
1650 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
1651         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
1652         crate::c_types::PublicKey::from_rust(&inner_val)
1653 }
1654 /// The per-commitment point of the second commitment transaction
1655 #[no_mangle]
1656 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
1657         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
1658 }
1659 /// If set, provides a `short_channel_id` alias for this channel.
1660 ///
1661 /// The sender will accept payments to be forwarded over this SCID and forward them to this
1662 /// messages' recipient.
1663 #[no_mangle]
1664 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
1665         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
1666         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() }) };
1667         local_inner_val
1668 }
1669 /// If set, provides a `short_channel_id` alias for this channel.
1670 ///
1671 /// The sender will accept payments to be forwarded over this SCID and forward them to this
1672 /// messages' recipient.
1673 #[no_mangle]
1674 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
1675         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1676         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
1677 }
1678 /// Constructs a new ChannelReady given each field
1679 #[must_use]
1680 #[no_mangle]
1681 pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady {
1682         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 };
1683         ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
1684                 channel_id: channel_id_arg.data,
1685                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1686                 short_channel_id_alias: local_short_channel_id_alias_arg,
1687         }), is_owned: true }
1688 }
1689 impl Clone for ChannelReady {
1690         fn clone(&self) -> Self {
1691                 Self {
1692                         inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
1693                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1694                         is_owned: true,
1695                 }
1696         }
1697 }
1698 #[allow(unused)]
1699 /// Used only if an object of this type is returned as a trait impl by a method
1700 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
1701         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void
1702 }
1703 #[no_mangle]
1704 /// Creates a copy of the ChannelReady
1705 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
1706         orig.clone()
1707 }
1708 /// Checks if two ChannelReadys contain equal inner contents.
1709 /// This ignores pointers and is_owned flags and looks at the values in fields.
1710 /// Two objects with NULL inner values will be considered "equal" here.
1711 #[no_mangle]
1712 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
1713         if a.inner == b.inner { return true; }
1714         if a.inner.is_null() || b.inner.is_null() { return false; }
1715         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1716 }
1717
1718 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1719 pub(crate) type nativeShutdown = nativeShutdownImport;
1720
1721 /// A [`shutdown`] message to be sent to or received from a peer.
1722 ///
1723 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
1724 #[must_use]
1725 #[repr(C)]
1726 pub struct Shutdown {
1727         /// A pointer to the opaque Rust object.
1728
1729         /// Nearly everywhere, inner must be non-null, however in places where
1730         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1731         pub inner: *mut nativeShutdown,
1732         /// Indicates that this is the only struct which contains the same pointer.
1733
1734         /// Rust functions which take ownership of an object provided via an argument require
1735         /// this to be true and invalidate the object pointed to by inner.
1736         pub is_owned: bool,
1737 }
1738
1739 impl Drop for Shutdown {
1740         fn drop(&mut self) {
1741                 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
1742                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1743                 }
1744         }
1745 }
1746 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
1747 #[no_mangle]
1748 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
1749 #[allow(unused)]
1750 /// Used only if an object of this type is returned as a trait impl by a method
1751 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1752         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
1753 }
1754 #[allow(unused)]
1755 impl Shutdown {
1756         pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
1757                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1758         }
1759         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
1760                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1761         }
1762         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1763         pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1764                 assert!(self.is_owned);
1765                 let ret = ObjOps::untweak_ptr(self.inner);
1766                 self.inner = core::ptr::null_mut();
1767                 ret
1768         }
1769 }
1770 /// The channel ID
1771 #[no_mangle]
1772 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1773         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1774         inner_val
1775 }
1776 /// The channel ID
1777 #[no_mangle]
1778 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1779         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1780 }
1781 /// The destination of this peer's funds on closing.
1782 ///
1783 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
1784 #[no_mangle]
1785 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1786         let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
1787         crate::c_types::u8slice::from_slice(&inner_val[..])
1788 }
1789 /// The destination of this peer's funds on closing.
1790 ///
1791 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
1792 #[no_mangle]
1793 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1794         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1795 }
1796 /// Constructs a new Shutdown given each field
1797 #[must_use]
1798 #[no_mangle]
1799 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1800         Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
1801                 channel_id: channel_id_arg.data,
1802                 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1803         }), is_owned: true }
1804 }
1805 impl Clone for Shutdown {
1806         fn clone(&self) -> Self {
1807                 Self {
1808                         inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
1809                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1810                         is_owned: true,
1811                 }
1812         }
1813 }
1814 #[allow(unused)]
1815 /// Used only if an object of this type is returned as a trait impl by a method
1816 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1817         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1818 }
1819 #[no_mangle]
1820 /// Creates a copy of the Shutdown
1821 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1822         orig.clone()
1823 }
1824 /// Checks if two Shutdowns contain equal inner contents.
1825 /// This ignores pointers and is_owned flags and looks at the values in fields.
1826 /// Two objects with NULL inner values will be considered "equal" here.
1827 #[no_mangle]
1828 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
1829         if a.inner == b.inner { return true; }
1830         if a.inner.is_null() || b.inner.is_null() { return false; }
1831         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1832 }
1833
1834 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1835 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1836
1837 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1838 ///
1839 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1840 /// to use.
1841 #[must_use]
1842 #[repr(C)]
1843 pub struct ClosingSignedFeeRange {
1844         /// A pointer to the opaque Rust object.
1845
1846         /// Nearly everywhere, inner must be non-null, however in places where
1847         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1848         pub inner: *mut nativeClosingSignedFeeRange,
1849         /// Indicates that this is the only struct which contains the same pointer.
1850
1851         /// Rust functions which take ownership of an object provided via an argument require
1852         /// this to be true and invalidate the object pointed to by inner.
1853         pub is_owned: bool,
1854 }
1855
1856 impl Drop for ClosingSignedFeeRange {
1857         fn drop(&mut self) {
1858                 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1859                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1860                 }
1861         }
1862 }
1863 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1864 #[no_mangle]
1865 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1866 #[allow(unused)]
1867 /// Used only if an object of this type is returned as a trait impl by a method
1868 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1869         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
1870 }
1871 #[allow(unused)]
1872 impl ClosingSignedFeeRange {
1873         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
1874                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1875         }
1876         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
1877                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1878         }
1879         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1880         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1881                 assert!(self.is_owned);
1882                 let ret = ObjOps::untweak_ptr(self.inner);
1883                 self.inner = core::ptr::null_mut();
1884                 ret
1885         }
1886 }
1887 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1888 /// transaction.
1889 #[no_mangle]
1890 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1891         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
1892         *inner_val
1893 }
1894 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1895 /// transaction.
1896 #[no_mangle]
1897 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1898         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
1899 }
1900 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1901 /// transaction.
1902 #[no_mangle]
1903 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1904         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
1905         *inner_val
1906 }
1907 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1908 /// transaction.
1909 #[no_mangle]
1910 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1911         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
1912 }
1913 /// Constructs a new ClosingSignedFeeRange given each field
1914 #[must_use]
1915 #[no_mangle]
1916 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1917         ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
1918                 min_fee_satoshis: min_fee_satoshis_arg,
1919                 max_fee_satoshis: max_fee_satoshis_arg,
1920         }), is_owned: true }
1921 }
1922 impl Clone for ClosingSignedFeeRange {
1923         fn clone(&self) -> Self {
1924                 Self {
1925                         inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
1926                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1927                         is_owned: true,
1928                 }
1929         }
1930 }
1931 #[allow(unused)]
1932 /// Used only if an object of this type is returned as a trait impl by a method
1933 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1934         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1935 }
1936 #[no_mangle]
1937 /// Creates a copy of the ClosingSignedFeeRange
1938 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1939         orig.clone()
1940 }
1941 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
1942 /// This ignores pointers and is_owned flags and looks at the values in fields.
1943 /// Two objects with NULL inner values will be considered "equal" here.
1944 #[no_mangle]
1945 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
1946         if a.inner == b.inner { return true; }
1947         if a.inner.is_null() || b.inner.is_null() { return false; }
1948         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1949 }
1950
1951 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1952 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
1953
1954 /// A [`closing_signed`] message to be sent to or received from a peer.
1955 ///
1956 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
1957 #[must_use]
1958 #[repr(C)]
1959 pub struct ClosingSigned {
1960         /// A pointer to the opaque Rust object.
1961
1962         /// Nearly everywhere, inner must be non-null, however in places where
1963         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1964         pub inner: *mut nativeClosingSigned,
1965         /// Indicates that this is the only struct which contains the same pointer.
1966
1967         /// Rust functions which take ownership of an object provided via an argument require
1968         /// this to be true and invalidate the object pointed to by inner.
1969         pub is_owned: bool,
1970 }
1971
1972 impl Drop for ClosingSigned {
1973         fn drop(&mut self) {
1974                 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1975                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1976                 }
1977         }
1978 }
1979 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1980 #[no_mangle]
1981 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1982 #[allow(unused)]
1983 /// Used only if an object of this type is returned as a trait impl by a method
1984 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1985         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
1986 }
1987 #[allow(unused)]
1988 impl ClosingSigned {
1989         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
1990                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1991         }
1992         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
1993                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1994         }
1995         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1996         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1997                 assert!(self.is_owned);
1998                 let ret = ObjOps::untweak_ptr(self.inner);
1999                 self.inner = core::ptr::null_mut();
2000                 ret
2001         }
2002 }
2003 /// The channel ID
2004 #[no_mangle]
2005 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
2006         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2007         inner_val
2008 }
2009 /// The channel ID
2010 #[no_mangle]
2011 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2012         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2013 }
2014 /// The proposed total fee for the closing transaction
2015 #[no_mangle]
2016 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
2017         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
2018         *inner_val
2019 }
2020 /// The proposed total fee for the closing transaction
2021 #[no_mangle]
2022 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
2023         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
2024 }
2025 /// A signature on the closing transaction
2026 #[no_mangle]
2027 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
2028         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2029         crate::c_types::Signature::from_rust(&inner_val)
2030 }
2031 /// A signature on the closing transaction
2032 #[no_mangle]
2033 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
2034         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2035 }
2036 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
2037 /// nodes.
2038 ///
2039 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2040 #[no_mangle]
2041 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
2042         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
2043         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 };
2044         local_inner_val
2045 }
2046 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
2047 /// nodes.
2048 ///
2049 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
2050 #[no_mangle]
2051 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
2052         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2053         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
2054 }
2055 /// Constructs a new ClosingSigned given each field
2056 #[must_use]
2057 #[no_mangle]
2058 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::Signature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
2059         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()) } }) };
2060         ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
2061                 channel_id: channel_id_arg.data,
2062                 fee_satoshis: fee_satoshis_arg,
2063                 signature: signature_arg.into_rust(),
2064                 fee_range: local_fee_range_arg,
2065         }), is_owned: true }
2066 }
2067 impl Clone for ClosingSigned {
2068         fn clone(&self) -> Self {
2069                 Self {
2070                         inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2071                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2072                         is_owned: true,
2073                 }
2074         }
2075 }
2076 #[allow(unused)]
2077 /// Used only if an object of this type is returned as a trait impl by a method
2078 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2079         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
2080 }
2081 #[no_mangle]
2082 /// Creates a copy of the ClosingSigned
2083 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
2084         orig.clone()
2085 }
2086 /// Checks if two ClosingSigneds contain equal inner contents.
2087 /// This ignores pointers and is_owned flags and looks at the values in fields.
2088 /// Two objects with NULL inner values will be considered "equal" here.
2089 #[no_mangle]
2090 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
2091         if a.inner == b.inner { return true; }
2092         if a.inner.is_null() || b.inner.is_null() { return false; }
2093         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2094 }
2095
2096 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
2097 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
2098
2099 /// An [`update_add_htlc`] message to be sent to or received from a peer.
2100 ///
2101 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
2102 #[must_use]
2103 #[repr(C)]
2104 pub struct UpdateAddHTLC {
2105         /// A pointer to the opaque Rust object.
2106
2107         /// Nearly everywhere, inner must be non-null, however in places where
2108         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2109         pub inner: *mut nativeUpdateAddHTLC,
2110         /// Indicates that this is the only struct which contains the same pointer.
2111
2112         /// Rust functions which take ownership of an object provided via an argument require
2113         /// this to be true and invalidate the object pointed to by inner.
2114         pub is_owned: bool,
2115 }
2116
2117 impl Drop for UpdateAddHTLC {
2118         fn drop(&mut self) {
2119                 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
2120                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2121                 }
2122         }
2123 }
2124 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
2125 #[no_mangle]
2126 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
2127 #[allow(unused)]
2128 /// Used only if an object of this type is returned as a trait impl by a method
2129 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
2130         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
2131 }
2132 #[allow(unused)]
2133 impl UpdateAddHTLC {
2134         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
2135                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2136         }
2137         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
2138                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2139         }
2140         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2141         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
2142                 assert!(self.is_owned);
2143                 let ret = ObjOps::untweak_ptr(self.inner);
2144                 self.inner = core::ptr::null_mut();
2145                 ret
2146         }
2147 }
2148 /// The channel ID
2149 #[no_mangle]
2150 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
2151         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2152         inner_val
2153 }
2154 /// The channel ID
2155 #[no_mangle]
2156 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2157         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2158 }
2159 /// The HTLC ID
2160 #[no_mangle]
2161 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
2162         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2163         *inner_val
2164 }
2165 /// The HTLC ID
2166 #[no_mangle]
2167 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
2168         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2169 }
2170 /// The HTLC value in milli-satoshi
2171 #[no_mangle]
2172 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
2173         let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
2174         *inner_val
2175 }
2176 /// The HTLC value in milli-satoshi
2177 #[no_mangle]
2178 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
2179         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
2180 }
2181 /// The payment hash, the pre-image of which controls HTLC redemption
2182 #[no_mangle]
2183 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
2184         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
2185         &inner_val.0
2186 }
2187 /// The payment hash, the pre-image of which controls HTLC redemption
2188 #[no_mangle]
2189 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2190         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
2191 }
2192 /// The expiry height of the HTLC
2193 #[no_mangle]
2194 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
2195         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
2196         *inner_val
2197 }
2198 /// The expiry height of the HTLC
2199 #[no_mangle]
2200 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
2201         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
2202 }
2203 impl Clone for UpdateAddHTLC {
2204         fn clone(&self) -> Self {
2205                 Self {
2206                         inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2207                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2208                         is_owned: true,
2209                 }
2210         }
2211 }
2212 #[allow(unused)]
2213 /// Used only if an object of this type is returned as a trait impl by a method
2214 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2215         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
2216 }
2217 #[no_mangle]
2218 /// Creates a copy of the UpdateAddHTLC
2219 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
2220         orig.clone()
2221 }
2222 /// Checks if two UpdateAddHTLCs contain equal inner contents.
2223 /// This ignores pointers and is_owned flags and looks at the values in fields.
2224 /// Two objects with NULL inner values will be considered "equal" here.
2225 #[no_mangle]
2226 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
2227         if a.inner == b.inner { return true; }
2228         if a.inner.is_null() || b.inner.is_null() { return false; }
2229         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2230 }
2231
2232 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
2233 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
2234
2235 /// An onion message to be sent to or received from a peer.
2236 ///
2237 #[must_use]
2238 #[repr(C)]
2239 pub struct OnionMessage {
2240         /// A pointer to the opaque Rust object.
2241
2242         /// Nearly everywhere, inner must be non-null, however in places where
2243         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2244         pub inner: *mut nativeOnionMessage,
2245         /// Indicates that this is the only struct which contains the same pointer.
2246
2247         /// Rust functions which take ownership of an object provided via an argument require
2248         /// this to be true and invalidate the object pointed to by inner.
2249         pub is_owned: bool,
2250 }
2251
2252 impl Drop for OnionMessage {
2253         fn drop(&mut self) {
2254                 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
2255                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2256                 }
2257         }
2258 }
2259 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
2260 #[no_mangle]
2261 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
2262 #[allow(unused)]
2263 /// Used only if an object of this type is returned as a trait impl by a method
2264 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
2265         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
2266 }
2267 #[allow(unused)]
2268 impl OnionMessage {
2269         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
2270                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2271         }
2272         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
2273                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2274         }
2275         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2276         pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
2277                 assert!(self.is_owned);
2278                 let ret = ObjOps::untweak_ptr(self.inner);
2279                 self.inner = core::ptr::null_mut();
2280                 ret
2281         }
2282 }
2283 /// Used in decrypting the onion packet's payload.
2284 #[no_mangle]
2285 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
2286         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
2287         crate::c_types::PublicKey::from_rust(&inner_val)
2288 }
2289 /// Used in decrypting the onion packet's payload.
2290 #[no_mangle]
2291 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
2292         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
2293 }
2294 impl Clone for OnionMessage {
2295         fn clone(&self) -> Self {
2296                 Self {
2297                         inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
2298                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2299                         is_owned: true,
2300                 }
2301         }
2302 }
2303 #[allow(unused)]
2304 /// Used only if an object of this type is returned as a trait impl by a method
2305 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
2306         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessage)).clone() })) as *mut c_void
2307 }
2308 #[no_mangle]
2309 /// Creates a copy of the OnionMessage
2310 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
2311         orig.clone()
2312 }
2313 /// Checks if two OnionMessages contain equal inner contents.
2314 /// This ignores pointers and is_owned flags and looks at the values in fields.
2315 /// Two objects with NULL inner values will be considered "equal" here.
2316 #[no_mangle]
2317 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
2318         if a.inner == b.inner { return true; }
2319         if a.inner.is_null() || b.inner.is_null() { return false; }
2320         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2321 }
2322
2323 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
2324 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
2325
2326 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
2327 ///
2328 /// [`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
2329 #[must_use]
2330 #[repr(C)]
2331 pub struct UpdateFulfillHTLC {
2332         /// A pointer to the opaque Rust object.
2333
2334         /// Nearly everywhere, inner must be non-null, however in places where
2335         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2336         pub inner: *mut nativeUpdateFulfillHTLC,
2337         /// Indicates that this is the only struct which contains the same pointer.
2338
2339         /// Rust functions which take ownership of an object provided via an argument require
2340         /// this to be true and invalidate the object pointed to by inner.
2341         pub is_owned: bool,
2342 }
2343
2344 impl Drop for UpdateFulfillHTLC {
2345         fn drop(&mut self) {
2346                 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
2347                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2348                 }
2349         }
2350 }
2351 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
2352 #[no_mangle]
2353 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
2354 #[allow(unused)]
2355 /// Used only if an object of this type is returned as a trait impl by a method
2356 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
2357         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
2358 }
2359 #[allow(unused)]
2360 impl UpdateFulfillHTLC {
2361         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
2362                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2363         }
2364         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
2365                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2366         }
2367         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2368         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
2369                 assert!(self.is_owned);
2370                 let ret = ObjOps::untweak_ptr(self.inner);
2371                 self.inner = core::ptr::null_mut();
2372                 ret
2373         }
2374 }
2375 /// The channel ID
2376 #[no_mangle]
2377 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2378         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2379         inner_val
2380 }
2381 /// The channel ID
2382 #[no_mangle]
2383 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2384         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2385 }
2386 /// The HTLC ID
2387 #[no_mangle]
2388 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
2389         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2390         *inner_val
2391 }
2392 /// The HTLC ID
2393 #[no_mangle]
2394 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
2395         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2396 }
2397 /// The pre-image of the payment hash, allowing HTLC redemption
2398 #[no_mangle]
2399 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2400         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
2401         &inner_val.0
2402 }
2403 /// The pre-image of the payment hash, allowing HTLC redemption
2404 #[no_mangle]
2405 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2406         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
2407 }
2408 /// Constructs a new UpdateFulfillHTLC given each field
2409 #[must_use]
2410 #[no_mangle]
2411 pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC {
2412         UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
2413                 channel_id: channel_id_arg.data,
2414                 htlc_id: htlc_id_arg,
2415                 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
2416         }), is_owned: true }
2417 }
2418 impl Clone for UpdateFulfillHTLC {
2419         fn clone(&self) -> Self {
2420                 Self {
2421                         inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2422                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2423                         is_owned: true,
2424                 }
2425         }
2426 }
2427 #[allow(unused)]
2428 /// Used only if an object of this type is returned as a trait impl by a method
2429 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2430         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
2431 }
2432 #[no_mangle]
2433 /// Creates a copy of the UpdateFulfillHTLC
2434 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
2435         orig.clone()
2436 }
2437 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
2438 /// This ignores pointers and is_owned flags and looks at the values in fields.
2439 /// Two objects with NULL inner values will be considered "equal" here.
2440 #[no_mangle]
2441 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
2442         if a.inner == b.inner { return true; }
2443         if a.inner.is_null() || b.inner.is_null() { return false; }
2444         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2445 }
2446
2447 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
2448 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
2449
2450 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
2451 ///
2452 /// [`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
2453 #[must_use]
2454 #[repr(C)]
2455 pub struct UpdateFailHTLC {
2456         /// A pointer to the opaque Rust object.
2457
2458         /// Nearly everywhere, inner must be non-null, however in places where
2459         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2460         pub inner: *mut nativeUpdateFailHTLC,
2461         /// Indicates that this is the only struct which contains the same pointer.
2462
2463         /// Rust functions which take ownership of an object provided via an argument require
2464         /// this to be true and invalidate the object pointed to by inner.
2465         pub is_owned: bool,
2466 }
2467
2468 impl Drop for UpdateFailHTLC {
2469         fn drop(&mut self) {
2470                 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
2471                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2472                 }
2473         }
2474 }
2475 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
2476 #[no_mangle]
2477 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
2478 #[allow(unused)]
2479 /// Used only if an object of this type is returned as a trait impl by a method
2480 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
2481         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
2482 }
2483 #[allow(unused)]
2484 impl UpdateFailHTLC {
2485         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
2486                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2487         }
2488         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
2489                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2490         }
2491         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2492         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
2493                 assert!(self.is_owned);
2494                 let ret = ObjOps::untweak_ptr(self.inner);
2495                 self.inner = core::ptr::null_mut();
2496                 ret
2497         }
2498 }
2499 /// The channel ID
2500 #[no_mangle]
2501 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
2502         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2503         inner_val
2504 }
2505 /// The channel ID
2506 #[no_mangle]
2507 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2508         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2509 }
2510 /// The HTLC ID
2511 #[no_mangle]
2512 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
2513         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2514         *inner_val
2515 }
2516 /// The HTLC ID
2517 #[no_mangle]
2518 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
2519         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2520 }
2521 impl Clone for UpdateFailHTLC {
2522         fn clone(&self) -> Self {
2523                 Self {
2524                         inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2525                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2526                         is_owned: true,
2527                 }
2528         }
2529 }
2530 #[allow(unused)]
2531 /// Used only if an object of this type is returned as a trait impl by a method
2532 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2533         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
2534 }
2535 #[no_mangle]
2536 /// Creates a copy of the UpdateFailHTLC
2537 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
2538         orig.clone()
2539 }
2540 /// Checks if two UpdateFailHTLCs contain equal inner contents.
2541 /// This ignores pointers and is_owned flags and looks at the values in fields.
2542 /// Two objects with NULL inner values will be considered "equal" here.
2543 #[no_mangle]
2544 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
2545         if a.inner == b.inner { return true; }
2546         if a.inner.is_null() || b.inner.is_null() { return false; }
2547         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2548 }
2549
2550 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
2551 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
2552
2553 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
2554 ///
2555 /// [`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
2556 #[must_use]
2557 #[repr(C)]
2558 pub struct UpdateFailMalformedHTLC {
2559         /// A pointer to the opaque Rust object.
2560
2561         /// Nearly everywhere, inner must be non-null, however in places where
2562         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2563         pub inner: *mut nativeUpdateFailMalformedHTLC,
2564         /// Indicates that this is the only struct which contains the same pointer.
2565
2566         /// Rust functions which take ownership of an object provided via an argument require
2567         /// this to be true and invalidate the object pointed to by inner.
2568         pub is_owned: bool,
2569 }
2570
2571 impl Drop for UpdateFailMalformedHTLC {
2572         fn drop(&mut self) {
2573                 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2574                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2575                 }
2576         }
2577 }
2578 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2579 #[no_mangle]
2580 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2581 #[allow(unused)]
2582 /// Used only if an object of this type is returned as a trait impl by a method
2583 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2584         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
2585 }
2586 #[allow(unused)]
2587 impl UpdateFailMalformedHTLC {
2588         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2589                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2590         }
2591         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2592                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2593         }
2594         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2595         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2596                 assert!(self.is_owned);
2597                 let ret = ObjOps::untweak_ptr(self.inner);
2598                 self.inner = core::ptr::null_mut();
2599                 ret
2600         }
2601 }
2602 /// The channel ID
2603 #[no_mangle]
2604 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2605         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2606         inner_val
2607 }
2608 /// The channel ID
2609 #[no_mangle]
2610 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2611         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2612 }
2613 /// The HTLC ID
2614 #[no_mangle]
2615 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2616         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2617         *inner_val
2618 }
2619 /// The HTLC ID
2620 #[no_mangle]
2621 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2622         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2623 }
2624 /// The failure code
2625 #[no_mangle]
2626 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2627         let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2628         *inner_val
2629 }
2630 /// The failure code
2631 #[no_mangle]
2632 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2633         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2634 }
2635 impl Clone for UpdateFailMalformedHTLC {
2636         fn clone(&self) -> Self {
2637                 Self {
2638                         inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2639                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2640                         is_owned: true,
2641                 }
2642         }
2643 }
2644 #[allow(unused)]
2645 /// Used only if an object of this type is returned as a trait impl by a method
2646 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2647         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2648 }
2649 #[no_mangle]
2650 /// Creates a copy of the UpdateFailMalformedHTLC
2651 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2652         orig.clone()
2653 }
2654 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
2655 /// This ignores pointers and is_owned flags and looks at the values in fields.
2656 /// Two objects with NULL inner values will be considered "equal" here.
2657 #[no_mangle]
2658 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
2659         if a.inner == b.inner { return true; }
2660         if a.inner.is_null() || b.inner.is_null() { return false; }
2661         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2662 }
2663
2664 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2665 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
2666
2667 /// A [`commitment_signed`] message to be sent to or received from a peer.
2668 ///
2669 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
2670 #[must_use]
2671 #[repr(C)]
2672 pub struct CommitmentSigned {
2673         /// A pointer to the opaque Rust object.
2674
2675         /// Nearly everywhere, inner must be non-null, however in places where
2676         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2677         pub inner: *mut nativeCommitmentSigned,
2678         /// Indicates that this is the only struct which contains the same pointer.
2679
2680         /// Rust functions which take ownership of an object provided via an argument require
2681         /// this to be true and invalidate the object pointed to by inner.
2682         pub is_owned: bool,
2683 }
2684
2685 impl Drop for CommitmentSigned {
2686         fn drop(&mut self) {
2687                 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2688                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2689                 }
2690         }
2691 }
2692 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2693 #[no_mangle]
2694 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2695 #[allow(unused)]
2696 /// Used only if an object of this type is returned as a trait impl by a method
2697 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2698         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
2699 }
2700 #[allow(unused)]
2701 impl CommitmentSigned {
2702         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2703                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2704         }
2705         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2706                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2707         }
2708         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2709         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2710                 assert!(self.is_owned);
2711                 let ret = ObjOps::untweak_ptr(self.inner);
2712                 self.inner = core::ptr::null_mut();
2713                 ret
2714         }
2715 }
2716 /// The channel ID
2717 #[no_mangle]
2718 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2719         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2720         inner_val
2721 }
2722 /// The channel ID
2723 #[no_mangle]
2724 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2725         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2726 }
2727 /// A signature on the commitment transaction
2728 #[no_mangle]
2729 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2730         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2731         crate::c_types::Signature::from_rust(&inner_val)
2732 }
2733 /// A signature on the commitment transaction
2734 #[no_mangle]
2735 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2736         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2737 }
2738 /// Signatures on the HTLC transactions
2739 ///
2740 /// Returns a copy of the field.
2741 #[no_mangle]
2742 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_SignatureZ {
2743         let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
2744         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Signature::from_rust(&item) }); };
2745         local_inner_val.into()
2746 }
2747 /// Signatures on the HTLC transactions
2748 #[no_mangle]
2749 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2750         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2751         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2752 }
2753 /// Constructs a new CommitmentSigned given each field
2754 #[must_use]
2755 #[no_mangle]
2756 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature, mut htlc_signatures_arg: crate::c_types::derived::CVec_SignatureZ) -> CommitmentSigned {
2757         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() }); };
2758         CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2759                 channel_id: channel_id_arg.data,
2760                 signature: signature_arg.into_rust(),
2761                 htlc_signatures: local_htlc_signatures_arg,
2762         }), is_owned: true }
2763 }
2764 impl Clone for CommitmentSigned {
2765         fn clone(&self) -> Self {
2766                 Self {
2767                         inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2768                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2769                         is_owned: true,
2770                 }
2771         }
2772 }
2773 #[allow(unused)]
2774 /// Used only if an object of this type is returned as a trait impl by a method
2775 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2776         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2777 }
2778 #[no_mangle]
2779 /// Creates a copy of the CommitmentSigned
2780 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2781         orig.clone()
2782 }
2783 /// Checks if two CommitmentSigneds contain equal inner contents.
2784 /// This ignores pointers and is_owned flags and looks at the values in fields.
2785 /// Two objects with NULL inner values will be considered "equal" here.
2786 #[no_mangle]
2787 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
2788         if a.inner == b.inner { return true; }
2789         if a.inner.is_null() || b.inner.is_null() { return false; }
2790         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2791 }
2792
2793 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2794 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
2795
2796 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
2797 ///
2798 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
2799 #[must_use]
2800 #[repr(C)]
2801 pub struct RevokeAndACK {
2802         /// A pointer to the opaque Rust object.
2803
2804         /// Nearly everywhere, inner must be non-null, however in places where
2805         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2806         pub inner: *mut nativeRevokeAndACK,
2807         /// Indicates that this is the only struct which contains the same pointer.
2808
2809         /// Rust functions which take ownership of an object provided via an argument require
2810         /// this to be true and invalidate the object pointed to by inner.
2811         pub is_owned: bool,
2812 }
2813
2814 impl Drop for RevokeAndACK {
2815         fn drop(&mut self) {
2816                 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2817                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2818                 }
2819         }
2820 }
2821 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2822 #[no_mangle]
2823 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2824 #[allow(unused)]
2825 /// Used only if an object of this type is returned as a trait impl by a method
2826 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2827         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
2828 }
2829 #[allow(unused)]
2830 impl RevokeAndACK {
2831         pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2832                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2833         }
2834         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2835                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2836         }
2837         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2838         pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2839                 assert!(self.is_owned);
2840                 let ret = ObjOps::untweak_ptr(self.inner);
2841                 self.inner = core::ptr::null_mut();
2842                 ret
2843         }
2844 }
2845 /// The channel ID
2846 #[no_mangle]
2847 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2848         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2849         inner_val
2850 }
2851 /// The channel ID
2852 #[no_mangle]
2853 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2854         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2855 }
2856 /// The secret corresponding to the per-commitment point
2857 #[no_mangle]
2858 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2859         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2860         inner_val
2861 }
2862 /// The secret corresponding to the per-commitment point
2863 #[no_mangle]
2864 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2865         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2866 }
2867 /// The next sender-broadcast commitment transaction's per-commitment point
2868 #[no_mangle]
2869 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2870         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2871         crate::c_types::PublicKey::from_rust(&inner_val)
2872 }
2873 /// The next sender-broadcast commitment transaction's per-commitment point
2874 #[no_mangle]
2875 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2876         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2877 }
2878 /// Constructs a new RevokeAndACK given each field
2879 #[must_use]
2880 #[no_mangle]
2881 pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK {
2882         RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2883                 channel_id: channel_id_arg.data,
2884                 per_commitment_secret: per_commitment_secret_arg.data,
2885                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2886         }), is_owned: true }
2887 }
2888 impl Clone for RevokeAndACK {
2889         fn clone(&self) -> Self {
2890                 Self {
2891                         inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
2892                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2893                         is_owned: true,
2894                 }
2895         }
2896 }
2897 #[allow(unused)]
2898 /// Used only if an object of this type is returned as a trait impl by a method
2899 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2900         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2901 }
2902 #[no_mangle]
2903 /// Creates a copy of the RevokeAndACK
2904 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2905         orig.clone()
2906 }
2907 /// Checks if two RevokeAndACKs contain equal inner contents.
2908 /// This ignores pointers and is_owned flags and looks at the values in fields.
2909 /// Two objects with NULL inner values will be considered "equal" here.
2910 #[no_mangle]
2911 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
2912         if a.inner == b.inner { return true; }
2913         if a.inner.is_null() || b.inner.is_null() { return false; }
2914         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2915 }
2916
2917 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2918 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
2919
2920 /// An [`update_fee`] message to be sent to or received from a peer
2921 ///
2922 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
2923 #[must_use]
2924 #[repr(C)]
2925 pub struct UpdateFee {
2926         /// A pointer to the opaque Rust object.
2927
2928         /// Nearly everywhere, inner must be non-null, however in places where
2929         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2930         pub inner: *mut nativeUpdateFee,
2931         /// Indicates that this is the only struct which contains the same pointer.
2932
2933         /// Rust functions which take ownership of an object provided via an argument require
2934         /// this to be true and invalidate the object pointed to by inner.
2935         pub is_owned: bool,
2936 }
2937
2938 impl Drop for UpdateFee {
2939         fn drop(&mut self) {
2940                 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2941                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2942                 }
2943         }
2944 }
2945 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2946 #[no_mangle]
2947 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2948 #[allow(unused)]
2949 /// Used only if an object of this type is returned as a trait impl by a method
2950 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2951         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
2952 }
2953 #[allow(unused)]
2954 impl UpdateFee {
2955         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2956                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2957         }
2958         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2959                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2960         }
2961         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2962         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2963                 assert!(self.is_owned);
2964                 let ret = ObjOps::untweak_ptr(self.inner);
2965                 self.inner = core::ptr::null_mut();
2966                 ret
2967         }
2968 }
2969 /// The channel ID
2970 #[no_mangle]
2971 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2972         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2973         inner_val
2974 }
2975 /// The channel ID
2976 #[no_mangle]
2977 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2978         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2979 }
2980 /// Fee rate per 1000-weight of the transaction
2981 #[no_mangle]
2982 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2983         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2984         *inner_val
2985 }
2986 /// Fee rate per 1000-weight of the transaction
2987 #[no_mangle]
2988 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2989         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2990 }
2991 /// Constructs a new UpdateFee given each field
2992 #[must_use]
2993 #[no_mangle]
2994 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2995         UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2996                 channel_id: channel_id_arg.data,
2997                 feerate_per_kw: feerate_per_kw_arg,
2998         }), is_owned: true }
2999 }
3000 impl Clone for UpdateFee {
3001         fn clone(&self) -> Self {
3002                 Self {
3003                         inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
3004                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3005                         is_owned: true,
3006                 }
3007         }
3008 }
3009 #[allow(unused)]
3010 /// Used only if an object of this type is returned as a trait impl by a method
3011 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
3012         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
3013 }
3014 #[no_mangle]
3015 /// Creates a copy of the UpdateFee
3016 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
3017         orig.clone()
3018 }
3019 /// Checks if two UpdateFees contain equal inner contents.
3020 /// This ignores pointers and is_owned flags and looks at the values in fields.
3021 /// Two objects with NULL inner values will be considered "equal" here.
3022 #[no_mangle]
3023 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
3024         if a.inner == b.inner { return true; }
3025         if a.inner.is_null() || b.inner.is_null() { return false; }
3026         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3027 }
3028
3029 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
3030 pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport;
3031
3032 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
3033 ///
3034 /// This is used to convince the recipient that the channel is at a certain commitment
3035 /// number even if they lost that data due to a local failure. Of course, the peer may lie
3036 /// and even later commitments may have been revoked.
3037 #[must_use]
3038 #[repr(C)]
3039 pub struct DataLossProtect {
3040         /// A pointer to the opaque Rust object.
3041
3042         /// Nearly everywhere, inner must be non-null, however in places where
3043         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3044         pub inner: *mut nativeDataLossProtect,
3045         /// Indicates that this is the only struct which contains the same pointer.
3046
3047         /// Rust functions which take ownership of an object provided via an argument require
3048         /// this to be true and invalidate the object pointed to by inner.
3049         pub is_owned: bool,
3050 }
3051
3052 impl Drop for DataLossProtect {
3053         fn drop(&mut self) {
3054                 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
3055                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3056                 }
3057         }
3058 }
3059 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
3060 #[no_mangle]
3061 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
3062 #[allow(unused)]
3063 /// Used only if an object of this type is returned as a trait impl by a method
3064 pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
3065         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDataLossProtect) };
3066 }
3067 #[allow(unused)]
3068 impl DataLossProtect {
3069         pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
3070                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3071         }
3072         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
3073                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3074         }
3075         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3076         pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
3077                 assert!(self.is_owned);
3078                 let ret = ObjOps::untweak_ptr(self.inner);
3079                 self.inner = core::ptr::null_mut();
3080                 ret
3081         }
3082 }
3083 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
3084 /// belonging to the recipient
3085 #[no_mangle]
3086 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
3087         let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
3088         inner_val
3089 }
3090 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
3091 /// belonging to the recipient
3092 #[no_mangle]
3093 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
3094         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
3095 }
3096 /// The sender's per-commitment point for their current commitment transaction
3097 #[no_mangle]
3098 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
3099         let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
3100         crate::c_types::PublicKey::from_rust(&inner_val)
3101 }
3102 /// The sender's per-commitment point for their current commitment transaction
3103 #[no_mangle]
3104 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
3105         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
3106 }
3107 /// Constructs a new DataLossProtect given each field
3108 #[must_use]
3109 #[no_mangle]
3110 pub extern "C" fn DataLossProtect_new(mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey) -> DataLossProtect {
3111         DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
3112                 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
3113                 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
3114         }), is_owned: true }
3115 }
3116 impl Clone for DataLossProtect {
3117         fn clone(&self) -> Self {
3118                 Self {
3119                         inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else {
3120                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3121                         is_owned: true,
3122                 }
3123         }
3124 }
3125 #[allow(unused)]
3126 /// Used only if an object of this type is returned as a trait impl by a method
3127 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
3128         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
3129 }
3130 #[no_mangle]
3131 /// Creates a copy of the DataLossProtect
3132 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
3133         orig.clone()
3134 }
3135 /// Checks if two DataLossProtects contain equal inner contents.
3136 /// This ignores pointers and is_owned flags and looks at the values in fields.
3137 /// Two objects with NULL inner values will be considered "equal" here.
3138 #[no_mangle]
3139 pub extern "C" fn DataLossProtect_eq(a: &DataLossProtect, b: &DataLossProtect) -> bool {
3140         if a.inner == b.inner { return true; }
3141         if a.inner.is_null() || b.inner.is_null() { return false; }
3142         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3143 }
3144
3145 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
3146 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
3147
3148 /// A [`channel_reestablish`] message to be sent to or received from a peer.
3149 ///
3150 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
3151 #[must_use]
3152 #[repr(C)]
3153 pub struct ChannelReestablish {
3154         /// A pointer to the opaque Rust object.
3155
3156         /// Nearly everywhere, inner must be non-null, however in places where
3157         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3158         pub inner: *mut nativeChannelReestablish,
3159         /// Indicates that this is the only struct which contains the same pointer.
3160
3161         /// Rust functions which take ownership of an object provided via an argument require
3162         /// this to be true and invalidate the object pointed to by inner.
3163         pub is_owned: bool,
3164 }
3165
3166 impl Drop for ChannelReestablish {
3167         fn drop(&mut self) {
3168                 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
3169                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3170                 }
3171         }
3172 }
3173 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
3174 #[no_mangle]
3175 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
3176 #[allow(unused)]
3177 /// Used only if an object of this type is returned as a trait impl by a method
3178 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
3179         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
3180 }
3181 #[allow(unused)]
3182 impl ChannelReestablish {
3183         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
3184                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3185         }
3186         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
3187                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3188         }
3189         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3190         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
3191                 assert!(self.is_owned);
3192                 let ret = ObjOps::untweak_ptr(self.inner);
3193                 self.inner = core::ptr::null_mut();
3194                 ret
3195         }
3196 }
3197 /// The channel ID
3198 #[no_mangle]
3199 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
3200         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3201         inner_val
3202 }
3203 /// The channel ID
3204 #[no_mangle]
3205 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
3206         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3207 }
3208 /// The next commitment number for the sender
3209 #[no_mangle]
3210 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
3211         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
3212         *inner_val
3213 }
3214 /// The next commitment number for the sender
3215 #[no_mangle]
3216 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
3217         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
3218 }
3219 /// The next commitment number for the recipient
3220 #[no_mangle]
3221 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
3222         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
3223         *inner_val
3224 }
3225 /// The next commitment number for the recipient
3226 #[no_mangle]
3227 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
3228         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
3229 }
3230 impl Clone for ChannelReestablish {
3231         fn clone(&self) -> Self {
3232                 Self {
3233                         inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
3234                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3235                         is_owned: true,
3236                 }
3237         }
3238 }
3239 #[allow(unused)]
3240 /// Used only if an object of this type is returned as a trait impl by a method
3241 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
3242         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
3243 }
3244 #[no_mangle]
3245 /// Creates a copy of the ChannelReestablish
3246 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
3247         orig.clone()
3248 }
3249 /// Checks if two ChannelReestablishs contain equal inner contents.
3250 /// This ignores pointers and is_owned flags and looks at the values in fields.
3251 /// Two objects with NULL inner values will be considered "equal" here.
3252 #[no_mangle]
3253 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
3254         if a.inner == b.inner { return true; }
3255         if a.inner.is_null() || b.inner.is_null() { return false; }
3256         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3257 }
3258
3259 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
3260 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
3261
3262 /// An [`announcement_signatures`] message to be sent to or received from a peer.
3263 ///
3264 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
3265 #[must_use]
3266 #[repr(C)]
3267 pub struct AnnouncementSignatures {
3268         /// A pointer to the opaque Rust object.
3269
3270         /// Nearly everywhere, inner must be non-null, however in places where
3271         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3272         pub inner: *mut nativeAnnouncementSignatures,
3273         /// Indicates that this is the only struct which contains the same pointer.
3274
3275         /// Rust functions which take ownership of an object provided via an argument require
3276         /// this to be true and invalidate the object pointed to by inner.
3277         pub is_owned: bool,
3278 }
3279
3280 impl Drop for AnnouncementSignatures {
3281         fn drop(&mut self) {
3282                 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
3283                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3284                 }
3285         }
3286 }
3287 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
3288 #[no_mangle]
3289 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
3290 #[allow(unused)]
3291 /// Used only if an object of this type is returned as a trait impl by a method
3292 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
3293         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
3294 }
3295 #[allow(unused)]
3296 impl AnnouncementSignatures {
3297         pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
3298                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3299         }
3300         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
3301                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3302         }
3303         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3304         pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
3305                 assert!(self.is_owned);
3306                 let ret = ObjOps::untweak_ptr(self.inner);
3307                 self.inner = core::ptr::null_mut();
3308                 ret
3309         }
3310 }
3311 /// The channel ID
3312 #[no_mangle]
3313 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
3314         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3315         inner_val
3316 }
3317 /// The channel ID
3318 #[no_mangle]
3319 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3320         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3321 }
3322 /// The short channel ID
3323 #[no_mangle]
3324 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
3325         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3326         *inner_val
3327 }
3328 /// The short channel ID
3329 #[no_mangle]
3330 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
3331         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3332 }
3333 /// A signature by the node key
3334 #[no_mangle]
3335 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
3336         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
3337         crate::c_types::Signature::from_rust(&inner_val)
3338 }
3339 /// A signature by the node key
3340 #[no_mangle]
3341 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
3342         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
3343 }
3344 /// A signature by the funding key
3345 #[no_mangle]
3346 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
3347         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
3348         crate::c_types::Signature::from_rust(&inner_val)
3349 }
3350 /// A signature by the funding key
3351 #[no_mangle]
3352 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
3353         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
3354 }
3355 /// Constructs a new AnnouncementSignatures given each field
3356 #[must_use]
3357 #[no_mangle]
3358 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::Signature, mut bitcoin_signature_arg: crate::c_types::Signature) -> AnnouncementSignatures {
3359         AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
3360                 channel_id: channel_id_arg.data,
3361                 short_channel_id: short_channel_id_arg,
3362                 node_signature: node_signature_arg.into_rust(),
3363                 bitcoin_signature: bitcoin_signature_arg.into_rust(),
3364         }), is_owned: true }
3365 }
3366 impl Clone for AnnouncementSignatures {
3367         fn clone(&self) -> Self {
3368                 Self {
3369                         inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3370                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3371                         is_owned: true,
3372                 }
3373         }
3374 }
3375 #[allow(unused)]
3376 /// Used only if an object of this type is returned as a trait impl by a method
3377 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3378         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
3379 }
3380 #[no_mangle]
3381 /// Creates a copy of the AnnouncementSignatures
3382 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
3383         orig.clone()
3384 }
3385 /// Checks if two AnnouncementSignaturess contain equal inner contents.
3386 /// This ignores pointers and is_owned flags and looks at the values in fields.
3387 /// Two objects with NULL inner values will be considered "equal" here.
3388 #[no_mangle]
3389 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
3390         if a.inner == b.inner { return true; }
3391         if a.inner.is_null() || b.inner.is_null() { return false; }
3392         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3393 }
3394 /// An address which can be used to connect to a remote peer.
3395 #[derive(Clone)]
3396 #[must_use]
3397 #[repr(C)]
3398 pub enum NetAddress {
3399         /// An IPv4 address/port on which the peer is listening.
3400         IPv4 {
3401                 /// The 4-byte IPv4 address
3402                 addr: crate::c_types::FourBytes,
3403                 /// The port on which the node is listening
3404                 port: u16,
3405         },
3406         /// An IPv6 address/port on which the peer is listening.
3407         IPv6 {
3408                 /// The 16-byte IPv6 address
3409                 addr: crate::c_types::SixteenBytes,
3410                 /// The port on which the node is listening
3411                 port: u16,
3412         },
3413         /// An old-style Tor onion address/port on which the peer is listening.
3414         ///
3415         /// This field is deprecated and the Tor network generally no longer supports V2 Onion
3416         /// addresses. Thus, the details are not parsed here.
3417         OnionV2(
3418                 crate::c_types::TwelveBytes),
3419         /// A new-style Tor onion address/port on which the peer is listening.
3420         ///
3421         /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
3422         /// wrap as base32 and append \".onion\".
3423         OnionV3 {
3424                 /// The ed25519 long-term public key of the peer
3425                 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
3426                 /// The checksum of the pubkey and version, as included in the onion address
3427                 checksum: u16,
3428                 /// The version byte, as defined by the Tor Onion v3 spec.
3429                 version: u8,
3430                 /// The port on which the node is listening
3431                 port: u16,
3432         },
3433         /// A hostname/port on which the peer is listening.
3434         Hostname {
3435                 /// The hostname on which the node is listening.
3436                 hostname: crate::lightning::util::ser::Hostname,
3437                 /// The port on which the node is listening.
3438                 port: u16,
3439         },
3440 }
3441 use lightning::ln::msgs::NetAddress as NetAddressImport;
3442 pub(crate) type nativeNetAddress = NetAddressImport;
3443
3444 impl NetAddress {
3445         #[allow(unused)]
3446         pub(crate) fn to_native(&self) -> nativeNetAddress {
3447                 match self {
3448                         NetAddress::IPv4 {ref addr, ref port, } => {
3449                                 let mut addr_nonref = Clone::clone(addr);
3450                                 let mut port_nonref = Clone::clone(port);
3451                                 nativeNetAddress::IPv4 {
3452                                         addr: addr_nonref.data,
3453                                         port: port_nonref,
3454                                 }
3455                         },
3456                         NetAddress::IPv6 {ref addr, ref port, } => {
3457                                 let mut addr_nonref = Clone::clone(addr);
3458                                 let mut port_nonref = Clone::clone(port);
3459                                 nativeNetAddress::IPv6 {
3460                                         addr: addr_nonref.data,
3461                                         port: port_nonref,
3462                                 }
3463                         },
3464                         NetAddress::OnionV2 (ref a, ) => {
3465                                 let mut a_nonref = Clone::clone(a);
3466                                 nativeNetAddress::OnionV2 (
3467                                         a_nonref.data,
3468                                 )
3469                         },
3470                         NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3471                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
3472                                 let mut checksum_nonref = Clone::clone(checksum);
3473                                 let mut version_nonref = Clone::clone(version);
3474                                 let mut port_nonref = Clone::clone(port);
3475                                 nativeNetAddress::OnionV3 {
3476                                         ed25519_pubkey: ed25519_pubkey_nonref.data,
3477                                         checksum: checksum_nonref,
3478                                         version: version_nonref,
3479                                         port: port_nonref,
3480                                 }
3481                         },
3482                         NetAddress::Hostname {ref hostname, ref port, } => {
3483                                 let mut hostname_nonref = Clone::clone(hostname);
3484                                 let mut port_nonref = Clone::clone(port);
3485                                 nativeNetAddress::Hostname {
3486                                         hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
3487                                         port: port_nonref,
3488                                 }
3489                         },
3490                 }
3491         }
3492         #[allow(unused)]
3493         pub(crate) fn into_native(self) -> nativeNetAddress {
3494                 match self {
3495                         NetAddress::IPv4 {mut addr, mut port, } => {
3496                                 nativeNetAddress::IPv4 {
3497                                         addr: addr.data,
3498                                         port: port,
3499                                 }
3500                         },
3501                         NetAddress::IPv6 {mut addr, mut port, } => {
3502                                 nativeNetAddress::IPv6 {
3503                                         addr: addr.data,
3504                                         port: port,
3505                                 }
3506                         },
3507                         NetAddress::OnionV2 (mut a, ) => {
3508                                 nativeNetAddress::OnionV2 (
3509                                         a.data,
3510                                 )
3511                         },
3512                         NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3513                                 nativeNetAddress::OnionV3 {
3514                                         ed25519_pubkey: ed25519_pubkey.data,
3515                                         checksum: checksum,
3516                                         version: version,
3517                                         port: port,
3518                                 }
3519                         },
3520                         NetAddress::Hostname {mut hostname, mut port, } => {
3521                                 nativeNetAddress::Hostname {
3522                                         hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
3523                                         port: port,
3524                                 }
3525                         },
3526                 }
3527         }
3528         #[allow(unused)]
3529         pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
3530                 match native {
3531                         nativeNetAddress::IPv4 {ref addr, ref port, } => {
3532                                 let mut addr_nonref = Clone::clone(addr);
3533                                 let mut port_nonref = Clone::clone(port);
3534                                 NetAddress::IPv4 {
3535                                         addr: crate::c_types::FourBytes { data: addr_nonref },
3536                                         port: port_nonref,
3537                                 }
3538                         },
3539                         nativeNetAddress::IPv6 {ref addr, ref port, } => {
3540                                 let mut addr_nonref = Clone::clone(addr);
3541                                 let mut port_nonref = Clone::clone(port);
3542                                 NetAddress::IPv6 {
3543                                         addr: crate::c_types::SixteenBytes { data: addr_nonref },
3544                                         port: port_nonref,
3545                                 }
3546                         },
3547                         nativeNetAddress::OnionV2 (ref a, ) => {
3548                                 let mut a_nonref = Clone::clone(a);
3549                                 NetAddress::OnionV2 (
3550                                         crate::c_types::TwelveBytes { data: a_nonref },
3551                                 )
3552                         },
3553                         nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3554                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
3555                                 let mut checksum_nonref = Clone::clone(checksum);
3556                                 let mut version_nonref = Clone::clone(version);
3557                                 let mut port_nonref = Clone::clone(port);
3558                                 NetAddress::OnionV3 {
3559                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
3560                                         checksum: checksum_nonref,
3561                                         version: version_nonref,
3562                                         port: port_nonref,
3563                                 }
3564                         },
3565                         nativeNetAddress::Hostname {ref hostname, ref port, } => {
3566                                 let mut hostname_nonref = Clone::clone(hostname);
3567                                 let mut port_nonref = Clone::clone(port);
3568                                 NetAddress::Hostname {
3569                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
3570                                         port: port_nonref,
3571                                 }
3572                         },
3573                 }
3574         }
3575         #[allow(unused)]
3576         pub(crate) fn native_into(native: nativeNetAddress) -> Self {
3577                 match native {
3578                         nativeNetAddress::IPv4 {mut addr, mut port, } => {
3579                                 NetAddress::IPv4 {
3580                                         addr: crate::c_types::FourBytes { data: addr },
3581                                         port: port,
3582                                 }
3583                         },
3584                         nativeNetAddress::IPv6 {mut addr, mut port, } => {
3585                                 NetAddress::IPv6 {
3586                                         addr: crate::c_types::SixteenBytes { data: addr },
3587                                         port: port,
3588                                 }
3589                         },
3590                         nativeNetAddress::OnionV2 (mut a, ) => {
3591                                 NetAddress::OnionV2 (
3592                                         crate::c_types::TwelveBytes { data: a },
3593                                 )
3594                         },
3595                         nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3596                                 NetAddress::OnionV3 {
3597                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
3598                                         checksum: checksum,
3599                                         version: version,
3600                                         port: port,
3601                                 }
3602                         },
3603                         nativeNetAddress::Hostname {mut hostname, mut port, } => {
3604                                 NetAddress::Hostname {
3605                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
3606                                         port: port,
3607                                 }
3608                         },
3609                 }
3610         }
3611 }
3612 /// Frees any resources used by the NetAddress
3613 #[no_mangle]
3614 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
3615 /// Creates a copy of the NetAddress
3616 #[no_mangle]
3617 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
3618         orig.clone()
3619 }
3620 #[no_mangle]
3621 /// Utility method to constructs a new IPv4-variant NetAddress
3622 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
3623         NetAddress::IPv4 {
3624                 addr,
3625                 port,
3626         }
3627 }
3628 #[no_mangle]
3629 /// Utility method to constructs a new IPv6-variant NetAddress
3630 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
3631         NetAddress::IPv6 {
3632                 addr,
3633                 port,
3634         }
3635 }
3636 #[no_mangle]
3637 /// Utility method to constructs a new OnionV2-variant NetAddress
3638 pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
3639         NetAddress::OnionV2(a, )
3640 }
3641 #[no_mangle]
3642 /// Utility method to constructs a new OnionV3-variant NetAddress
3643 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
3644         NetAddress::OnionV3 {
3645                 ed25519_pubkey,
3646                 checksum,
3647                 version,
3648                 port,
3649         }
3650 }
3651 #[no_mangle]
3652 /// Utility method to constructs a new Hostname-variant NetAddress
3653 pub extern "C" fn NetAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> NetAddress {
3654         NetAddress::Hostname {
3655                 hostname,
3656                 port,
3657         }
3658 }
3659 /// Checks if two NetAddresss contain equal inner contents.
3660 /// This ignores pointers and is_owned flags and looks at the values in fields.
3661 #[no_mangle]
3662 pub extern "C" fn NetAddress_eq(a: &NetAddress, b: &NetAddress) -> bool {
3663         if &a.to_native() == &b.to_native() { true } else { false }
3664 }
3665 #[no_mangle]
3666 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
3667 pub extern "C" fn NetAddress_write(obj: &crate::lightning::ln::msgs::NetAddress) -> crate::c_types::derived::CVec_u8Z {
3668         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
3669 }
3670 #[no_mangle]
3671 /// Read a NetAddress from a byte array, created by NetAddress_write
3672 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
3673         let res: Result<lightning::ln::msgs::NetAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3674         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
3675         local_res
3676 }
3677 /// Represents the set of gossip messages that require a signature from a node's identity key.
3678 #[derive(Clone)]
3679 #[must_use]
3680 #[repr(C)]
3681 pub enum UnsignedGossipMessage {
3682         /// An unsigned channel announcement.
3683         ChannelAnnouncement(
3684                 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
3685         /// An unsigned channel update.
3686         ChannelUpdate(
3687                 crate::lightning::ln::msgs::UnsignedChannelUpdate),
3688         /// An unsigned node announcement.
3689         NodeAnnouncement(
3690                 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
3691 }
3692 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
3693 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
3694
3695 impl UnsignedGossipMessage {
3696         #[allow(unused)]
3697         pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
3698                 match self {
3699                         UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
3700                                 let mut a_nonref = Clone::clone(a);
3701                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
3702                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
3703                                 )
3704                         },
3705                         UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
3706                                 let mut a_nonref = Clone::clone(a);
3707                                 nativeUnsignedGossipMessage::ChannelUpdate (
3708                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
3709                                 )
3710                         },
3711                         UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
3712                                 let mut a_nonref = Clone::clone(a);
3713                                 nativeUnsignedGossipMessage::NodeAnnouncement (
3714                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
3715                                 )
3716                         },
3717                 }
3718         }
3719         #[allow(unused)]
3720         pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
3721                 match self {
3722                         UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
3723                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
3724                                         *unsafe { Box::from_raw(a.take_inner()) },
3725                                 )
3726                         },
3727                         UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
3728                                 nativeUnsignedGossipMessage::ChannelUpdate (
3729                                         *unsafe { Box::from_raw(a.take_inner()) },
3730                                 )
3731                         },
3732                         UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
3733                                 nativeUnsignedGossipMessage::NodeAnnouncement (
3734                                         *unsafe { Box::from_raw(a.take_inner()) },
3735                                 )
3736                         },
3737                 }
3738         }
3739         #[allow(unused)]
3740         pub(crate) fn from_native(native: &nativeUnsignedGossipMessage) -> Self {
3741                 match native {
3742                         nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
3743                                 let mut a_nonref = Clone::clone(a);
3744                                 UnsignedGossipMessage::ChannelAnnouncement (
3745                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
3746                                 )
3747                         },
3748                         nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
3749                                 let mut a_nonref = Clone::clone(a);
3750                                 UnsignedGossipMessage::ChannelUpdate (
3751                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
3752                                 )
3753                         },
3754                         nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
3755                                 let mut a_nonref = Clone::clone(a);
3756                                 UnsignedGossipMessage::NodeAnnouncement (
3757                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
3758                                 )
3759                         },
3760                 }
3761         }
3762         #[allow(unused)]
3763         pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
3764                 match native {
3765                         nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
3766                                 UnsignedGossipMessage::ChannelAnnouncement (
3767                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
3768                                 )
3769                         },
3770                         nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
3771                                 UnsignedGossipMessage::ChannelUpdate (
3772                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
3773                                 )
3774                         },
3775                         nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
3776                                 UnsignedGossipMessage::NodeAnnouncement (
3777                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
3778                                 )
3779                         },
3780                 }
3781         }
3782 }
3783 /// Frees any resources used by the UnsignedGossipMessage
3784 #[no_mangle]
3785 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
3786 /// Creates a copy of the UnsignedGossipMessage
3787 #[no_mangle]
3788 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
3789         orig.clone()
3790 }
3791 #[no_mangle]
3792 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
3793 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
3794         UnsignedGossipMessage::ChannelAnnouncement(a, )
3795 }
3796 #[no_mangle]
3797 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
3798 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
3799         UnsignedGossipMessage::ChannelUpdate(a, )
3800 }
3801 #[no_mangle]
3802 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
3803 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
3804         UnsignedGossipMessage::NodeAnnouncement(a, )
3805 }
3806 #[no_mangle]
3807 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
3808 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
3809         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
3810 }
3811
3812 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
3813 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
3814
3815 /// The unsigned part of a [`node_announcement`] message.
3816 ///
3817 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
3818 #[must_use]
3819 #[repr(C)]
3820 pub struct UnsignedNodeAnnouncement {
3821         /// A pointer to the opaque Rust object.
3822
3823         /// Nearly everywhere, inner must be non-null, however in places where
3824         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3825         pub inner: *mut nativeUnsignedNodeAnnouncement,
3826         /// Indicates that this is the only struct which contains the same pointer.
3827
3828         /// Rust functions which take ownership of an object provided via an argument require
3829         /// this to be true and invalidate the object pointed to by inner.
3830         pub is_owned: bool,
3831 }
3832
3833 impl Drop for UnsignedNodeAnnouncement {
3834         fn drop(&mut self) {
3835                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3836                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3837                 }
3838         }
3839 }
3840 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3841 #[no_mangle]
3842 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3843 #[allow(unused)]
3844 /// Used only if an object of this type is returned as a trait impl by a method
3845 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3846         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
3847 }
3848 #[allow(unused)]
3849 impl UnsignedNodeAnnouncement {
3850         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3851                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3852         }
3853         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3854                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3855         }
3856         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3857         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3858                 assert!(self.is_owned);
3859                 let ret = ObjOps::untweak_ptr(self.inner);
3860                 self.inner = core::ptr::null_mut();
3861                 ret
3862         }
3863 }
3864 /// The advertised features
3865 #[no_mangle]
3866 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3867         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3868         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 }
3869 }
3870 /// The advertised features
3871 #[no_mangle]
3872 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3873         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3874 }
3875 /// A strictly monotonic announcement counter, with gaps allowed
3876 #[no_mangle]
3877 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3878         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3879         *inner_val
3880 }
3881 /// A strictly monotonic announcement counter, with gaps allowed
3882 #[no_mangle]
3883 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3884         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3885 }
3886 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
3887 /// to this node).
3888 #[no_mangle]
3889 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
3890         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3891         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 }
3892 }
3893 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
3894 /// to this node).
3895 #[no_mangle]
3896 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
3897         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
3898 }
3899 /// An RGB color for UI purposes
3900 #[no_mangle]
3901 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3902         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3903         inner_val
3904 }
3905 /// An RGB color for UI purposes
3906 #[no_mangle]
3907 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3908         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3909 }
3910 /// An alias, for UI purposes.
3911 ///
3912 /// This should be sanitized before use. There is no guarantee of uniqueness.
3913 #[no_mangle]
3914 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3915         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3916         inner_val
3917 }
3918 /// An alias, for UI purposes.
3919 ///
3920 /// This should be sanitized before use. There is no guarantee of uniqueness.
3921 #[no_mangle]
3922 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3923         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3924 }
3925 /// List of addresses on which this node is reachable
3926 ///
3927 /// Returns a copy of the field.
3928 #[no_mangle]
3929 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_NetAddressZ {
3930         let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
3931         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::NetAddress::native_into(item) }); };
3932         local_inner_val.into()
3933 }
3934 /// List of addresses on which this node is reachable
3935 #[no_mangle]
3936 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3937         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3938         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3939 }
3940 impl Clone for UnsignedNodeAnnouncement {
3941         fn clone(&self) -> Self {
3942                 Self {
3943                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3944                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3945                         is_owned: true,
3946                 }
3947         }
3948 }
3949 #[allow(unused)]
3950 /// Used only if an object of this type is returned as a trait impl by a method
3951 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3952         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3953 }
3954 #[no_mangle]
3955 /// Creates a copy of the UnsignedNodeAnnouncement
3956 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3957         orig.clone()
3958 }
3959 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
3960 /// This ignores pointers and is_owned flags and looks at the values in fields.
3961 /// Two objects with NULL inner values will be considered "equal" here.
3962 #[no_mangle]
3963 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
3964         if a.inner == b.inner { return true; }
3965         if a.inner.is_null() || b.inner.is_null() { return false; }
3966         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3967 }
3968
3969 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3970 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3971
3972 /// A [`node_announcement`] message to be sent to or received from a peer.
3973 ///
3974 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
3975 #[must_use]
3976 #[repr(C)]
3977 pub struct NodeAnnouncement {
3978         /// A pointer to the opaque Rust object.
3979
3980         /// Nearly everywhere, inner must be non-null, however in places where
3981         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3982         pub inner: *mut nativeNodeAnnouncement,
3983         /// Indicates that this is the only struct which contains the same pointer.
3984
3985         /// Rust functions which take ownership of an object provided via an argument require
3986         /// this to be true and invalidate the object pointed to by inner.
3987         pub is_owned: bool,
3988 }
3989
3990 impl Drop for NodeAnnouncement {
3991         fn drop(&mut self) {
3992                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3993                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3994                 }
3995         }
3996 }
3997 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3998 #[no_mangle]
3999 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
4000 #[allow(unused)]
4001 /// Used only if an object of this type is returned as a trait impl by a method
4002 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
4003         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
4004 }
4005 #[allow(unused)]
4006 impl NodeAnnouncement {
4007         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
4008                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4009         }
4010         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
4011                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4012         }
4013         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4014         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
4015                 assert!(self.is_owned);
4016                 let ret = ObjOps::untweak_ptr(self.inner);
4017                 self.inner = core::ptr::null_mut();
4018                 ret
4019         }
4020 }
4021 /// The signature by the node key
4022 #[no_mangle]
4023 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
4024         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4025         crate::c_types::Signature::from_rust(&inner_val)
4026 }
4027 /// The signature by the node key
4028 #[no_mangle]
4029 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
4030         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4031 }
4032 /// The actual content of the announcement
4033 #[no_mangle]
4034 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
4035         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
4036         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 }
4037 }
4038 /// The actual content of the announcement
4039 #[no_mangle]
4040 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
4041         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
4042 }
4043 /// Constructs a new NodeAnnouncement given each field
4044 #[must_use]
4045 #[no_mangle]
4046 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
4047         NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
4048                 signature: signature_arg.into_rust(),
4049                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
4050         }), is_owned: true }
4051 }
4052 impl Clone for NodeAnnouncement {
4053         fn clone(&self) -> Self {
4054                 Self {
4055                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
4056                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4057                         is_owned: true,
4058                 }
4059         }
4060 }
4061 #[allow(unused)]
4062 /// Used only if an object of this type is returned as a trait impl by a method
4063 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
4064         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
4065 }
4066 #[no_mangle]
4067 /// Creates a copy of the NodeAnnouncement
4068 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
4069         orig.clone()
4070 }
4071 /// Checks if two NodeAnnouncements contain equal inner contents.
4072 /// This ignores pointers and is_owned flags and looks at the values in fields.
4073 /// Two objects with NULL inner values will be considered "equal" here.
4074 #[no_mangle]
4075 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
4076         if a.inner == b.inner { return true; }
4077         if a.inner.is_null() || b.inner.is_null() { return false; }
4078         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4079 }
4080
4081 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
4082 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
4083
4084 /// The unsigned part of a [`channel_announcement`] message.
4085 ///
4086 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
4087 #[must_use]
4088 #[repr(C)]
4089 pub struct UnsignedChannelAnnouncement {
4090         /// A pointer to the opaque Rust object.
4091
4092         /// Nearly everywhere, inner must be non-null, however in places where
4093         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4094         pub inner: *mut nativeUnsignedChannelAnnouncement,
4095         /// Indicates that this is the only struct which contains the same pointer.
4096
4097         /// Rust functions which take ownership of an object provided via an argument require
4098         /// this to be true and invalidate the object pointed to by inner.
4099         pub is_owned: bool,
4100 }
4101
4102 impl Drop for UnsignedChannelAnnouncement {
4103         fn drop(&mut self) {
4104                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
4105                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4106                 }
4107         }
4108 }
4109 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
4110 #[no_mangle]
4111 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
4112 #[allow(unused)]
4113 /// Used only if an object of this type is returned as a trait impl by a method
4114 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
4115         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
4116 }
4117 #[allow(unused)]
4118 impl UnsignedChannelAnnouncement {
4119         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
4120                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4121         }
4122         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
4123                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4124         }
4125         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4126         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
4127                 assert!(self.is_owned);
4128                 let ret = ObjOps::untweak_ptr(self.inner);
4129                 self.inner = core::ptr::null_mut();
4130                 ret
4131         }
4132 }
4133 /// The advertised channel features
4134 #[no_mangle]
4135 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
4136         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
4137         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 }
4138 }
4139 /// The advertised channel features
4140 #[no_mangle]
4141 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
4142         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
4143 }
4144 /// The genesis hash of the blockchain where the channel is to be opened
4145 #[no_mangle]
4146 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
4147         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4148         inner_val.as_inner()
4149 }
4150 /// The genesis hash of the blockchain where the channel is to be opened
4151 #[no_mangle]
4152 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
4153         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4154 }
4155 /// The short channel ID
4156 #[no_mangle]
4157 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
4158         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
4159         *inner_val
4160 }
4161 /// The short channel ID
4162 #[no_mangle]
4163 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
4164         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
4165 }
4166 /// One of the two `node_id`s which are endpoints of this channel
4167 #[no_mangle]
4168 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
4169         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
4170         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 }
4171 }
4172 /// One of the two `node_id`s which are endpoints of this channel
4173 #[no_mangle]
4174 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
4175         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
4176 }
4177 /// The other of the two `node_id`s which are endpoints of this channel
4178 #[no_mangle]
4179 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
4180         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
4181         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 }
4182 }
4183 /// The other of the two `node_id`s which are endpoints of this channel
4184 #[no_mangle]
4185 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
4186         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
4187 }
4188 /// The funding key for the first node
4189 #[no_mangle]
4190 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
4191         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
4192         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 }
4193 }
4194 /// The funding key for the first node
4195 #[no_mangle]
4196 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
4197         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
4198 }
4199 /// The funding key for the second node
4200 #[no_mangle]
4201 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
4202         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
4203         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 }
4204 }
4205 /// The funding key for the second node
4206 #[no_mangle]
4207 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
4208         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
4209 }
4210 impl Clone for UnsignedChannelAnnouncement {
4211         fn clone(&self) -> Self {
4212                 Self {
4213                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
4214                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4215                         is_owned: true,
4216                 }
4217         }
4218 }
4219 #[allow(unused)]
4220 /// Used only if an object of this type is returned as a trait impl by a method
4221 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
4222         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
4223 }
4224 #[no_mangle]
4225 /// Creates a copy of the UnsignedChannelAnnouncement
4226 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
4227         orig.clone()
4228 }
4229 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
4230 /// This ignores pointers and is_owned flags and looks at the values in fields.
4231 /// Two objects with NULL inner values will be considered "equal" here.
4232 #[no_mangle]
4233 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
4234         if a.inner == b.inner { return true; }
4235         if a.inner.is_null() || b.inner.is_null() { return false; }
4236         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4237 }
4238
4239 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
4240 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
4241
4242 /// A [`channel_announcement`] message to be sent to or received from a peer.
4243 ///
4244 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
4245 #[must_use]
4246 #[repr(C)]
4247 pub struct ChannelAnnouncement {
4248         /// A pointer to the opaque Rust object.
4249
4250         /// Nearly everywhere, inner must be non-null, however in places where
4251         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4252         pub inner: *mut nativeChannelAnnouncement,
4253         /// Indicates that this is the only struct which contains the same pointer.
4254
4255         /// Rust functions which take ownership of an object provided via an argument require
4256         /// this to be true and invalidate the object pointed to by inner.
4257         pub is_owned: bool,
4258 }
4259
4260 impl Drop for ChannelAnnouncement {
4261         fn drop(&mut self) {
4262                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
4263                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4264                 }
4265         }
4266 }
4267 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
4268 #[no_mangle]
4269 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
4270 #[allow(unused)]
4271 /// Used only if an object of this type is returned as a trait impl by a method
4272 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
4273         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
4274 }
4275 #[allow(unused)]
4276 impl ChannelAnnouncement {
4277         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
4278                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4279         }
4280         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
4281                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4282         }
4283         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4284         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
4285                 assert!(self.is_owned);
4286                 let ret = ObjOps::untweak_ptr(self.inner);
4287                 self.inner = core::ptr::null_mut();
4288                 ret
4289         }
4290 }
4291 /// Authentication of the announcement by the first public node
4292 #[no_mangle]
4293 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4294         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
4295         crate::c_types::Signature::from_rust(&inner_val)
4296 }
4297 /// Authentication of the announcement by the first public node
4298 #[no_mangle]
4299 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4300         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
4301 }
4302 /// Authentication of the announcement by the second public node
4303 #[no_mangle]
4304 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4305         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
4306         crate::c_types::Signature::from_rust(&inner_val)
4307 }
4308 /// Authentication of the announcement by the second public node
4309 #[no_mangle]
4310 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4311         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
4312 }
4313 /// Proof of funding UTXO ownership by the first public node
4314 #[no_mangle]
4315 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4316         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
4317         crate::c_types::Signature::from_rust(&inner_val)
4318 }
4319 /// Proof of funding UTXO ownership by the first public node
4320 #[no_mangle]
4321 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4322         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
4323 }
4324 /// Proof of funding UTXO ownership by the second public node
4325 #[no_mangle]
4326 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4327         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
4328         crate::c_types::Signature::from_rust(&inner_val)
4329 }
4330 /// Proof of funding UTXO ownership by the second public node
4331 #[no_mangle]
4332 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4333         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
4334 }
4335 /// The actual announcement
4336 #[no_mangle]
4337 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
4338         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
4339         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 }
4340 }
4341 /// The actual announcement
4342 #[no_mangle]
4343 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
4344         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
4345 }
4346 /// Constructs a new ChannelAnnouncement given each field
4347 #[must_use]
4348 #[no_mangle]
4349 pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_types::Signature, mut node_signature_2_arg: crate::c_types::Signature, mut bitcoin_signature_1_arg: crate::c_types::Signature, mut bitcoin_signature_2_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
4350         ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
4351                 node_signature_1: node_signature_1_arg.into_rust(),
4352                 node_signature_2: node_signature_2_arg.into_rust(),
4353                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
4354                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
4355                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
4356         }), is_owned: true }
4357 }
4358 impl Clone for ChannelAnnouncement {
4359         fn clone(&self) -> Self {
4360                 Self {
4361                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
4362                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4363                         is_owned: true,
4364                 }
4365         }
4366 }
4367 #[allow(unused)]
4368 /// Used only if an object of this type is returned as a trait impl by a method
4369 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
4370         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
4371 }
4372 #[no_mangle]
4373 /// Creates a copy of the ChannelAnnouncement
4374 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
4375         orig.clone()
4376 }
4377 /// Checks if two ChannelAnnouncements contain equal inner contents.
4378 /// This ignores pointers and is_owned flags and looks at the values in fields.
4379 /// Two objects with NULL inner values will be considered "equal" here.
4380 #[no_mangle]
4381 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
4382         if a.inner == b.inner { return true; }
4383         if a.inner.is_null() || b.inner.is_null() { return false; }
4384         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4385 }
4386
4387 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
4388 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
4389
4390 /// The unsigned part of a [`channel_update`] message.
4391 ///
4392 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
4393 #[must_use]
4394 #[repr(C)]
4395 pub struct UnsignedChannelUpdate {
4396         /// A pointer to the opaque Rust object.
4397
4398         /// Nearly everywhere, inner must be non-null, however in places where
4399         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4400         pub inner: *mut nativeUnsignedChannelUpdate,
4401         /// Indicates that this is the only struct which contains the same pointer.
4402
4403         /// Rust functions which take ownership of an object provided via an argument require
4404         /// this to be true and invalidate the object pointed to by inner.
4405         pub is_owned: bool,
4406 }
4407
4408 impl Drop for UnsignedChannelUpdate {
4409         fn drop(&mut self) {
4410                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
4411                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4412                 }
4413         }
4414 }
4415 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
4416 #[no_mangle]
4417 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
4418 #[allow(unused)]
4419 /// Used only if an object of this type is returned as a trait impl by a method
4420 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
4421         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
4422 }
4423 #[allow(unused)]
4424 impl UnsignedChannelUpdate {
4425         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
4426                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4427         }
4428         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
4429                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4430         }
4431         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4432         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
4433                 assert!(self.is_owned);
4434                 let ret = ObjOps::untweak_ptr(self.inner);
4435                 self.inner = core::ptr::null_mut();
4436                 ret
4437         }
4438 }
4439 /// The genesis hash of the blockchain where the channel is to be opened
4440 #[no_mangle]
4441 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
4442         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4443         inner_val.as_inner()
4444 }
4445 /// The genesis hash of the blockchain where the channel is to be opened
4446 #[no_mangle]
4447 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
4448         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4449 }
4450 /// The short channel ID
4451 #[no_mangle]
4452 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
4453         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
4454         *inner_val
4455 }
4456 /// The short channel ID
4457 #[no_mangle]
4458 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
4459         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
4460 }
4461 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
4462 #[no_mangle]
4463 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
4464         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
4465         *inner_val
4466 }
4467 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
4468 #[no_mangle]
4469 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
4470         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
4471 }
4472 /// Channel flags
4473 #[no_mangle]
4474 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
4475         let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
4476         *inner_val
4477 }
4478 /// Channel flags
4479 #[no_mangle]
4480 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
4481         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
4482 }
4483 /// The number of blocks such that if:
4484 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
4485 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
4486 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
4487 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
4488 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
4489 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
4490 /// constructing the route.
4491 #[no_mangle]
4492 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
4493         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
4494         *inner_val
4495 }
4496 /// The number of blocks such that if:
4497 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
4498 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
4499 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
4500 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
4501 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
4502 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
4503 /// constructing the route.
4504 #[no_mangle]
4505 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
4506         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
4507 }
4508 /// The minimum HTLC size incoming to sender, in milli-satoshi
4509 #[no_mangle]
4510 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
4511         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
4512         *inner_val
4513 }
4514 /// The minimum HTLC size incoming to sender, in milli-satoshi
4515 #[no_mangle]
4516 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
4517         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
4518 }
4519 /// The maximum HTLC value incoming to sender, in milli-satoshi.
4520 ///
4521 /// This used to be optional.
4522 #[no_mangle]
4523 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
4524         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
4525         *inner_val
4526 }
4527 /// The maximum HTLC value incoming to sender, in milli-satoshi.
4528 ///
4529 /// This used to be optional.
4530 #[no_mangle]
4531 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
4532         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
4533 }
4534 /// The base HTLC fee charged by sender, in milli-satoshi
4535 #[no_mangle]
4536 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
4537         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
4538         *inner_val
4539 }
4540 /// The base HTLC fee charged by sender, in milli-satoshi
4541 #[no_mangle]
4542 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
4543         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
4544 }
4545 /// The amount to fee multiplier, in micro-satoshi
4546 #[no_mangle]
4547 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
4548         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
4549         *inner_val
4550 }
4551 /// The amount to fee multiplier, in micro-satoshi
4552 #[no_mangle]
4553 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
4554         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
4555 }
4556 /// Excess data which was signed as a part of the message which we do not (yet) understand how
4557 /// to decode.
4558 ///
4559 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
4560 ///
4561 /// Returns a copy of the field.
4562 #[no_mangle]
4563 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4564         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
4565         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4566         local_inner_val.into()
4567 }
4568 /// Excess data which was signed as a part of the message which we do not (yet) understand how
4569 /// to decode.
4570 ///
4571 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
4572 #[no_mangle]
4573 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
4574         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4575         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
4576 }
4577 /// Constructs a new UnsignedChannelUpdate given each field
4578 #[must_use]
4579 #[no_mangle]
4580 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 {
4581         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
4582         UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
4583                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4584                 short_channel_id: short_channel_id_arg,
4585                 timestamp: timestamp_arg,
4586                 flags: flags_arg,
4587                 cltv_expiry_delta: cltv_expiry_delta_arg,
4588                 htlc_minimum_msat: htlc_minimum_msat_arg,
4589                 htlc_maximum_msat: htlc_maximum_msat_arg,
4590                 fee_base_msat: fee_base_msat_arg,
4591                 fee_proportional_millionths: fee_proportional_millionths_arg,
4592                 excess_data: local_excess_data_arg,
4593         }), is_owned: true }
4594 }
4595 impl Clone for UnsignedChannelUpdate {
4596         fn clone(&self) -> Self {
4597                 Self {
4598                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4599                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4600                         is_owned: true,
4601                 }
4602         }
4603 }
4604 #[allow(unused)]
4605 /// Used only if an object of this type is returned as a trait impl by a method
4606 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4607         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
4608 }
4609 #[no_mangle]
4610 /// Creates a copy of the UnsignedChannelUpdate
4611 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
4612         orig.clone()
4613 }
4614 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
4615 /// This ignores pointers and is_owned flags and looks at the values in fields.
4616 /// Two objects with NULL inner values will be considered "equal" here.
4617 #[no_mangle]
4618 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
4619         if a.inner == b.inner { return true; }
4620         if a.inner.is_null() || b.inner.is_null() { return false; }
4621         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4622 }
4623
4624 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
4625 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
4626
4627 /// A [`channel_update`] message to be sent to or received from a peer.
4628 ///
4629 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
4630 #[must_use]
4631 #[repr(C)]
4632 pub struct ChannelUpdate {
4633         /// A pointer to the opaque Rust object.
4634
4635         /// Nearly everywhere, inner must be non-null, however in places where
4636         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4637         pub inner: *mut nativeChannelUpdate,
4638         /// Indicates that this is the only struct which contains the same pointer.
4639
4640         /// Rust functions which take ownership of an object provided via an argument require
4641         /// this to be true and invalidate the object pointed to by inner.
4642         pub is_owned: bool,
4643 }
4644
4645 impl Drop for ChannelUpdate {
4646         fn drop(&mut self) {
4647                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
4648                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4649                 }
4650         }
4651 }
4652 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
4653 #[no_mangle]
4654 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
4655 #[allow(unused)]
4656 /// Used only if an object of this type is returned as a trait impl by a method
4657 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
4658         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
4659 }
4660 #[allow(unused)]
4661 impl ChannelUpdate {
4662         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
4663                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4664         }
4665         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
4666                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4667         }
4668         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4669         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
4670                 assert!(self.is_owned);
4671                 let ret = ObjOps::untweak_ptr(self.inner);
4672                 self.inner = core::ptr::null_mut();
4673                 ret
4674         }
4675 }
4676 /// A signature of the channel update
4677 #[no_mangle]
4678 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
4679         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4680         crate::c_types::Signature::from_rust(&inner_val)
4681 }
4682 /// A signature of the channel update
4683 #[no_mangle]
4684 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
4685         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4686 }
4687 /// The actual channel update
4688 #[no_mangle]
4689 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
4690         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
4691         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 }
4692 }
4693 /// The actual channel update
4694 #[no_mangle]
4695 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
4696         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
4697 }
4698 /// Constructs a new ChannelUpdate given each field
4699 #[must_use]
4700 #[no_mangle]
4701 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
4702         ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
4703                 signature: signature_arg.into_rust(),
4704                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
4705         }), is_owned: true }
4706 }
4707 impl Clone for ChannelUpdate {
4708         fn clone(&self) -> Self {
4709                 Self {
4710                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4711                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4712                         is_owned: true,
4713                 }
4714         }
4715 }
4716 #[allow(unused)]
4717 /// Used only if an object of this type is returned as a trait impl by a method
4718 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4719         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
4720 }
4721 #[no_mangle]
4722 /// Creates a copy of the ChannelUpdate
4723 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
4724         orig.clone()
4725 }
4726 /// Checks if two ChannelUpdates contain equal inner contents.
4727 /// This ignores pointers and is_owned flags and looks at the values in fields.
4728 /// Two objects with NULL inner values will be considered "equal" here.
4729 #[no_mangle]
4730 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
4731         if a.inner == b.inner { return true; }
4732         if a.inner.is_null() || b.inner.is_null() { return false; }
4733         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4734 }
4735
4736 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
4737 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
4738
4739 /// A [`query_channel_range`] message is used to query a peer for channel
4740 /// UTXOs in a range of blocks. The recipient of a query makes a best
4741 /// effort to reply to the query using one or more [`ReplyChannelRange`]
4742 /// messages.
4743 ///
4744 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
4745 #[must_use]
4746 #[repr(C)]
4747 pub struct QueryChannelRange {
4748         /// A pointer to the opaque Rust object.
4749
4750         /// Nearly everywhere, inner must be non-null, however in places where
4751         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4752         pub inner: *mut nativeQueryChannelRange,
4753         /// Indicates that this is the only struct which contains the same pointer.
4754
4755         /// Rust functions which take ownership of an object provided via an argument require
4756         /// this to be true and invalidate the object pointed to by inner.
4757         pub is_owned: bool,
4758 }
4759
4760 impl Drop for QueryChannelRange {
4761         fn drop(&mut self) {
4762                 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
4763                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4764                 }
4765         }
4766 }
4767 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
4768 #[no_mangle]
4769 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
4770 #[allow(unused)]
4771 /// Used only if an object of this type is returned as a trait impl by a method
4772 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
4773         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
4774 }
4775 #[allow(unused)]
4776 impl QueryChannelRange {
4777         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
4778                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4779         }
4780         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
4781                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4782         }
4783         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4784         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
4785                 assert!(self.is_owned);
4786                 let ret = ObjOps::untweak_ptr(self.inner);
4787                 self.inner = core::ptr::null_mut();
4788                 ret
4789         }
4790 }
4791 /// The genesis hash of the blockchain being queried
4792 #[no_mangle]
4793 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
4794         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4795         inner_val.as_inner()
4796 }
4797 /// The genesis hash of the blockchain being queried
4798 #[no_mangle]
4799 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4800         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4801 }
4802 /// The height of the first block for the channel UTXOs being queried
4803 #[no_mangle]
4804 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
4805         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4806         *inner_val
4807 }
4808 /// The height of the first block for the channel UTXOs being queried
4809 #[no_mangle]
4810 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
4811         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4812 }
4813 /// The number of blocks to include in the query results
4814 #[no_mangle]
4815 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
4816         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4817         *inner_val
4818 }
4819 /// The number of blocks to include in the query results
4820 #[no_mangle]
4821 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
4822         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4823 }
4824 /// Constructs a new QueryChannelRange given each field
4825 #[must_use]
4826 #[no_mangle]
4827 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 {
4828         QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
4829                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4830                 first_blocknum: first_blocknum_arg,
4831                 number_of_blocks: number_of_blocks_arg,
4832         }), is_owned: true }
4833 }
4834 impl Clone for QueryChannelRange {
4835         fn clone(&self) -> Self {
4836                 Self {
4837                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4838                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4839                         is_owned: true,
4840                 }
4841         }
4842 }
4843 #[allow(unused)]
4844 /// Used only if an object of this type is returned as a trait impl by a method
4845 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4846         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
4847 }
4848 #[no_mangle]
4849 /// Creates a copy of the QueryChannelRange
4850 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
4851         orig.clone()
4852 }
4853 /// Checks if two QueryChannelRanges contain equal inner contents.
4854 /// This ignores pointers and is_owned flags and looks at the values in fields.
4855 /// Two objects with NULL inner values will be considered "equal" here.
4856 #[no_mangle]
4857 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
4858         if a.inner == b.inner { return true; }
4859         if a.inner.is_null() || b.inner.is_null() { return false; }
4860         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4861 }
4862
4863 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
4864 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
4865
4866 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
4867 /// message.
4868 ///
4869 /// Multiple `reply_channel_range` messages can be sent in reply
4870 /// to a single [`QueryChannelRange`] message. The query recipient makes a
4871 /// best effort to respond based on their local network view which may
4872 /// not be a perfect view of the network. The `short_channel_id`s in the
4873 /// reply are encoded. We only support `encoding_type=0` uncompressed
4874 /// serialization and do not support `encoding_type=1` zlib serialization.
4875 ///
4876 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
4877 #[must_use]
4878 #[repr(C)]
4879 pub struct ReplyChannelRange {
4880         /// A pointer to the opaque Rust object.
4881
4882         /// Nearly everywhere, inner must be non-null, however in places where
4883         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4884         pub inner: *mut nativeReplyChannelRange,
4885         /// Indicates that this is the only struct which contains the same pointer.
4886
4887         /// Rust functions which take ownership of an object provided via an argument require
4888         /// this to be true and invalidate the object pointed to by inner.
4889         pub is_owned: bool,
4890 }
4891
4892 impl Drop for ReplyChannelRange {
4893         fn drop(&mut self) {
4894                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
4895                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4896                 }
4897         }
4898 }
4899 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
4900 #[no_mangle]
4901 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
4902 #[allow(unused)]
4903 /// Used only if an object of this type is returned as a trait impl by a method
4904 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
4905         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
4906 }
4907 #[allow(unused)]
4908 impl ReplyChannelRange {
4909         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
4910                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4911         }
4912         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
4913                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4914         }
4915         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4916         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
4917                 assert!(self.is_owned);
4918                 let ret = ObjOps::untweak_ptr(self.inner);
4919                 self.inner = core::ptr::null_mut();
4920                 ret
4921         }
4922 }
4923 /// The genesis hash of the blockchain being queried
4924 #[no_mangle]
4925 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
4926         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4927         inner_val.as_inner()
4928 }
4929 /// The genesis hash of the blockchain being queried
4930 #[no_mangle]
4931 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4932         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4933 }
4934 /// The height of the first block in the range of the reply
4935 #[no_mangle]
4936 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
4937         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4938         *inner_val
4939 }
4940 /// The height of the first block in the range of the reply
4941 #[no_mangle]
4942 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4943         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4944 }
4945 /// The number of blocks included in the range of the reply
4946 #[no_mangle]
4947 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
4948         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4949         *inner_val
4950 }
4951 /// The number of blocks included in the range of the reply
4952 #[no_mangle]
4953 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4954         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4955 }
4956 /// True when this is the final reply for a query
4957 #[no_mangle]
4958 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
4959         let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
4960         *inner_val
4961 }
4962 /// True when this is the final reply for a query
4963 #[no_mangle]
4964 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4965         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4966 }
4967 /// The `short_channel_id`s in the channel range
4968 ///
4969 /// Returns a copy of the field.
4970 #[no_mangle]
4971 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
4972         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
4973         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4974         local_inner_val.into()
4975 }
4976 /// The `short_channel_id`s in the channel range
4977 #[no_mangle]
4978 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4979         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4980         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4981 }
4982 /// Constructs a new ReplyChannelRange given each field
4983 #[must_use]
4984 #[no_mangle]
4985 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 {
4986         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 }); };
4987         ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4988                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4989                 first_blocknum: first_blocknum_arg,
4990                 number_of_blocks: number_of_blocks_arg,
4991                 sync_complete: sync_complete_arg,
4992                 short_channel_ids: local_short_channel_ids_arg,
4993         }), is_owned: true }
4994 }
4995 impl Clone for ReplyChannelRange {
4996         fn clone(&self) -> Self {
4997                 Self {
4998                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4999                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5000                         is_owned: true,
5001                 }
5002         }
5003 }
5004 #[allow(unused)]
5005 /// Used only if an object of this type is returned as a trait impl by a method
5006 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
5007         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
5008 }
5009 #[no_mangle]
5010 /// Creates a copy of the ReplyChannelRange
5011 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
5012         orig.clone()
5013 }
5014 /// Checks if two ReplyChannelRanges contain equal inner contents.
5015 /// This ignores pointers and is_owned flags and looks at the values in fields.
5016 /// Two objects with NULL inner values will be considered "equal" here.
5017 #[no_mangle]
5018 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
5019         if a.inner == b.inner { return true; }
5020         if a.inner.is_null() || b.inner.is_null() { return false; }
5021         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5022 }
5023
5024 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
5025 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
5026
5027 /// A [`query_short_channel_ids`] message is used to query a peer for
5028 /// routing gossip messages related to one or more `short_channel_id`s.
5029 ///
5030 /// The query recipient will reply with the latest, if available,
5031 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
5032 /// it maintains for the requested `short_channel_id`s followed by a
5033 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
5034 /// this query are encoded. We only support `encoding_type=0` uncompressed
5035 /// serialization and do not support `encoding_type=1` zlib serialization.
5036 ///
5037 /// [`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
5038 #[must_use]
5039 #[repr(C)]
5040 pub struct QueryShortChannelIds {
5041         /// A pointer to the opaque Rust object.
5042
5043         /// Nearly everywhere, inner must be non-null, however in places where
5044         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5045         pub inner: *mut nativeQueryShortChannelIds,
5046         /// Indicates that this is the only struct which contains the same pointer.
5047
5048         /// Rust functions which take ownership of an object provided via an argument require
5049         /// this to be true and invalidate the object pointed to by inner.
5050         pub is_owned: bool,
5051 }
5052
5053 impl Drop for QueryShortChannelIds {
5054         fn drop(&mut self) {
5055                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
5056                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5057                 }
5058         }
5059 }
5060 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
5061 #[no_mangle]
5062 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
5063 #[allow(unused)]
5064 /// Used only if an object of this type is returned as a trait impl by a method
5065 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
5066         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
5067 }
5068 #[allow(unused)]
5069 impl QueryShortChannelIds {
5070         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
5071                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5072         }
5073         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
5074                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5075         }
5076         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5077         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
5078                 assert!(self.is_owned);
5079                 let ret = ObjOps::untweak_ptr(self.inner);
5080                 self.inner = core::ptr::null_mut();
5081                 ret
5082         }
5083 }
5084 /// The genesis hash of the blockchain being queried
5085 #[no_mangle]
5086 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
5087         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
5088         inner_val.as_inner()
5089 }
5090 /// The genesis hash of the blockchain being queried
5091 #[no_mangle]
5092 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
5093         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
5094 }
5095 /// The short_channel_ids that are being queried
5096 ///
5097 /// Returns a copy of the field.
5098 #[no_mangle]
5099 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
5100         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
5101         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
5102         local_inner_val.into()
5103 }
5104 /// The short_channel_ids that are being queried
5105 #[no_mangle]
5106 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
5107         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
5108         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
5109 }
5110 /// Constructs a new QueryShortChannelIds given each field
5111 #[must_use]
5112 #[no_mangle]
5113 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 {
5114         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 }); };
5115         QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
5116                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
5117                 short_channel_ids: local_short_channel_ids_arg,
5118         }), is_owned: true }
5119 }
5120 impl Clone for QueryShortChannelIds {
5121         fn clone(&self) -> Self {
5122                 Self {
5123                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
5124                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5125                         is_owned: true,
5126                 }
5127         }
5128 }
5129 #[allow(unused)]
5130 /// Used only if an object of this type is returned as a trait impl by a method
5131 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
5132         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
5133 }
5134 #[no_mangle]
5135 /// Creates a copy of the QueryShortChannelIds
5136 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
5137         orig.clone()
5138 }
5139 /// Checks if two QueryShortChannelIdss contain equal inner contents.
5140 /// This ignores pointers and is_owned flags and looks at the values in fields.
5141 /// Two objects with NULL inner values will be considered "equal" here.
5142 #[no_mangle]
5143 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
5144         if a.inner == b.inner { return true; }
5145         if a.inner.is_null() || b.inner.is_null() { return false; }
5146         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5147 }
5148
5149 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
5150 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
5151
5152 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
5153 /// message. The query recipient makes a best
5154 /// effort to respond based on their local network view which may not be
5155 /// a perfect view of the network.
5156 ///
5157 /// [`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
5158 #[must_use]
5159 #[repr(C)]
5160 pub struct ReplyShortChannelIdsEnd {
5161         /// A pointer to the opaque Rust object.
5162
5163         /// Nearly everywhere, inner must be non-null, however in places where
5164         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5165         pub inner: *mut nativeReplyShortChannelIdsEnd,
5166         /// Indicates that this is the only struct which contains the same pointer.
5167
5168         /// Rust functions which take ownership of an object provided via an argument require
5169         /// this to be true and invalidate the object pointed to by inner.
5170         pub is_owned: bool,
5171 }
5172
5173 impl Drop for ReplyShortChannelIdsEnd {
5174         fn drop(&mut self) {
5175                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
5176                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5177                 }
5178         }
5179 }
5180 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
5181 #[no_mangle]
5182 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
5183 #[allow(unused)]
5184 /// Used only if an object of this type is returned as a trait impl by a method
5185 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
5186         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
5187 }
5188 #[allow(unused)]
5189 impl ReplyShortChannelIdsEnd {
5190         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
5191                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5192         }
5193         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
5194                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5195         }
5196         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5197         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
5198                 assert!(self.is_owned);
5199                 let ret = ObjOps::untweak_ptr(self.inner);
5200                 self.inner = core::ptr::null_mut();
5201                 ret
5202         }
5203 }
5204 /// The genesis hash of the blockchain that was queried
5205 #[no_mangle]
5206 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
5207         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
5208         inner_val.as_inner()
5209 }
5210 /// The genesis hash of the blockchain that was queried
5211 #[no_mangle]
5212 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
5213         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
5214 }
5215 /// Indicates if the query recipient maintains up-to-date channel
5216 /// information for the `chain_hash`
5217 #[no_mangle]
5218 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
5219         let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
5220         *inner_val
5221 }
5222 /// Indicates if the query recipient maintains up-to-date channel
5223 /// information for the `chain_hash`
5224 #[no_mangle]
5225 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
5226         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
5227 }
5228 /// Constructs a new ReplyShortChannelIdsEnd given each field
5229 #[must_use]
5230 #[no_mangle]
5231 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
5232         ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
5233                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
5234                 full_information: full_information_arg,
5235         }), is_owned: true }
5236 }
5237 impl Clone for ReplyShortChannelIdsEnd {
5238         fn clone(&self) -> Self {
5239                 Self {
5240                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
5241                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5242                         is_owned: true,
5243                 }
5244         }
5245 }
5246 #[allow(unused)]
5247 /// Used only if an object of this type is returned as a trait impl by a method
5248 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
5249         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
5250 }
5251 #[no_mangle]
5252 /// Creates a copy of the ReplyShortChannelIdsEnd
5253 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
5254         orig.clone()
5255 }
5256 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
5257 /// This ignores pointers and is_owned flags and looks at the values in fields.
5258 /// Two objects with NULL inner values will be considered "equal" here.
5259 #[no_mangle]
5260 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
5261         if a.inner == b.inner { return true; }
5262         if a.inner.is_null() || b.inner.is_null() { return false; }
5263         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5264 }
5265
5266 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
5267 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
5268
5269 /// A [`gossip_timestamp_filter`] message is used by a node to request
5270 /// gossip relay for messages in the requested time range when the
5271 /// `gossip_queries` feature has been negotiated.
5272 ///
5273 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
5274 #[must_use]
5275 #[repr(C)]
5276 pub struct GossipTimestampFilter {
5277         /// A pointer to the opaque Rust object.
5278
5279         /// Nearly everywhere, inner must be non-null, however in places where
5280         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5281         pub inner: *mut nativeGossipTimestampFilter,
5282         /// Indicates that this is the only struct which contains the same pointer.
5283
5284         /// Rust functions which take ownership of an object provided via an argument require
5285         /// this to be true and invalidate the object pointed to by inner.
5286         pub is_owned: bool,
5287 }
5288
5289 impl Drop for GossipTimestampFilter {
5290         fn drop(&mut self) {
5291                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
5292                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5293                 }
5294         }
5295 }
5296 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
5297 #[no_mangle]
5298 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
5299 #[allow(unused)]
5300 /// Used only if an object of this type is returned as a trait impl by a method
5301 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
5302         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
5303 }
5304 #[allow(unused)]
5305 impl GossipTimestampFilter {
5306         pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
5307                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5308         }
5309         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
5310                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5311         }
5312         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5313         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
5314                 assert!(self.is_owned);
5315                 let ret = ObjOps::untweak_ptr(self.inner);
5316                 self.inner = core::ptr::null_mut();
5317                 ret
5318         }
5319 }
5320 /// The genesis hash of the blockchain for channel and node information
5321 #[no_mangle]
5322 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
5323         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
5324         inner_val.as_inner()
5325 }
5326 /// The genesis hash of the blockchain for channel and node information
5327 #[no_mangle]
5328 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
5329         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
5330 }
5331 /// The starting unix timestamp
5332 #[no_mangle]
5333 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
5334         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
5335         *inner_val
5336 }
5337 /// The starting unix timestamp
5338 #[no_mangle]
5339 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
5340         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
5341 }
5342 /// The range of information in seconds
5343 #[no_mangle]
5344 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
5345         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
5346         *inner_val
5347 }
5348 /// The range of information in seconds
5349 #[no_mangle]
5350 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
5351         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
5352 }
5353 /// Constructs a new GossipTimestampFilter given each field
5354 #[must_use]
5355 #[no_mangle]
5356 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 {
5357         GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
5358                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
5359                 first_timestamp: first_timestamp_arg,
5360                 timestamp_range: timestamp_range_arg,
5361         }), is_owned: true }
5362 }
5363 impl Clone for GossipTimestampFilter {
5364         fn clone(&self) -> Self {
5365                 Self {
5366                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
5367                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5368                         is_owned: true,
5369                 }
5370         }
5371 }
5372 #[allow(unused)]
5373 /// Used only if an object of this type is returned as a trait impl by a method
5374 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
5375         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
5376 }
5377 #[no_mangle]
5378 /// Creates a copy of the GossipTimestampFilter
5379 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
5380         orig.clone()
5381 }
5382 /// Checks if two GossipTimestampFilters contain equal inner contents.
5383 /// This ignores pointers and is_owned flags and looks at the values in fields.
5384 /// Two objects with NULL inner values will be considered "equal" here.
5385 #[no_mangle]
5386 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
5387         if a.inner == b.inner { return true; }
5388         if a.inner.is_null() || b.inner.is_null() { return false; }
5389         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5390 }
5391 /// Used to put an error message in a [`LightningError`].
5392 #[derive(Clone)]
5393 #[must_use]
5394 #[repr(C)]
5395 pub enum ErrorAction {
5396         /// The peer took some action which made us think they were useless. Disconnect them.
5397         DisconnectPeer {
5398                 /// An error message which we should make an effort to send before we disconnect.
5399                 ///
5400                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
5401                 msg: crate::lightning::ln::msgs::ErrorMessage,
5402         },
5403         /// The peer did something harmless that we weren't able to process, just log and ignore
5404         IgnoreError,
5405         /// The peer did something harmless that we weren't able to meaningfully process.
5406         /// If the error is logged, log it at the given level.
5407         IgnoreAndLog(
5408                 crate::lightning::util::logger::Level),
5409         /// The peer provided us with a gossip message which we'd already seen. In most cases this
5410         /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
5411         /// our own channel announcements.
5412         IgnoreDuplicateGossip,
5413         /// The peer did something incorrect. Tell them.
5414         SendErrorMessage {
5415                 /// The message to send.
5416                 msg: crate::lightning::ln::msgs::ErrorMessage,
5417         },
5418         /// The peer did something incorrect. Tell them without closing any channels.
5419         SendWarningMessage {
5420                 /// The message to send.
5421                 msg: crate::lightning::ln::msgs::WarningMessage,
5422                 /// The peer may have done something harmless that we weren't able to meaningfully process,
5423                 /// though we should still tell them about it.
5424                 /// If this event is logged, log it at the given level.
5425                 log_level: crate::lightning::util::logger::Level,
5426         },
5427 }
5428 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
5429 pub(crate) type nativeErrorAction = ErrorActionImport;
5430
5431 impl ErrorAction {
5432         #[allow(unused)]
5433         pub(crate) fn to_native(&self) -> nativeErrorAction {
5434                 match self {
5435                         ErrorAction::DisconnectPeer {ref msg, } => {
5436                                 let mut msg_nonref = Clone::clone(msg);
5437                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
5438                                 nativeErrorAction::DisconnectPeer {
5439                                         msg: local_msg_nonref,
5440                                 }
5441                         },
5442                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
5443                         ErrorAction::IgnoreAndLog (ref a, ) => {
5444                                 let mut a_nonref = Clone::clone(a);
5445                                 nativeErrorAction::IgnoreAndLog (
5446                                         a_nonref.into_native(),
5447                                 )
5448                         },
5449                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
5450                         ErrorAction::SendErrorMessage {ref msg, } => {
5451                                 let mut msg_nonref = Clone::clone(msg);
5452                                 nativeErrorAction::SendErrorMessage {
5453                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
5454                                 }
5455                         },
5456                         ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
5457                                 let mut msg_nonref = Clone::clone(msg);
5458                                 let mut log_level_nonref = Clone::clone(log_level);
5459                                 nativeErrorAction::SendWarningMessage {
5460                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
5461                                         log_level: log_level_nonref.into_native(),
5462                                 }
5463                         },
5464                 }
5465         }
5466         #[allow(unused)]
5467         pub(crate) fn into_native(self) -> nativeErrorAction {
5468                 match self {
5469                         ErrorAction::DisconnectPeer {mut msg, } => {
5470                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
5471                                 nativeErrorAction::DisconnectPeer {
5472                                         msg: local_msg,
5473                                 }
5474                         },
5475                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
5476                         ErrorAction::IgnoreAndLog (mut a, ) => {
5477                                 nativeErrorAction::IgnoreAndLog (
5478                                         a.into_native(),
5479                                 )
5480                         },
5481                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
5482                         ErrorAction::SendErrorMessage {mut msg, } => {
5483                                 nativeErrorAction::SendErrorMessage {
5484                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
5485                                 }
5486                         },
5487                         ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
5488                                 nativeErrorAction::SendWarningMessage {
5489                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
5490                                         log_level: log_level.into_native(),
5491                                 }
5492                         },
5493                 }
5494         }
5495         #[allow(unused)]
5496         pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
5497                 match native {
5498                         nativeErrorAction::DisconnectPeer {ref msg, } => {
5499                                 let mut msg_nonref = Clone::clone(msg);
5500                                 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 };
5501                                 ErrorAction::DisconnectPeer {
5502                                         msg: local_msg_nonref,
5503                                 }
5504                         },
5505                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
5506                         nativeErrorAction::IgnoreAndLog (ref a, ) => {
5507                                 let mut a_nonref = Clone::clone(a);
5508                                 ErrorAction::IgnoreAndLog (
5509                                         crate::lightning::util::logger::Level::native_into(a_nonref),
5510                                 )
5511                         },
5512                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
5513                         nativeErrorAction::SendErrorMessage {ref msg, } => {
5514                                 let mut msg_nonref = Clone::clone(msg);
5515                                 ErrorAction::SendErrorMessage {
5516                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
5517                                 }
5518                         },
5519                         nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
5520                                 let mut msg_nonref = Clone::clone(msg);
5521                                 let mut log_level_nonref = Clone::clone(log_level);
5522                                 ErrorAction::SendWarningMessage {
5523                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
5524                                         log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
5525                                 }
5526                         },
5527                 }
5528         }
5529         #[allow(unused)]
5530         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
5531                 match native {
5532                         nativeErrorAction::DisconnectPeer {mut msg, } => {
5533                                 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 };
5534                                 ErrorAction::DisconnectPeer {
5535                                         msg: local_msg,
5536                                 }
5537                         },
5538                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
5539                         nativeErrorAction::IgnoreAndLog (mut a, ) => {
5540                                 ErrorAction::IgnoreAndLog (
5541                                         crate::lightning::util::logger::Level::native_into(a),
5542                                 )
5543                         },
5544                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
5545                         nativeErrorAction::SendErrorMessage {mut msg, } => {
5546                                 ErrorAction::SendErrorMessage {
5547                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
5548                                 }
5549                         },
5550                         nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
5551                                 ErrorAction::SendWarningMessage {
5552                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
5553                                         log_level: crate::lightning::util::logger::Level::native_into(log_level),
5554                                 }
5555                         },
5556                 }
5557         }
5558 }
5559 /// Frees any resources used by the ErrorAction
5560 #[no_mangle]
5561 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
5562 /// Creates a copy of the ErrorAction
5563 #[no_mangle]
5564 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
5565         orig.clone()
5566 }
5567 #[no_mangle]
5568 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
5569 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
5570         ErrorAction::DisconnectPeer {
5571                 msg,
5572         }
5573 }
5574 #[no_mangle]
5575 /// Utility method to constructs a new IgnoreError-variant ErrorAction
5576 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
5577         ErrorAction::IgnoreError}
5578 #[no_mangle]
5579 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
5580 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
5581         ErrorAction::IgnoreAndLog(a, )
5582 }
5583 #[no_mangle]
5584 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
5585 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
5586         ErrorAction::IgnoreDuplicateGossip}
5587 #[no_mangle]
5588 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
5589 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
5590         ErrorAction::SendErrorMessage {
5591                 msg,
5592         }
5593 }
5594 #[no_mangle]
5595 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
5596 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
5597         ErrorAction::SendWarningMessage {
5598                 msg,
5599                 log_level,
5600         }
5601 }
5602
5603 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
5604 pub(crate) type nativeLightningError = nativeLightningErrorImport;
5605
5606 /// An Err type for failure to process messages.
5607 #[must_use]
5608 #[repr(C)]
5609 pub struct LightningError {
5610         /// A pointer to the opaque Rust object.
5611
5612         /// Nearly everywhere, inner must be non-null, however in places where
5613         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5614         pub inner: *mut nativeLightningError,
5615         /// Indicates that this is the only struct which contains the same pointer.
5616
5617         /// Rust functions which take ownership of an object provided via an argument require
5618         /// this to be true and invalidate the object pointed to by inner.
5619         pub is_owned: bool,
5620 }
5621
5622 impl Drop for LightningError {
5623         fn drop(&mut self) {
5624                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
5625                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5626                 }
5627         }
5628 }
5629 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
5630 #[no_mangle]
5631 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
5632 #[allow(unused)]
5633 /// Used only if an object of this type is returned as a trait impl by a method
5634 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
5635         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
5636 }
5637 #[allow(unused)]
5638 impl LightningError {
5639         pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
5640                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5641         }
5642         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
5643                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5644         }
5645         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5646         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
5647                 assert!(self.is_owned);
5648                 let ret = ObjOps::untweak_ptr(self.inner);
5649                 self.inner = core::ptr::null_mut();
5650                 ret
5651         }
5652 }
5653 /// A human-readable message describing the error
5654 #[no_mangle]
5655 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
5656         let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
5657         inner_val.as_str().into()
5658 }
5659 /// A human-readable message describing the error
5660 #[no_mangle]
5661 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
5662         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
5663 }
5664 /// The action which should be taken against the offending peer.
5665 #[no_mangle]
5666 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
5667         let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
5668         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
5669 }
5670 /// The action which should be taken against the offending peer.
5671 #[no_mangle]
5672 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
5673         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
5674 }
5675 /// Constructs a new LightningError given each field
5676 #[must_use]
5677 #[no_mangle]
5678 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
5679         LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
5680                 err: err_arg.into_string(),
5681                 action: action_arg.into_native(),
5682         }), is_owned: true }
5683 }
5684 impl Clone for LightningError {
5685         fn clone(&self) -> Self {
5686                 Self {
5687                         inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
5688                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5689                         is_owned: true,
5690                 }
5691         }
5692 }
5693 #[allow(unused)]
5694 /// Used only if an object of this type is returned as a trait impl by a method
5695 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
5696         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
5697 }
5698 #[no_mangle]
5699 /// Creates a copy of the LightningError
5700 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
5701         orig.clone()
5702 }
5703
5704 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
5705 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
5706
5707 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
5708 /// transaction updates if they were pending.
5709 #[must_use]
5710 #[repr(C)]
5711 pub struct CommitmentUpdate {
5712         /// A pointer to the opaque Rust object.
5713
5714         /// Nearly everywhere, inner must be non-null, however in places where
5715         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5716         pub inner: *mut nativeCommitmentUpdate,
5717         /// Indicates that this is the only struct which contains the same pointer.
5718
5719         /// Rust functions which take ownership of an object provided via an argument require
5720         /// this to be true and invalidate the object pointed to by inner.
5721         pub is_owned: bool,
5722 }
5723
5724 impl Drop for CommitmentUpdate {
5725         fn drop(&mut self) {
5726                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
5727                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5728                 }
5729         }
5730 }
5731 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
5732 #[no_mangle]
5733 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
5734 #[allow(unused)]
5735 /// Used only if an object of this type is returned as a trait impl by a method
5736 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
5737         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
5738 }
5739 #[allow(unused)]
5740 impl CommitmentUpdate {
5741         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
5742                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5743         }
5744         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
5745                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5746         }
5747         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5748         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
5749                 assert!(self.is_owned);
5750                 let ret = ObjOps::untweak_ptr(self.inner);
5751                 self.inner = core::ptr::null_mut();
5752                 ret
5753         }
5754 }
5755 /// `update_add_htlc` messages which should be sent
5756 #[no_mangle]
5757 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
5758         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
5759         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 } }); };
5760         local_inner_val.into()
5761 }
5762 /// `update_add_htlc` messages which should be sent
5763 #[no_mangle]
5764 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
5765         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5766         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
5767 }
5768 /// `update_fulfill_htlc` messages which should be sent
5769 #[no_mangle]
5770 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
5771         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
5772         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 } }); };
5773         local_inner_val.into()
5774 }
5775 /// `update_fulfill_htlc` messages which should be sent
5776 #[no_mangle]
5777 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
5778         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5779         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
5780 }
5781 /// `update_fail_htlc` messages which should be sent
5782 #[no_mangle]
5783 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
5784         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
5785         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 } }); };
5786         local_inner_val.into()
5787 }
5788 /// `update_fail_htlc` messages which should be sent
5789 #[no_mangle]
5790 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
5791         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5792         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
5793 }
5794 /// `update_fail_malformed_htlc` messages which should be sent
5795 #[no_mangle]
5796 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
5797         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
5798         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 } }); };
5799         local_inner_val.into()
5800 }
5801 /// `update_fail_malformed_htlc` messages which should be sent
5802 #[no_mangle]
5803 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
5804         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5805         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
5806 }
5807 /// An `update_fee` message which should be sent
5808 ///
5809 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
5810 #[no_mangle]
5811 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
5812         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
5813         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 };
5814         local_inner_val
5815 }
5816 /// An `update_fee` message which should be sent
5817 ///
5818 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
5819 #[no_mangle]
5820 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
5821         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
5822         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
5823 }
5824 /// A `commitment_signed` message which should be sent
5825 #[no_mangle]
5826 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
5827         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
5828         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 }
5829 }
5830 /// A `commitment_signed` message which should be sent
5831 #[no_mangle]
5832 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
5833         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
5834 }
5835 /// Constructs a new CommitmentUpdate given each field
5836 #[must_use]
5837 #[no_mangle]
5838 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 {
5839         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()) } }); };
5840         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()) } }); };
5841         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()) } }); };
5842         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()) } }); };
5843         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()) } }) };
5844         CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
5845                 update_add_htlcs: local_update_add_htlcs_arg,
5846                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
5847                 update_fail_htlcs: local_update_fail_htlcs_arg,
5848                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
5849                 update_fee: local_update_fee_arg,
5850                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
5851         }), is_owned: true }
5852 }
5853 impl Clone for CommitmentUpdate {
5854         fn clone(&self) -> Self {
5855                 Self {
5856                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
5857                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5858                         is_owned: true,
5859                 }
5860         }
5861 }
5862 #[allow(unused)]
5863 /// Used only if an object of this type is returned as a trait impl by a method
5864 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
5865         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
5866 }
5867 #[no_mangle]
5868 /// Creates a copy of the CommitmentUpdate
5869 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
5870         orig.clone()
5871 }
5872 /// Checks if two CommitmentUpdates contain equal inner contents.
5873 /// This ignores pointers and is_owned flags and looks at the values in fields.
5874 /// Two objects with NULL inner values will be considered "equal" here.
5875 #[no_mangle]
5876 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
5877         if a.inner == b.inner { return true; }
5878         if a.inner.is_null() || b.inner.is_null() { return false; }
5879         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5880 }
5881 /// A trait to describe an object which can receive channel messages.
5882 ///
5883 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
5884 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
5885 #[repr(C)]
5886 pub struct ChannelMessageHandler {
5887         /// An opaque pointer which is passed to your function implementations as an argument.
5888         /// This has no meaning in the LDK, and can be NULL or any other value.
5889         pub this_arg: *mut c_void,
5890         /// Handle an incoming `open_channel` message from the given peer.
5891         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),
5892         /// Handle an incoming `accept_channel` message from the given peer.
5893         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),
5894         /// Handle an incoming `funding_created` message from the given peer.
5895         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),
5896         /// Handle an incoming `funding_signed` message from the given peer.
5897         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),
5898         /// Handle an incoming `channel_ready` message from the given peer.
5899         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),
5900         /// Handle an incoming `shutdown` message from the given peer.
5901         pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
5902         /// Handle an incoming `closing_signed` message from the given peer.
5903         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),
5904         /// Handle an incoming `update_add_htlc` message from the given peer.
5905         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),
5906         /// Handle an incoming `update_fulfill_htlc` message from the given peer.
5907         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),
5908         /// Handle an incoming `update_fail_htlc` message from the given peer.
5909         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),
5910         /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
5911         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),
5912         /// Handle an incoming `commitment_signed` message from the given peer.
5913         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),
5914         /// Handle an incoming `revoke_and_ack` message from the given peer.
5915         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),
5916         /// Handle an incoming `update_fee` message from the given peer.
5917         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),
5918         /// Handle an incoming `announcement_signatures` message from the given peer.
5919         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),
5920         /// Indicates a connection to the peer failed/an existing connection was lost.
5921         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
5922         /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
5923         ///
5924         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
5925         /// with us. Implementors should be somewhat conservative about doing so, however, as other
5926         /// message handlers may still wish to communicate with this peer.
5927         #[must_use]
5928         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,
5929         /// Handle an incoming `channel_reestablish` message from the given peer.
5930         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),
5931         /// Handle an incoming `channel_update` message from the given peer.
5932         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),
5933         /// Handle an incoming `error` message from the given peer.
5934         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
5935         /// Gets the node feature flags which this handler itself supports. All available handlers are
5936         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
5937         /// which are broadcasted in our [`NodeAnnouncement`] message.
5938         #[must_use]
5939         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
5940         /// Gets the init feature flags which should be sent to the given peer. All available handlers
5941         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
5942         /// which are sent in our [`Init`] message.
5943         ///
5944         /// Note that this method is called before [`Self::peer_connected`].
5945         #[must_use]
5946         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
5947         /// Implementation of MessageSendEventsProvider for this object.
5948         pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5949         /// Frees any resources associated with this object given its this_arg pointer.
5950         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5951         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5952 }
5953 unsafe impl Send for ChannelMessageHandler {}
5954 unsafe impl Sync for ChannelMessageHandler {}
5955 #[no_mangle]
5956 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
5957         ChannelMessageHandler {
5958                 this_arg: orig.this_arg,
5959                 handle_open_channel: Clone::clone(&orig.handle_open_channel),
5960                 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
5961                 handle_funding_created: Clone::clone(&orig.handle_funding_created),
5962                 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
5963                 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
5964                 handle_shutdown: Clone::clone(&orig.handle_shutdown),
5965                 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
5966                 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
5967                 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
5968                 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
5969                 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
5970                 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
5971                 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
5972                 handle_update_fee: Clone::clone(&orig.handle_update_fee),
5973                 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
5974                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
5975                 peer_connected: Clone::clone(&orig.peer_connected),
5976                 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
5977                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5978                 handle_error: Clone::clone(&orig.handle_error),
5979                 provided_node_features: Clone::clone(&orig.provided_node_features),
5980                 provided_init_features: Clone::clone(&orig.provided_init_features),
5981                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5982                 free: Clone::clone(&orig.free),
5983         }
5984 }
5985 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
5986         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5987                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5988                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5989                 local_ret
5990         }
5991 }
5992
5993 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
5994 impl rustChannelMessageHandler for ChannelMessageHandler {
5995         fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
5996                 (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 })
5997         }
5998         fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
5999                 (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 })
6000         }
6001         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
6002                 (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 })
6003         }
6004         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
6005                 (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 })
6006         }
6007         fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
6008                 (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 })
6009         }
6010         fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
6011                 (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 })
6012         }
6013         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
6014                 (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 })
6015         }
6016         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
6017                 (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 })
6018         }
6019         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
6020                 (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 })
6021         }
6022         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
6023                 (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 })
6024         }
6025         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
6026                 (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 })
6027         }
6028         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
6029                 (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 })
6030         }
6031         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
6032                 (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 })
6033         }
6034         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
6035                 (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 })
6036         }
6037         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
6038                 (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 })
6039         }
6040         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
6041                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
6042         }
6043         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
6044                 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);
6045                 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)) })*/ })};
6046                 local_ret
6047         }
6048         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
6049                 (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 })
6050         }
6051         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
6052                 (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 })
6053         }
6054         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
6055                 (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 })
6056         }
6057         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
6058                 let mut ret = (self.provided_node_features)(self.this_arg);
6059                 *unsafe { Box::from_raw(ret.take_inner()) }
6060         }
6061         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
6062                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
6063                 *unsafe { Box::from_raw(ret.take_inner()) }
6064         }
6065 }
6066
6067 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
6068 // directly as a Deref trait in higher-level structs:
6069 impl core::ops::Deref for ChannelMessageHandler {
6070         type Target = Self;
6071         fn deref(&self) -> &Self {
6072                 self
6073         }
6074 }
6075 /// Calls the free function if one is set
6076 #[no_mangle]
6077 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
6078 impl Drop for ChannelMessageHandler {
6079         fn drop(&mut self) {
6080                 if let Some(f) = self.free {
6081                         f(self.this_arg);
6082                 }
6083         }
6084 }
6085 /// A trait to describe an object which can receive routing messages.
6086 ///
6087 /// # Implementor DoS Warnings
6088 ///
6089 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
6090 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
6091 /// repeated disk I/O for queries accessing different parts of the network graph.
6092 #[repr(C)]
6093 pub struct RoutingMessageHandler {
6094         /// An opaque pointer which is passed to your function implementations as an argument.
6095         /// This has no meaning in the LDK, and can be NULL or any other value.
6096         pub this_arg: *mut c_void,
6097         /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
6098         /// `false` or returning an `Err` otherwise.
6099         #[must_use]
6100         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
6101         /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
6102         /// or returning an `Err` otherwise.
6103         #[must_use]
6104         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
6105         /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
6106         /// `false` or returning an `Err` otherwise.
6107         #[must_use]
6108         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
6109         /// Gets channel announcements and updates required to dump our routing table to a remote node,
6110         /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
6111         /// for a single channel.
6112         #[must_use]
6113         pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
6114         /// Gets a node announcement required to dump our routing table to a remote node, starting at
6115         /// the node *after* the provided pubkey and including up to one announcement immediately
6116         /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
6117         /// If `None` is provided for `starting_point`, we start at the first node.
6118         ///
6119         /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
6120         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
6121         #[must_use]
6122         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,
6123         /// Called when a connection is established with a peer. This can be used to
6124         /// perform routing table synchronization using a strategy defined by the
6125         /// implementor.
6126         ///
6127         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
6128         /// with us. Implementors should be somewhat conservative about doing so, however, as other
6129         /// message handlers may still wish to communicate with this peer.
6130         #[must_use]
6131         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,
6132         /// Handles the reply of a query we initiated to learn about channels
6133         /// for a given range of blocks. We can expect to receive one or more
6134         /// replies to a single query.
6135         #[must_use]
6136         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,
6137         /// Handles the reply of a query we initiated asking for routing gossip
6138         /// messages for a list of channels. We should receive this message when
6139         /// a node has completed its best effort to send us the pertaining routing
6140         /// gossip messages.
6141         #[must_use]
6142         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,
6143         /// Handles when a peer asks us to send a list of `short_channel_id`s
6144         /// for the requested range of blocks.
6145         #[must_use]
6146         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,
6147         /// Handles when a peer asks us to send routing gossip messages for a
6148         /// list of `short_channel_id`s.
6149         #[must_use]
6150         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,
6151         /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
6152         /// pending some async action. While there is no guarantee of the rate of future messages, the
6153         /// caller should seek to reduce the rate of new gossip messages handled, especially
6154         /// [`ChannelAnnouncement`]s.
6155         #[must_use]
6156         pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
6157         /// Gets the node feature flags which this handler itself supports. All available handlers are
6158         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
6159         /// which are broadcasted in our [`NodeAnnouncement`] message.
6160         #[must_use]
6161         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
6162         /// Gets the init feature flags which should be sent to the given peer. All available handlers
6163         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
6164         /// which are sent in our [`Init`] message.
6165         ///
6166         /// Note that this method is called before [`Self::peer_connected`].
6167         #[must_use]
6168         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
6169         /// Implementation of MessageSendEventsProvider for this object.
6170         pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
6171         /// Frees any resources associated with this object given its this_arg pointer.
6172         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
6173         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
6174 }
6175 unsafe impl Send for RoutingMessageHandler {}
6176 unsafe impl Sync for RoutingMessageHandler {}
6177 #[no_mangle]
6178 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
6179         RoutingMessageHandler {
6180                 this_arg: orig.this_arg,
6181                 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
6182                 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
6183                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
6184                 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
6185                 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
6186                 peer_connected: Clone::clone(&orig.peer_connected),
6187                 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
6188                 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
6189                 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
6190                 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
6191                 processing_queue_high: Clone::clone(&orig.processing_queue_high),
6192                 provided_node_features: Clone::clone(&orig.provided_node_features),
6193                 provided_init_features: Clone::clone(&orig.provided_init_features),
6194                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
6195                 free: Clone::clone(&orig.free),
6196         }
6197 }
6198 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
6199         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
6200                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
6201                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
6202                 local_ret
6203         }
6204 }
6205
6206 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
6207 impl rustRoutingMessageHandler for RoutingMessageHandler {
6208         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
6209                 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 });
6210                 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()) } })};
6211                 local_ret
6212         }
6213         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
6214                 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 });
6215                 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()) } })};
6216                 local_ret
6217         }
6218         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
6219                 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 });
6220                 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()) } })};
6221                 local_ret
6222         }
6223         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>)> {
6224                 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
6225                 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 };
6226                 local_ret
6227         }
6228         fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
6229                 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 };
6230                 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
6231                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
6232                 local_ret
6233         }
6234         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
6235                 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);
6236                 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)) })*/ })};
6237                 local_ret
6238         }
6239         fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
6240                 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 });
6241                 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()) } })};
6242                 local_ret
6243         }
6244         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> {
6245                 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 });
6246                 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()) } })};
6247                 local_ret
6248         }
6249         fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
6250                 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 });
6251                 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()) } })};
6252                 local_ret
6253         }
6254         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> {
6255                 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 });
6256                 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()) } })};
6257                 local_ret
6258         }
6259         fn processing_queue_high(&self) -> bool {
6260                 let mut ret = (self.processing_queue_high)(self.this_arg);
6261                 ret
6262         }
6263         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
6264                 let mut ret = (self.provided_node_features)(self.this_arg);
6265                 *unsafe { Box::from_raw(ret.take_inner()) }
6266         }
6267         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
6268                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
6269                 *unsafe { Box::from_raw(ret.take_inner()) }
6270         }
6271 }
6272
6273 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
6274 // directly as a Deref trait in higher-level structs:
6275 impl core::ops::Deref for RoutingMessageHandler {
6276         type Target = Self;
6277         fn deref(&self) -> &Self {
6278                 self
6279         }
6280 }
6281 /// Calls the free function if one is set
6282 #[no_mangle]
6283 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
6284 impl Drop for RoutingMessageHandler {
6285         fn drop(&mut self) {
6286                 if let Some(f) = self.free {
6287                         f(self.this_arg);
6288                 }
6289         }
6290 }
6291 /// A trait to describe an object that can receive onion messages.
6292 #[repr(C)]
6293 pub struct OnionMessageHandler {
6294         /// An opaque pointer which is passed to your function implementations as an argument.
6295         /// This has no meaning in the LDK, and can be NULL or any other value.
6296         pub this_arg: *mut c_void,
6297         /// Handle an incoming `onion_message` message from the given peer.
6298         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),
6299         /// Called when a connection is established with a peer. Can be used to track which peers
6300         /// advertise onion message support and are online.
6301         ///
6302         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
6303         /// with us. Implementors should be somewhat conservative about doing so, however, as other
6304         /// message handlers may still wish to communicate with this peer.
6305         #[must_use]
6306         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,
6307         /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
6308         /// drop and refuse to forward onion messages to this peer.
6309         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
6310         /// Gets the node feature flags which this handler itself supports. All available handlers are
6311         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
6312         /// which are broadcasted in our [`NodeAnnouncement`] message.
6313         #[must_use]
6314         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
6315         /// Gets the init feature flags which should be sent to the given peer. All available handlers
6316         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
6317         /// which are sent in our [`Init`] message.
6318         ///
6319         /// Note that this method is called before [`Self::peer_connected`].
6320         #[must_use]
6321         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
6322         /// Implementation of OnionMessageProvider for this object.
6323         pub OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider,
6324         /// Frees any resources associated with this object given its this_arg pointer.
6325         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
6326         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
6327 }
6328 unsafe impl Send for OnionMessageHandler {}
6329 unsafe impl Sync for OnionMessageHandler {}
6330 #[no_mangle]
6331 pub(crate) extern "C" fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
6332         OnionMessageHandler {
6333                 this_arg: orig.this_arg,
6334                 handle_onion_message: Clone::clone(&orig.handle_onion_message),
6335                 peer_connected: Clone::clone(&orig.peer_connected),
6336                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
6337                 provided_node_features: Clone::clone(&orig.provided_node_features),
6338                 provided_init_features: Clone::clone(&orig.provided_init_features),
6339                 OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider),
6340                 free: Clone::clone(&orig.free),
6341         }
6342 }
6343 impl lightning::util::events::OnionMessageProvider for OnionMessageHandler {
6344         fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
6345                 let mut ret = (self.OnionMessageProvider.next_onion_message_for_peer)(self.OnionMessageProvider.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
6346                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
6347                 local_ret
6348         }
6349 }
6350
6351 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
6352 impl rustOnionMessageHandler for OnionMessageHandler {
6353         fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
6354                 (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 })
6355         }
6356         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
6357                 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);
6358                 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)) })*/ })};
6359                 local_ret
6360         }
6361         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
6362                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
6363         }
6364         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
6365                 let mut ret = (self.provided_node_features)(self.this_arg);
6366                 *unsafe { Box::from_raw(ret.take_inner()) }
6367         }
6368         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
6369                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
6370                 *unsafe { Box::from_raw(ret.take_inner()) }
6371         }
6372 }
6373
6374 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
6375 // directly as a Deref trait in higher-level structs:
6376 impl core::ops::Deref for OnionMessageHandler {
6377         type Target = Self;
6378         fn deref(&self) -> &Self {
6379                 self
6380         }
6381 }
6382 /// Calls the free function if one is set
6383 #[no_mangle]
6384 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
6385 impl Drop for OnionMessageHandler {
6386         fn drop(&mut self) {
6387                 if let Some(f) = self.free {
6388                         f(self.this_arg);
6389                 }
6390         }
6391 }
6392 mod fuzzy_internal_msgs {
6393
6394 use alloc::str::FromStr;
6395 use core::ffi::c_void;
6396 use core::convert::Infallible;
6397 use bitcoin::hashes::Hash;
6398 use crate::c_types::*;
6399 #[cfg(feature="no-std")]
6400 use alloc::{vec::Vec, boxed::Box};
6401
6402 }
6403 #[no_mangle]
6404 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
6405 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
6406         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6407 }
6408 #[no_mangle]
6409 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6410         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
6411 }
6412 #[no_mangle]
6413 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
6414 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
6415         let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6416         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() };
6417         local_res
6418 }
6419 #[no_mangle]
6420 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
6421 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
6422         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6423 }
6424 #[no_mangle]
6425 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6426         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
6427 }
6428 #[no_mangle]
6429 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
6430 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
6431         let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6432         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() };
6433         local_res
6434 }
6435 #[no_mangle]
6436 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
6437 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
6438         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6439 }
6440 #[no_mangle]
6441 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6442         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
6443 }
6444 #[no_mangle]
6445 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
6446 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
6447         let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6448         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() };
6449         local_res
6450 }
6451 #[no_mangle]
6452 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
6453 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
6454         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6455 }
6456 #[no_mangle]
6457 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6458         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
6459 }
6460 #[no_mangle]
6461 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
6462 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
6463         let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6464         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() };
6465         local_res
6466 }
6467 #[no_mangle]
6468 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
6469 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
6470         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6471 }
6472 #[no_mangle]
6473 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6474         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
6475 }
6476 #[no_mangle]
6477 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
6478 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
6479         let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6480         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() };
6481         local_res
6482 }
6483 #[no_mangle]
6484 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
6485 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
6486         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6487 }
6488 #[no_mangle]
6489 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6490         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
6491 }
6492 #[no_mangle]
6493 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
6494 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
6495         let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6496         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() };
6497         local_res
6498 }
6499 #[no_mangle]
6500 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
6501 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
6502         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6503 }
6504 #[no_mangle]
6505 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6506         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
6507 }
6508 #[no_mangle]
6509 /// Read a FundingCreated from a byte array, created by FundingCreated_write
6510 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
6511         let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6512         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() };
6513         local_res
6514 }
6515 #[no_mangle]
6516 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
6517 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
6518         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6519 }
6520 #[no_mangle]
6521 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6522         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
6523 }
6524 #[no_mangle]
6525 /// Read a FundingSigned from a byte array, created by FundingSigned_write
6526 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
6527         let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6528         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() };
6529         local_res
6530 }
6531 #[no_mangle]
6532 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
6533 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
6534         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6535 }
6536 #[no_mangle]
6537 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6538         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
6539 }
6540 #[no_mangle]
6541 /// Read a ChannelReady from a byte array, created by ChannelReady_write
6542 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
6543         let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6544         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() };
6545         local_res
6546 }
6547 #[no_mangle]
6548 /// Serialize the Init object into a byte array which can be read by Init_read
6549 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
6550         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6551 }
6552 #[no_mangle]
6553 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6554         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
6555 }
6556 #[no_mangle]
6557 /// Read a Init from a byte array, created by Init_write
6558 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
6559         let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6560         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() };
6561         local_res
6562 }
6563 #[no_mangle]
6564 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
6565 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
6566         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6567 }
6568 #[no_mangle]
6569 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6570         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
6571 }
6572 #[no_mangle]
6573 /// Read a OpenChannel from a byte array, created by OpenChannel_write
6574 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
6575         let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6576         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() };
6577         local_res
6578 }
6579 #[no_mangle]
6580 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
6581 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
6582         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6583 }
6584 #[no_mangle]
6585 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6586         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
6587 }
6588 #[no_mangle]
6589 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
6590 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
6591         let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6592         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() };
6593         local_res
6594 }
6595 #[no_mangle]
6596 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
6597 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
6598         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6599 }
6600 #[no_mangle]
6601 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6602         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
6603 }
6604 #[no_mangle]
6605 /// Read a Shutdown from a byte array, created by Shutdown_write
6606 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
6607         let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6608         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() };
6609         local_res
6610 }
6611 #[no_mangle]
6612 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
6613 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
6614         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6615 }
6616 #[no_mangle]
6617 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6618         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
6619 }
6620 #[no_mangle]
6621 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
6622 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
6623         let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6624         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() };
6625         local_res
6626 }
6627 #[no_mangle]
6628 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
6629 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
6630         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6631 }
6632 #[no_mangle]
6633 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6634         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
6635 }
6636 #[no_mangle]
6637 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
6638 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
6639         let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6640         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() };
6641         local_res
6642 }
6643 #[no_mangle]
6644 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
6645 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
6646         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6647 }
6648 #[no_mangle]
6649 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6650         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
6651 }
6652 #[no_mangle]
6653 /// Read a UpdateFee from a byte array, created by UpdateFee_write
6654 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
6655         let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6656         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() };
6657         local_res
6658 }
6659 #[no_mangle]
6660 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
6661 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
6662         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6663 }
6664 #[no_mangle]
6665 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6666         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
6667 }
6668 #[no_mangle]
6669 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
6670 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
6671         let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6672         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() };
6673         local_res
6674 }
6675 #[no_mangle]
6676 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
6677 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
6678         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6679 }
6680 #[no_mangle]
6681 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6682         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
6683 }
6684 #[no_mangle]
6685 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
6686 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
6687         let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6688         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() };
6689         local_res
6690 }
6691 #[no_mangle]
6692 /// Read a OnionMessage from a byte array, created by OnionMessage_write
6693 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
6694         let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6695         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() };
6696         local_res
6697 }
6698 #[no_mangle]
6699 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
6700 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
6701         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6702 }
6703 #[no_mangle]
6704 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6705         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
6706 }
6707 #[no_mangle]
6708 /// Serialize the Ping object into a byte array which can be read by Ping_read
6709 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
6710         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6711 }
6712 #[no_mangle]
6713 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6714         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
6715 }
6716 #[no_mangle]
6717 /// Read a Ping from a byte array, created by Ping_write
6718 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
6719         let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6720         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() };
6721         local_res
6722 }
6723 #[no_mangle]
6724 /// Serialize the Pong object into a byte array which can be read by Pong_read
6725 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
6726         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6727 }
6728 #[no_mangle]
6729 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6730         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
6731 }
6732 #[no_mangle]
6733 /// Read a Pong from a byte array, created by Pong_write
6734 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
6735         let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6736         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() };
6737         local_res
6738 }
6739 #[no_mangle]
6740 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
6741 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6742         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6743 }
6744 #[no_mangle]
6745 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6746         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
6747 }
6748 #[no_mangle]
6749 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
6750 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
6751         let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6752         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() };
6753         local_res
6754 }
6755 #[no_mangle]
6756 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
6757 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6758         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6759 }
6760 #[no_mangle]
6761 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6762         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
6763 }
6764 #[no_mangle]
6765 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
6766 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
6767         let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6768         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() };
6769         local_res
6770 }
6771 #[no_mangle]
6772 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
6773 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6774         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6775 }
6776 #[no_mangle]
6777 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6778         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
6779 }
6780 #[no_mangle]
6781 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
6782 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
6783         let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6784         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() };
6785         local_res
6786 }
6787 #[no_mangle]
6788 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
6789 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6790         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6791 }
6792 #[no_mangle]
6793 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6794         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
6795 }
6796 #[no_mangle]
6797 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
6798 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
6799         let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6800         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() };
6801         local_res
6802 }
6803 #[no_mangle]
6804 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
6805 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
6806         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6807 }
6808 #[no_mangle]
6809 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6810         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
6811 }
6812 #[no_mangle]
6813 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
6814 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
6815         let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6816         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() };
6817         local_res
6818 }
6819 #[no_mangle]
6820 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
6821 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
6822         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6823 }
6824 #[no_mangle]
6825 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6826         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
6827 }
6828 #[no_mangle]
6829 /// Read a WarningMessage from a byte array, created by WarningMessage_write
6830 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
6831         let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6832         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() };
6833         local_res
6834 }
6835 #[no_mangle]
6836 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
6837 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6838         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6839 }
6840 #[no_mangle]
6841 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6842         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
6843 }
6844 #[no_mangle]
6845 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
6846 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
6847         let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6848         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() };
6849         local_res
6850 }
6851 #[no_mangle]
6852 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
6853 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6854         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6855 }
6856 #[no_mangle]
6857 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6858         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
6859 }
6860 #[no_mangle]
6861 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
6862 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
6863         let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6864         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() };
6865         local_res
6866 }
6867 #[no_mangle]
6868 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
6869 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
6870         let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6871         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() };
6872         local_res
6873 }
6874 #[no_mangle]
6875 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
6876 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
6877         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6878 }
6879 #[no_mangle]
6880 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6881         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
6882 }
6883 #[no_mangle]
6884 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
6885 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
6886         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6887 }
6888 #[no_mangle]
6889 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6890         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
6891 }
6892 #[no_mangle]
6893 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
6894 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
6895         let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6896         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() };
6897         local_res
6898 }
6899 /// Calculates the overflow safe ending block height for the query.
6900 ///
6901 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
6902 #[must_use]
6903 #[no_mangle]
6904 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
6905         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
6906         ret
6907 }
6908
6909 #[no_mangle]
6910 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
6911 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
6912         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6913 }
6914 #[no_mangle]
6915 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6916         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
6917 }
6918 #[no_mangle]
6919 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
6920 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
6921         let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6922         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() };
6923         local_res
6924 }
6925 #[no_mangle]
6926 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
6927 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
6928         let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6929         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() };
6930         local_res
6931 }
6932 #[no_mangle]
6933 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
6934 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
6935         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6936 }
6937 #[no_mangle]
6938 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6939         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
6940 }
6941 #[no_mangle]
6942 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
6943 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
6944         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6945 }
6946 #[no_mangle]
6947 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6948         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
6949 }
6950 #[no_mangle]
6951 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
6952 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
6953         let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6954         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() };
6955         local_res
6956 }