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