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