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::OnionMessage as nativeOnionMessageImport;
1985 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
1986
1987 /// An onion message to be sent or received from a peer
1988 #[must_use]
1989 #[repr(C)]
1990 pub struct OnionMessage {
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 nativeOnionMessage,
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 OnionMessage {
2004         fn drop(&mut self) {
2005                 if self.is_owned && !<*mut nativeOnionMessage>::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 OnionMessage, if is_owned is set and inner is non-NULL.
2011 #[no_mangle]
2012 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
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 OnionMessage_free_void(this_ptr: *mut c_void) {
2016         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOnionMessage); }
2017 }
2018 #[allow(unused)]
2019 impl OnionMessage {
2020         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
2021                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2022         }
2023         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
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 nativeOnionMessage {
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 /// Used in decrypting the onion packet's payload.
2035 #[no_mangle]
2036 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
2037         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
2038         crate::c_types::PublicKey::from_rust(&inner_val)
2039 }
2040 /// Used in decrypting the onion packet's payload.
2041 #[no_mangle]
2042 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
2043         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
2044 }
2045 impl Clone for OnionMessage {
2046         fn clone(&self) -> Self {
2047                 Self {
2048                         inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
2049                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2050                         is_owned: true,
2051                 }
2052         }
2053 }
2054 #[allow(unused)]
2055 /// Used only if an object of this type is returned as a trait impl by a method
2056 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
2057         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessage)).clone() })) as *mut c_void
2058 }
2059 #[no_mangle]
2060 /// Creates a copy of the OnionMessage
2061 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
2062         orig.clone()
2063 }
2064
2065 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
2066 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
2067
2068 /// An update_fulfill_htlc message to be sent or received from a peer
2069 #[must_use]
2070 #[repr(C)]
2071 pub struct UpdateFulfillHTLC {
2072         /// A pointer to the opaque Rust object.
2073
2074         /// Nearly everywhere, inner must be non-null, however in places where
2075         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2076         pub inner: *mut nativeUpdateFulfillHTLC,
2077         /// Indicates that this is the only struct which contains the same pointer.
2078
2079         /// Rust functions which take ownership of an object provided via an argument require
2080         /// this to be true and invalidate the object pointed to by inner.
2081         pub is_owned: bool,
2082 }
2083
2084 impl Drop for UpdateFulfillHTLC {
2085         fn drop(&mut self) {
2086                 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
2087                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2088                 }
2089         }
2090 }
2091 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
2092 #[no_mangle]
2093 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
2094 #[allow(unused)]
2095 /// Used only if an object of this type is returned as a trait impl by a method
2096 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
2097         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
2098 }
2099 #[allow(unused)]
2100 impl UpdateFulfillHTLC {
2101         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
2102                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2103         }
2104         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
2105                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2106         }
2107         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2108         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
2109                 assert!(self.is_owned);
2110                 let ret = ObjOps::untweak_ptr(self.inner);
2111                 self.inner = core::ptr::null_mut();
2112                 ret
2113         }
2114 }
2115 /// The channel ID
2116 #[no_mangle]
2117 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2118         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2119         inner_val
2120 }
2121 /// The channel ID
2122 #[no_mangle]
2123 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2124         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2125 }
2126 /// The HTLC ID
2127 #[no_mangle]
2128 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
2129         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2130         *inner_val
2131 }
2132 /// The HTLC ID
2133 #[no_mangle]
2134 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
2135         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2136 }
2137 /// The pre-image of the payment hash, allowing HTLC redemption
2138 #[no_mangle]
2139 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2140         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
2141         &inner_val.0
2142 }
2143 /// The pre-image of the payment hash, allowing HTLC redemption
2144 #[no_mangle]
2145 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2146         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
2147 }
2148 /// Constructs a new UpdateFulfillHTLC given each field
2149 #[must_use]
2150 #[no_mangle]
2151 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 {
2152         UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
2153                 channel_id: channel_id_arg.data,
2154                 htlc_id: htlc_id_arg,
2155                 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
2156         }), is_owned: true }
2157 }
2158 impl Clone for UpdateFulfillHTLC {
2159         fn clone(&self) -> Self {
2160                 Self {
2161                         inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2162                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2163                         is_owned: true,
2164                 }
2165         }
2166 }
2167 #[allow(unused)]
2168 /// Used only if an object of this type is returned as a trait impl by a method
2169 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2170         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
2171 }
2172 #[no_mangle]
2173 /// Creates a copy of the UpdateFulfillHTLC
2174 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
2175         orig.clone()
2176 }
2177
2178 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
2179 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
2180
2181 /// An update_fail_htlc message to be sent or received from a peer
2182 #[must_use]
2183 #[repr(C)]
2184 pub struct UpdateFailHTLC {
2185         /// A pointer to the opaque Rust object.
2186
2187         /// Nearly everywhere, inner must be non-null, however in places where
2188         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2189         pub inner: *mut nativeUpdateFailHTLC,
2190         /// Indicates that this is the only struct which contains the same pointer.
2191
2192         /// Rust functions which take ownership of an object provided via an argument require
2193         /// this to be true and invalidate the object pointed to by inner.
2194         pub is_owned: bool,
2195 }
2196
2197 impl Drop for UpdateFailHTLC {
2198         fn drop(&mut self) {
2199                 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
2200                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2201                 }
2202         }
2203 }
2204 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
2205 #[no_mangle]
2206 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
2207 #[allow(unused)]
2208 /// Used only if an object of this type is returned as a trait impl by a method
2209 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
2210         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
2211 }
2212 #[allow(unused)]
2213 impl UpdateFailHTLC {
2214         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
2215                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2216         }
2217         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
2218                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2219         }
2220         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2221         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
2222                 assert!(self.is_owned);
2223                 let ret = ObjOps::untweak_ptr(self.inner);
2224                 self.inner = core::ptr::null_mut();
2225                 ret
2226         }
2227 }
2228 /// The channel ID
2229 #[no_mangle]
2230 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
2231         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2232         inner_val
2233 }
2234 /// The channel ID
2235 #[no_mangle]
2236 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2237         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2238 }
2239 /// The HTLC ID
2240 #[no_mangle]
2241 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
2242         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2243         *inner_val
2244 }
2245 /// The HTLC ID
2246 #[no_mangle]
2247 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
2248         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2249 }
2250 impl Clone for UpdateFailHTLC {
2251         fn clone(&self) -> Self {
2252                 Self {
2253                         inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2254                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2255                         is_owned: true,
2256                 }
2257         }
2258 }
2259 #[allow(unused)]
2260 /// Used only if an object of this type is returned as a trait impl by a method
2261 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2262         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
2263 }
2264 #[no_mangle]
2265 /// Creates a copy of the UpdateFailHTLC
2266 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
2267         orig.clone()
2268 }
2269
2270 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
2271 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
2272
2273 /// An update_fail_malformed_htlc message to be sent or received from a peer
2274 #[must_use]
2275 #[repr(C)]
2276 pub struct UpdateFailMalformedHTLC {
2277         /// A pointer to the opaque Rust object.
2278
2279         /// Nearly everywhere, inner must be non-null, however in places where
2280         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2281         pub inner: *mut nativeUpdateFailMalformedHTLC,
2282         /// Indicates that this is the only struct which contains the same pointer.
2283
2284         /// Rust functions which take ownership of an object provided via an argument require
2285         /// this to be true and invalidate the object pointed to by inner.
2286         pub is_owned: bool,
2287 }
2288
2289 impl Drop for UpdateFailMalformedHTLC {
2290         fn drop(&mut self) {
2291                 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2292                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2293                 }
2294         }
2295 }
2296 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2297 #[no_mangle]
2298 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2299 #[allow(unused)]
2300 /// Used only if an object of this type is returned as a trait impl by a method
2301 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2302         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
2303 }
2304 #[allow(unused)]
2305 impl UpdateFailMalformedHTLC {
2306         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2307                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2308         }
2309         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2310                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2311         }
2312         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2313         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2314                 assert!(self.is_owned);
2315                 let ret = ObjOps::untweak_ptr(self.inner);
2316                 self.inner = core::ptr::null_mut();
2317                 ret
2318         }
2319 }
2320 /// The channel ID
2321 #[no_mangle]
2322 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2323         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2324         inner_val
2325 }
2326 /// The channel ID
2327 #[no_mangle]
2328 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2329         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2330 }
2331 /// The HTLC ID
2332 #[no_mangle]
2333 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2334         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2335         *inner_val
2336 }
2337 /// The HTLC ID
2338 #[no_mangle]
2339 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2340         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2341 }
2342 /// The failure code
2343 #[no_mangle]
2344 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2345         let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2346         *inner_val
2347 }
2348 /// The failure code
2349 #[no_mangle]
2350 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2351         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2352 }
2353 impl Clone for UpdateFailMalformedHTLC {
2354         fn clone(&self) -> Self {
2355                 Self {
2356                         inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2357                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2358                         is_owned: true,
2359                 }
2360         }
2361 }
2362 #[allow(unused)]
2363 /// Used only if an object of this type is returned as a trait impl by a method
2364 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2365         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2366 }
2367 #[no_mangle]
2368 /// Creates a copy of the UpdateFailMalformedHTLC
2369 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2370         orig.clone()
2371 }
2372
2373 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2374 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
2375
2376 /// A commitment_signed message to be sent or received from a peer
2377 #[must_use]
2378 #[repr(C)]
2379 pub struct CommitmentSigned {
2380         /// A pointer to the opaque Rust object.
2381
2382         /// Nearly everywhere, inner must be non-null, however in places where
2383         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2384         pub inner: *mut nativeCommitmentSigned,
2385         /// Indicates that this is the only struct which contains the same pointer.
2386
2387         /// Rust functions which take ownership of an object provided via an argument require
2388         /// this to be true and invalidate the object pointed to by inner.
2389         pub is_owned: bool,
2390 }
2391
2392 impl Drop for CommitmentSigned {
2393         fn drop(&mut self) {
2394                 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2395                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2396                 }
2397         }
2398 }
2399 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2400 #[no_mangle]
2401 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2402 #[allow(unused)]
2403 /// Used only if an object of this type is returned as a trait impl by a method
2404 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2405         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
2406 }
2407 #[allow(unused)]
2408 impl CommitmentSigned {
2409         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2410                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2411         }
2412         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2413                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2414         }
2415         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2416         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2417                 assert!(self.is_owned);
2418                 let ret = ObjOps::untweak_ptr(self.inner);
2419                 self.inner = core::ptr::null_mut();
2420                 ret
2421         }
2422 }
2423 /// The channel ID
2424 #[no_mangle]
2425 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2426         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2427         inner_val
2428 }
2429 /// The channel ID
2430 #[no_mangle]
2431 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2432         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2433 }
2434 /// A signature on the commitment transaction
2435 #[no_mangle]
2436 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2437         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2438         crate::c_types::Signature::from_rust(&inner_val)
2439 }
2440 /// A signature on the commitment transaction
2441 #[no_mangle]
2442 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2443         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2444 }
2445 /// Signatures on the HTLC transactions
2446 ///
2447 /// Returns a copy of the field.
2448 #[no_mangle]
2449 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_SignatureZ {
2450         let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
2451         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Signature::from_rust(&item) }); };
2452         local_inner_val.into()
2453 }
2454 /// Signatures on the HTLC transactions
2455 #[no_mangle]
2456 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2457         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2458         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2459 }
2460 /// Constructs a new CommitmentSigned given each field
2461 #[must_use]
2462 #[no_mangle]
2463 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 {
2464         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() }); };
2465         CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2466                 channel_id: channel_id_arg.data,
2467                 signature: signature_arg.into_rust(),
2468                 htlc_signatures: local_htlc_signatures_arg,
2469         }), is_owned: true }
2470 }
2471 impl Clone for CommitmentSigned {
2472         fn clone(&self) -> Self {
2473                 Self {
2474                         inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2475                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2476                         is_owned: true,
2477                 }
2478         }
2479 }
2480 #[allow(unused)]
2481 /// Used only if an object of this type is returned as a trait impl by a method
2482 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2483         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2484 }
2485 #[no_mangle]
2486 /// Creates a copy of the CommitmentSigned
2487 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2488         orig.clone()
2489 }
2490
2491 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2492 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
2493
2494 /// A revoke_and_ack message to be sent or received from a peer
2495 #[must_use]
2496 #[repr(C)]
2497 pub struct RevokeAndACK {
2498         /// A pointer to the opaque Rust object.
2499
2500         /// Nearly everywhere, inner must be non-null, however in places where
2501         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2502         pub inner: *mut nativeRevokeAndACK,
2503         /// Indicates that this is the only struct which contains the same pointer.
2504
2505         /// Rust functions which take ownership of an object provided via an argument require
2506         /// this to be true and invalidate the object pointed to by inner.
2507         pub is_owned: bool,
2508 }
2509
2510 impl Drop for RevokeAndACK {
2511         fn drop(&mut self) {
2512                 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2513                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2514                 }
2515         }
2516 }
2517 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2518 #[no_mangle]
2519 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2520 #[allow(unused)]
2521 /// Used only if an object of this type is returned as a trait impl by a method
2522 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2523         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
2524 }
2525 #[allow(unused)]
2526 impl RevokeAndACK {
2527         pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2528                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2529         }
2530         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2531                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2532         }
2533         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2534         pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2535                 assert!(self.is_owned);
2536                 let ret = ObjOps::untweak_ptr(self.inner);
2537                 self.inner = core::ptr::null_mut();
2538                 ret
2539         }
2540 }
2541 /// The channel ID
2542 #[no_mangle]
2543 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2544         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2545         inner_val
2546 }
2547 /// The channel ID
2548 #[no_mangle]
2549 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2550         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2551 }
2552 /// The secret corresponding to the per-commitment point
2553 #[no_mangle]
2554 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2555         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2556         inner_val
2557 }
2558 /// The secret corresponding to the per-commitment point
2559 #[no_mangle]
2560 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2561         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2562 }
2563 /// The next sender-broadcast commitment transaction's per-commitment point
2564 #[no_mangle]
2565 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2566         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2567         crate::c_types::PublicKey::from_rust(&inner_val)
2568 }
2569 /// The next sender-broadcast commitment transaction's per-commitment point
2570 #[no_mangle]
2571 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2572         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2573 }
2574 /// Constructs a new RevokeAndACK given each field
2575 #[must_use]
2576 #[no_mangle]
2577 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 {
2578         RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2579                 channel_id: channel_id_arg.data,
2580                 per_commitment_secret: per_commitment_secret_arg.data,
2581                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2582         }), is_owned: true }
2583 }
2584 impl Clone for RevokeAndACK {
2585         fn clone(&self) -> Self {
2586                 Self {
2587                         inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
2588                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2589                         is_owned: true,
2590                 }
2591         }
2592 }
2593 #[allow(unused)]
2594 /// Used only if an object of this type is returned as a trait impl by a method
2595 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2596         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2597 }
2598 #[no_mangle]
2599 /// Creates a copy of the RevokeAndACK
2600 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2601         orig.clone()
2602 }
2603
2604 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2605 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
2606
2607 /// An update_fee message to be sent or received from a peer
2608 #[must_use]
2609 #[repr(C)]
2610 pub struct UpdateFee {
2611         /// A pointer to the opaque Rust object.
2612
2613         /// Nearly everywhere, inner must be non-null, however in places where
2614         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2615         pub inner: *mut nativeUpdateFee,
2616         /// Indicates that this is the only struct which contains the same pointer.
2617
2618         /// Rust functions which take ownership of an object provided via an argument require
2619         /// this to be true and invalidate the object pointed to by inner.
2620         pub is_owned: bool,
2621 }
2622
2623 impl Drop for UpdateFee {
2624         fn drop(&mut self) {
2625                 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2626                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2627                 }
2628         }
2629 }
2630 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2631 #[no_mangle]
2632 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2633 #[allow(unused)]
2634 /// Used only if an object of this type is returned as a trait impl by a method
2635 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2636         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
2637 }
2638 #[allow(unused)]
2639 impl UpdateFee {
2640         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2641                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2642         }
2643         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2644                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2645         }
2646         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2647         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2648                 assert!(self.is_owned);
2649                 let ret = ObjOps::untweak_ptr(self.inner);
2650                 self.inner = core::ptr::null_mut();
2651                 ret
2652         }
2653 }
2654 /// The channel ID
2655 #[no_mangle]
2656 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2657         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2658         inner_val
2659 }
2660 /// The channel ID
2661 #[no_mangle]
2662 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2663         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2664 }
2665 /// Fee rate per 1000-weight of the transaction
2666 #[no_mangle]
2667 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2668         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2669         *inner_val
2670 }
2671 /// Fee rate per 1000-weight of the transaction
2672 #[no_mangle]
2673 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2674         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2675 }
2676 /// Constructs a new UpdateFee given each field
2677 #[must_use]
2678 #[no_mangle]
2679 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2680         UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2681                 channel_id: channel_id_arg.data,
2682                 feerate_per_kw: feerate_per_kw_arg,
2683         }), is_owned: true }
2684 }
2685 impl Clone for UpdateFee {
2686         fn clone(&self) -> Self {
2687                 Self {
2688                         inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
2689                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2690                         is_owned: true,
2691                 }
2692         }
2693 }
2694 #[allow(unused)]
2695 /// Used only if an object of this type is returned as a trait impl by a method
2696 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
2697         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
2698 }
2699 #[no_mangle]
2700 /// Creates a copy of the UpdateFee
2701 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
2702         orig.clone()
2703 }
2704
2705 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
2706 pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport;
2707
2708 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2709 /// This is used to convince the recipient that the channel is at a certain commitment
2710 /// number even if they lost that data due to a local failure.  Of course, the peer may lie
2711 /// and even later commitments may have been revoked.
2712 #[must_use]
2713 #[repr(C)]
2714 pub struct DataLossProtect {
2715         /// A pointer to the opaque Rust object.
2716
2717         /// Nearly everywhere, inner must be non-null, however in places where
2718         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2719         pub inner: *mut nativeDataLossProtect,
2720         /// Indicates that this is the only struct which contains the same pointer.
2721
2722         /// Rust functions which take ownership of an object provided via an argument require
2723         /// this to be true and invalidate the object pointed to by inner.
2724         pub is_owned: bool,
2725 }
2726
2727 impl Drop for DataLossProtect {
2728         fn drop(&mut self) {
2729                 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
2730                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2731                 }
2732         }
2733 }
2734 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
2735 #[no_mangle]
2736 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
2737 #[allow(unused)]
2738 /// Used only if an object of this type is returned as a trait impl by a method
2739 pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2740         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2741 }
2742 #[allow(unused)]
2743 impl DataLossProtect {
2744         pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
2745                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2746         }
2747         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
2748                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2749         }
2750         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2751         pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2752                 assert!(self.is_owned);
2753                 let ret = ObjOps::untweak_ptr(self.inner);
2754                 self.inner = core::ptr::null_mut();
2755                 ret
2756         }
2757 }
2758 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2759 /// belonging to the recipient
2760 #[no_mangle]
2761 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2762         let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
2763         inner_val
2764 }
2765 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2766 /// belonging to the recipient
2767 #[no_mangle]
2768 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2769         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
2770 }
2771 /// The sender's per-commitment point for their current commitment transaction
2772 #[no_mangle]
2773 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2774         let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
2775         crate::c_types::PublicKey::from_rust(&inner_val)
2776 }
2777 /// The sender's per-commitment point for their current commitment transaction
2778 #[no_mangle]
2779 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2780         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
2781 }
2782 /// Constructs a new DataLossProtect given each field
2783 #[must_use]
2784 #[no_mangle]
2785 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 {
2786         DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
2787                 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2788                 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2789         }), is_owned: true }
2790 }
2791 impl Clone for DataLossProtect {
2792         fn clone(&self) -> Self {
2793                 Self {
2794                         inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else {
2795                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2796                         is_owned: true,
2797                 }
2798         }
2799 }
2800 #[allow(unused)]
2801 /// Used only if an object of this type is returned as a trait impl by a method
2802 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2803         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2804 }
2805 #[no_mangle]
2806 /// Creates a copy of the DataLossProtect
2807 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2808         orig.clone()
2809 }
2810
2811 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2812 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
2813
2814 /// A channel_reestablish message to be sent or received from a peer
2815 #[must_use]
2816 #[repr(C)]
2817 pub struct ChannelReestablish {
2818         /// A pointer to the opaque Rust object.
2819
2820         /// Nearly everywhere, inner must be non-null, however in places where
2821         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2822         pub inner: *mut nativeChannelReestablish,
2823         /// Indicates that this is the only struct which contains the same pointer.
2824
2825         /// Rust functions which take ownership of an object provided via an argument require
2826         /// this to be true and invalidate the object pointed to by inner.
2827         pub is_owned: bool,
2828 }
2829
2830 impl Drop for ChannelReestablish {
2831         fn drop(&mut self) {
2832                 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
2833                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2834                 }
2835         }
2836 }
2837 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
2838 #[no_mangle]
2839 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
2840 #[allow(unused)]
2841 /// Used only if an object of this type is returned as a trait impl by a method
2842 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2843         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2844 }
2845 #[allow(unused)]
2846 impl ChannelReestablish {
2847         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
2848                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2849         }
2850         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
2851                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2852         }
2853         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2854         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2855                 assert!(self.is_owned);
2856                 let ret = ObjOps::untweak_ptr(self.inner);
2857                 self.inner = core::ptr::null_mut();
2858                 ret
2859         }
2860 }
2861 /// The channel ID
2862 #[no_mangle]
2863 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2864         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2865         inner_val
2866 }
2867 /// The channel ID
2868 #[no_mangle]
2869 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2870         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2871 }
2872 /// The next commitment number for the sender
2873 #[no_mangle]
2874 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2875         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
2876         *inner_val
2877 }
2878 /// The next commitment number for the sender
2879 #[no_mangle]
2880 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2881         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
2882 }
2883 /// The next commitment number for the recipient
2884 #[no_mangle]
2885 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2886         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
2887         *inner_val
2888 }
2889 /// The next commitment number for the recipient
2890 #[no_mangle]
2891 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2892         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
2893 }
2894 impl Clone for ChannelReestablish {
2895         fn clone(&self) -> Self {
2896                 Self {
2897                         inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
2898                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2899                         is_owned: true,
2900                 }
2901         }
2902 }
2903 #[allow(unused)]
2904 /// Used only if an object of this type is returned as a trait impl by a method
2905 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2906         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2907 }
2908 #[no_mangle]
2909 /// Creates a copy of the ChannelReestablish
2910 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2911         orig.clone()
2912 }
2913
2914 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2915 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2916
2917 /// An announcement_signatures message to be sent or received from a peer
2918 #[must_use]
2919 #[repr(C)]
2920 pub struct AnnouncementSignatures {
2921         /// A pointer to the opaque Rust object.
2922
2923         /// Nearly everywhere, inner must be non-null, however in places where
2924         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2925         pub inner: *mut nativeAnnouncementSignatures,
2926         /// Indicates that this is the only struct which contains the same pointer.
2927
2928         /// Rust functions which take ownership of an object provided via an argument require
2929         /// this to be true and invalidate the object pointed to by inner.
2930         pub is_owned: bool,
2931 }
2932
2933 impl Drop for AnnouncementSignatures {
2934         fn drop(&mut self) {
2935                 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
2936                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2937                 }
2938         }
2939 }
2940 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
2941 #[no_mangle]
2942 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
2943 #[allow(unused)]
2944 /// Used only if an object of this type is returned as a trait impl by a method
2945 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2946         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2947 }
2948 #[allow(unused)]
2949 impl AnnouncementSignatures {
2950         pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
2951                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2952         }
2953         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
2954                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2955         }
2956         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2957         pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2958                 assert!(self.is_owned);
2959                 let ret = ObjOps::untweak_ptr(self.inner);
2960                 self.inner = core::ptr::null_mut();
2961                 ret
2962         }
2963 }
2964 /// The channel ID
2965 #[no_mangle]
2966 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2967         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2968         inner_val
2969 }
2970 /// The channel ID
2971 #[no_mangle]
2972 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2973         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2974 }
2975 /// The short channel ID
2976 #[no_mangle]
2977 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2978         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
2979         *inner_val
2980 }
2981 /// The short channel ID
2982 #[no_mangle]
2983 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2984         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
2985 }
2986 /// A signature by the node key
2987 #[no_mangle]
2988 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2989         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
2990         crate::c_types::Signature::from_rust(&inner_val)
2991 }
2992 /// A signature by the node key
2993 #[no_mangle]
2994 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2995         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
2996 }
2997 /// A signature by the funding key
2998 #[no_mangle]
2999 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
3000         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
3001         crate::c_types::Signature::from_rust(&inner_val)
3002 }
3003 /// A signature by the funding key
3004 #[no_mangle]
3005 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
3006         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
3007 }
3008 /// Constructs a new AnnouncementSignatures given each field
3009 #[must_use]
3010 #[no_mangle]
3011 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 {
3012         AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
3013                 channel_id: channel_id_arg.data,
3014                 short_channel_id: short_channel_id_arg,
3015                 node_signature: node_signature_arg.into_rust(),
3016                 bitcoin_signature: bitcoin_signature_arg.into_rust(),
3017         }), is_owned: true }
3018 }
3019 impl Clone for AnnouncementSignatures {
3020         fn clone(&self) -> Self {
3021                 Self {
3022                         inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3023                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3024                         is_owned: true,
3025                 }
3026         }
3027 }
3028 #[allow(unused)]
3029 /// Used only if an object of this type is returned as a trait impl by a method
3030 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3031         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
3032 }
3033 #[no_mangle]
3034 /// Creates a copy of the AnnouncementSignatures
3035 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
3036         orig.clone()
3037 }
3038 /// An address which can be used to connect to a remote peer
3039 #[derive(Clone)]
3040 #[must_use]
3041 #[repr(C)]
3042 pub enum NetAddress {
3043         /// An IPv4 address/port on which the peer is listening.
3044         IPv4 {
3045                 /// The 4-byte IPv4 address
3046                 addr: crate::c_types::FourBytes,
3047                 /// The port on which the node is listening
3048                 port: u16,
3049         },
3050         /// An IPv6 address/port on which the peer is listening.
3051         IPv6 {
3052                 /// The 16-byte IPv6 address
3053                 addr: crate::c_types::SixteenBytes,
3054                 /// The port on which the node is listening
3055                 port: u16,
3056         },
3057         /// An old-style Tor onion address/port on which the peer is listening.
3058         ///
3059         /// This field is deprecated and the Tor network generally no longer supports V2 Onion
3060         /// addresses. Thus, the details are not parsed here.
3061         OnionV2(
3062                 crate::c_types::TwelveBytes),
3063         /// A new-style Tor onion address/port on which the peer is listening.
3064         /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
3065         /// wrap as base32 and append \".onion\".
3066         OnionV3 {
3067                 /// The ed25519 long-term public key of the peer
3068                 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
3069                 /// The checksum of the pubkey and version, as included in the onion address
3070                 checksum: u16,
3071                 /// The version byte, as defined by the Tor Onion v3 spec.
3072                 version: u8,
3073                 /// The port on which the node is listening
3074                 port: u16,
3075         },
3076         /// A hostname/port on which the peer is listening.
3077         Hostname {
3078                 /// The hostname on which the node is listening.
3079                 hostname: crate::lightning::util::ser::Hostname,
3080                 /// The port on which the node is listening.
3081                 port: u16,
3082         },
3083 }
3084 use lightning::ln::msgs::NetAddress as NetAddressImport;
3085 pub(crate) type nativeNetAddress = NetAddressImport;
3086
3087 impl NetAddress {
3088         #[allow(unused)]
3089         pub(crate) fn to_native(&self) -> nativeNetAddress {
3090                 match self {
3091                         NetAddress::IPv4 {ref addr, ref port, } => {
3092                                 let mut addr_nonref = (*addr).clone();
3093                                 let mut port_nonref = (*port).clone();
3094                                 nativeNetAddress::IPv4 {
3095                                         addr: addr_nonref.data,
3096                                         port: port_nonref,
3097                                 }
3098                         },
3099                         NetAddress::IPv6 {ref addr, ref port, } => {
3100                                 let mut addr_nonref = (*addr).clone();
3101                                 let mut port_nonref = (*port).clone();
3102                                 nativeNetAddress::IPv6 {
3103                                         addr: addr_nonref.data,
3104                                         port: port_nonref,
3105                                 }
3106                         },
3107                         NetAddress::OnionV2 (ref a, ) => {
3108                                 let mut a_nonref = (*a).clone();
3109                                 nativeNetAddress::OnionV2 (
3110                                         a_nonref.data,
3111                                 )
3112                         },
3113                         NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3114                                 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
3115                                 let mut checksum_nonref = (*checksum).clone();
3116                                 let mut version_nonref = (*version).clone();
3117                                 let mut port_nonref = (*port).clone();
3118                                 nativeNetAddress::OnionV3 {
3119                                         ed25519_pubkey: ed25519_pubkey_nonref.data,
3120                                         checksum: checksum_nonref,
3121                                         version: version_nonref,
3122                                         port: port_nonref,
3123                                 }
3124                         },
3125                         NetAddress::Hostname {ref hostname, ref port, } => {
3126                                 let mut hostname_nonref = (*hostname).clone();
3127                                 let mut port_nonref = (*port).clone();
3128                                 nativeNetAddress::Hostname {
3129                                         hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
3130                                         port: port_nonref,
3131                                 }
3132                         },
3133                 }
3134         }
3135         #[allow(unused)]
3136         pub(crate) fn into_native(self) -> nativeNetAddress {
3137                 match self {
3138                         NetAddress::IPv4 {mut addr, mut port, } => {
3139                                 nativeNetAddress::IPv4 {
3140                                         addr: addr.data,
3141                                         port: port,
3142                                 }
3143                         },
3144                         NetAddress::IPv6 {mut addr, mut port, } => {
3145                                 nativeNetAddress::IPv6 {
3146                                         addr: addr.data,
3147                                         port: port,
3148                                 }
3149                         },
3150                         NetAddress::OnionV2 (mut a, ) => {
3151                                 nativeNetAddress::OnionV2 (
3152                                         a.data,
3153                                 )
3154                         },
3155                         NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3156                                 nativeNetAddress::OnionV3 {
3157                                         ed25519_pubkey: ed25519_pubkey.data,
3158                                         checksum: checksum,
3159                                         version: version,
3160                                         port: port,
3161                                 }
3162                         },
3163                         NetAddress::Hostname {mut hostname, mut port, } => {
3164                                 nativeNetAddress::Hostname {
3165                                         hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
3166                                         port: port,
3167                                 }
3168                         },
3169                 }
3170         }
3171         #[allow(unused)]
3172         pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
3173                 match native {
3174                         nativeNetAddress::IPv4 {ref addr, ref port, } => {
3175                                 let mut addr_nonref = (*addr).clone();
3176                                 let mut port_nonref = (*port).clone();
3177                                 NetAddress::IPv4 {
3178                                         addr: crate::c_types::FourBytes { data: addr_nonref },
3179                                         port: port_nonref,
3180                                 }
3181                         },
3182                         nativeNetAddress::IPv6 {ref addr, ref port, } => {
3183                                 let mut addr_nonref = (*addr).clone();
3184                                 let mut port_nonref = (*port).clone();
3185                                 NetAddress::IPv6 {
3186                                         addr: crate::c_types::SixteenBytes { data: addr_nonref },
3187                                         port: port_nonref,
3188                                 }
3189                         },
3190                         nativeNetAddress::OnionV2 (ref a, ) => {
3191                                 let mut a_nonref = (*a).clone();
3192                                 NetAddress::OnionV2 (
3193                                         crate::c_types::TwelveBytes { data: a_nonref },
3194                                 )
3195                         },
3196                         nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3197                                 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
3198                                 let mut checksum_nonref = (*checksum).clone();
3199                                 let mut version_nonref = (*version).clone();
3200                                 let mut port_nonref = (*port).clone();
3201                                 NetAddress::OnionV3 {
3202                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
3203                                         checksum: checksum_nonref,
3204                                         version: version_nonref,
3205                                         port: port_nonref,
3206                                 }
3207                         },
3208                         nativeNetAddress::Hostname {ref hostname, ref port, } => {
3209                                 let mut hostname_nonref = (*hostname).clone();
3210                                 let mut port_nonref = (*port).clone();
3211                                 NetAddress::Hostname {
3212                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
3213                                         port: port_nonref,
3214                                 }
3215                         },
3216                 }
3217         }
3218         #[allow(unused)]
3219         pub(crate) fn native_into(native: nativeNetAddress) -> Self {
3220                 match native {
3221                         nativeNetAddress::IPv4 {mut addr, mut port, } => {
3222                                 NetAddress::IPv4 {
3223                                         addr: crate::c_types::FourBytes { data: addr },
3224                                         port: port,
3225                                 }
3226                         },
3227                         nativeNetAddress::IPv6 {mut addr, mut port, } => {
3228                                 NetAddress::IPv6 {
3229                                         addr: crate::c_types::SixteenBytes { data: addr },
3230                                         port: port,
3231                                 }
3232                         },
3233                         nativeNetAddress::OnionV2 (mut a, ) => {
3234                                 NetAddress::OnionV2 (
3235                                         crate::c_types::TwelveBytes { data: a },
3236                                 )
3237                         },
3238                         nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3239                                 NetAddress::OnionV3 {
3240                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
3241                                         checksum: checksum,
3242                                         version: version,
3243                                         port: port,
3244                                 }
3245                         },
3246                         nativeNetAddress::Hostname {mut hostname, mut port, } => {
3247                                 NetAddress::Hostname {
3248                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
3249                                         port: port,
3250                                 }
3251                         },
3252                 }
3253         }
3254 }
3255 /// Frees any resources used by the NetAddress
3256 #[no_mangle]
3257 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
3258 /// Creates a copy of the NetAddress
3259 #[no_mangle]
3260 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
3261         orig.clone()
3262 }
3263 #[no_mangle]
3264 /// Utility method to constructs a new IPv4-variant NetAddress
3265 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
3266         NetAddress::IPv4 {
3267                 addr,
3268                 port,
3269         }
3270 }
3271 #[no_mangle]
3272 /// Utility method to constructs a new IPv6-variant NetAddress
3273 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
3274         NetAddress::IPv6 {
3275                 addr,
3276                 port,
3277         }
3278 }
3279 #[no_mangle]
3280 /// Utility method to constructs a new OnionV2-variant NetAddress
3281 pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
3282         NetAddress::OnionV2(a, )
3283 }
3284 #[no_mangle]
3285 /// Utility method to constructs a new OnionV3-variant NetAddress
3286 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
3287         NetAddress::OnionV3 {
3288                 ed25519_pubkey,
3289                 checksum,
3290                 version,
3291                 port,
3292         }
3293 }
3294 #[no_mangle]
3295 /// Utility method to constructs a new Hostname-variant NetAddress
3296 pub extern "C" fn NetAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> NetAddress {
3297         NetAddress::Hostname {
3298                 hostname,
3299                 port,
3300         }
3301 }
3302 #[no_mangle]
3303 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
3304 pub extern "C" fn NetAddress_write(obj: &crate::lightning::ln::msgs::NetAddress) -> crate::c_types::derived::CVec_u8Z {
3305         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
3306 }
3307 #[no_mangle]
3308 /// Read a NetAddress from a byte array, created by NetAddress_write
3309 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
3310         let res: Result<lightning::ln::msgs::NetAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3311         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() };
3312         local_res
3313 }
3314
3315 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
3316 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
3317
3318 /// The unsigned part of a node_announcement
3319 #[must_use]
3320 #[repr(C)]
3321 pub struct UnsignedNodeAnnouncement {
3322         /// A pointer to the opaque Rust object.
3323
3324         /// Nearly everywhere, inner must be non-null, however in places where
3325         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3326         pub inner: *mut nativeUnsignedNodeAnnouncement,
3327         /// Indicates that this is the only struct which contains the same pointer.
3328
3329         /// Rust functions which take ownership of an object provided via an argument require
3330         /// this to be true and invalidate the object pointed to by inner.
3331         pub is_owned: bool,
3332 }
3333
3334 impl Drop for UnsignedNodeAnnouncement {
3335         fn drop(&mut self) {
3336                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3337                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3338                 }
3339         }
3340 }
3341 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3342 #[no_mangle]
3343 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3344 #[allow(unused)]
3345 /// Used only if an object of this type is returned as a trait impl by a method
3346 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3347         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
3348 }
3349 #[allow(unused)]
3350 impl UnsignedNodeAnnouncement {
3351         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3352                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3353         }
3354         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3355                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3356         }
3357         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3358         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3359                 assert!(self.is_owned);
3360                 let ret = ObjOps::untweak_ptr(self.inner);
3361                 self.inner = core::ptr::null_mut();
3362                 ret
3363         }
3364 }
3365 /// The advertised features
3366 #[no_mangle]
3367 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3368         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3369         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 }
3370 }
3371 /// The advertised features
3372 #[no_mangle]
3373 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3374         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3375 }
3376 /// A strictly monotonic announcement counter, with gaps allowed
3377 #[no_mangle]
3378 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3379         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3380         *inner_val
3381 }
3382 /// A strictly monotonic announcement counter, with gaps allowed
3383 #[no_mangle]
3384 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3385         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3386 }
3387 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3388 /// to this node).
3389 #[no_mangle]
3390 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
3391         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3392         crate::c_types::PublicKey::from_rust(&inner_val)
3393 }
3394 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3395 /// to this node).
3396 #[no_mangle]
3397 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
3398         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
3399 }
3400 /// An RGB color for UI purposes
3401 #[no_mangle]
3402 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3403         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3404         inner_val
3405 }
3406 /// An RGB color for UI purposes
3407 #[no_mangle]
3408 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3409         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3410 }
3411 /// An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
3412 /// of uniqueness.
3413 #[no_mangle]
3414 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3415         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3416         inner_val
3417 }
3418 /// An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
3419 /// of uniqueness.
3420 #[no_mangle]
3421 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3422         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3423 }
3424 /// List of addresses on which this node is reachable
3425 ///
3426 /// Returns a copy of the field.
3427 #[no_mangle]
3428 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_NetAddressZ {
3429         let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
3430         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::NetAddress::native_into(item) }); };
3431         local_inner_val.into()
3432 }
3433 /// List of addresses on which this node is reachable
3434 #[no_mangle]
3435 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3436         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3437         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3438 }
3439 impl Clone for UnsignedNodeAnnouncement {
3440         fn clone(&self) -> Self {
3441                 Self {
3442                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3443                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3444                         is_owned: true,
3445                 }
3446         }
3447 }
3448 #[allow(unused)]
3449 /// Used only if an object of this type is returned as a trait impl by a method
3450 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3451         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3452 }
3453 #[no_mangle]
3454 /// Creates a copy of the UnsignedNodeAnnouncement
3455 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3456         orig.clone()
3457 }
3458
3459 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3460 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3461
3462 /// A node_announcement message to be sent or received from a peer
3463 #[must_use]
3464 #[repr(C)]
3465 pub struct NodeAnnouncement {
3466         /// A pointer to the opaque Rust object.
3467
3468         /// Nearly everywhere, inner must be non-null, however in places where
3469         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3470         pub inner: *mut nativeNodeAnnouncement,
3471         /// Indicates that this is the only struct which contains the same pointer.
3472
3473         /// Rust functions which take ownership of an object provided via an argument require
3474         /// this to be true and invalidate the object pointed to by inner.
3475         pub is_owned: bool,
3476 }
3477
3478 impl Drop for NodeAnnouncement {
3479         fn drop(&mut self) {
3480                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3481                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3482                 }
3483         }
3484 }
3485 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3486 #[no_mangle]
3487 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3488 #[allow(unused)]
3489 /// Used only if an object of this type is returned as a trait impl by a method
3490 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3491         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3492 }
3493 #[allow(unused)]
3494 impl NodeAnnouncement {
3495         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
3496                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3497         }
3498         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
3499                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3500         }
3501         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3502         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3503                 assert!(self.is_owned);
3504                 let ret = ObjOps::untweak_ptr(self.inner);
3505                 self.inner = core::ptr::null_mut();
3506                 ret
3507         }
3508 }
3509 /// The signature by the node key
3510 #[no_mangle]
3511 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3512         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3513         crate::c_types::Signature::from_rust(&inner_val)
3514 }
3515 /// The signature by the node key
3516 #[no_mangle]
3517 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3518         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3519 }
3520 /// The actual content of the announcement
3521 #[no_mangle]
3522 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3523         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3524         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 }
3525 }
3526 /// The actual content of the announcement
3527 #[no_mangle]
3528 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3529         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3530 }
3531 /// Constructs a new NodeAnnouncement given each field
3532 #[must_use]
3533 #[no_mangle]
3534 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3535         NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
3536                 signature: signature_arg.into_rust(),
3537                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3538         }), is_owned: true }
3539 }
3540 impl Clone for NodeAnnouncement {
3541         fn clone(&self) -> Self {
3542                 Self {
3543                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3544                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3545                         is_owned: true,
3546                 }
3547         }
3548 }
3549 #[allow(unused)]
3550 /// Used only if an object of this type is returned as a trait impl by a method
3551 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3552         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3553 }
3554 #[no_mangle]
3555 /// Creates a copy of the NodeAnnouncement
3556 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3557         orig.clone()
3558 }
3559
3560 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3561 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3562
3563 /// The unsigned part of a channel_announcement
3564 #[must_use]
3565 #[repr(C)]
3566 pub struct UnsignedChannelAnnouncement {
3567         /// A pointer to the opaque Rust object.
3568
3569         /// Nearly everywhere, inner must be non-null, however in places where
3570         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3571         pub inner: *mut nativeUnsignedChannelAnnouncement,
3572         /// Indicates that this is the only struct which contains the same pointer.
3573
3574         /// Rust functions which take ownership of an object provided via an argument require
3575         /// this to be true and invalidate the object pointed to by inner.
3576         pub is_owned: bool,
3577 }
3578
3579 impl Drop for UnsignedChannelAnnouncement {
3580         fn drop(&mut self) {
3581                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3582                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3583                 }
3584         }
3585 }
3586 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3587 #[no_mangle]
3588 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3589 #[allow(unused)]
3590 /// Used only if an object of this type is returned as a trait impl by a method
3591 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3592         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3593 }
3594 #[allow(unused)]
3595 impl UnsignedChannelAnnouncement {
3596         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
3597                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3598         }
3599         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
3600                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3601         }
3602         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3603         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3604                 assert!(self.is_owned);
3605                 let ret = ObjOps::untweak_ptr(self.inner);
3606                 self.inner = core::ptr::null_mut();
3607                 ret
3608         }
3609 }
3610 /// The advertised channel features
3611 #[no_mangle]
3612 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3613         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3614         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 }
3615 }
3616 /// The advertised channel features
3617 #[no_mangle]
3618 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3619         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3620 }
3621 /// The genesis hash of the blockchain where the channel is to be opened
3622 #[no_mangle]
3623 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3624         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3625         inner_val.as_inner()
3626 }
3627 /// The genesis hash of the blockchain where the channel is to be opened
3628 #[no_mangle]
3629 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3630         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3631 }
3632 /// The short channel ID
3633 #[no_mangle]
3634 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3635         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3636         *inner_val
3637 }
3638 /// The short channel ID
3639 #[no_mangle]
3640 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3641         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3642 }
3643 /// One of the two node_ids which are endpoints of this channel
3644 #[no_mangle]
3645 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3646         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
3647         crate::c_types::PublicKey::from_rust(&inner_val)
3648 }
3649 /// One of the two node_ids which are endpoints of this channel
3650 #[no_mangle]
3651 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3652         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = val.into_rust();
3653 }
3654 /// The other of the two node_ids which are endpoints of this channel
3655 #[no_mangle]
3656 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3657         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
3658         crate::c_types::PublicKey::from_rust(&inner_val)
3659 }
3660 /// The other of the two node_ids which are endpoints of this channel
3661 #[no_mangle]
3662 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3663         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = val.into_rust();
3664 }
3665 /// The funding key for the first node
3666 #[no_mangle]
3667 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3668         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
3669         crate::c_types::PublicKey::from_rust(&inner_val)
3670 }
3671 /// The funding key for the first node
3672 #[no_mangle]
3673 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3674         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = val.into_rust();
3675 }
3676 /// The funding key for the second node
3677 #[no_mangle]
3678 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3679         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
3680         crate::c_types::PublicKey::from_rust(&inner_val)
3681 }
3682 /// The funding key for the second node
3683 #[no_mangle]
3684 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3685         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = val.into_rust();
3686 }
3687 impl Clone for UnsignedChannelAnnouncement {
3688         fn clone(&self) -> Self {
3689                 Self {
3690                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3691                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3692                         is_owned: true,
3693                 }
3694         }
3695 }
3696 #[allow(unused)]
3697 /// Used only if an object of this type is returned as a trait impl by a method
3698 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3699         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3700 }
3701 #[no_mangle]
3702 /// Creates a copy of the UnsignedChannelAnnouncement
3703 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3704         orig.clone()
3705 }
3706
3707 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3708 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3709
3710 /// A channel_announcement message to be sent or received from a peer
3711 #[must_use]
3712 #[repr(C)]
3713 pub struct ChannelAnnouncement {
3714         /// A pointer to the opaque Rust object.
3715
3716         /// Nearly everywhere, inner must be non-null, however in places where
3717         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3718         pub inner: *mut nativeChannelAnnouncement,
3719         /// Indicates that this is the only struct which contains the same pointer.
3720
3721         /// Rust functions which take ownership of an object provided via an argument require
3722         /// this to be true and invalidate the object pointed to by inner.
3723         pub is_owned: bool,
3724 }
3725
3726 impl Drop for ChannelAnnouncement {
3727         fn drop(&mut self) {
3728                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3729                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3730                 }
3731         }
3732 }
3733 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3734 #[no_mangle]
3735 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3736 #[allow(unused)]
3737 /// Used only if an object of this type is returned as a trait impl by a method
3738 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3739         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3740 }
3741 #[allow(unused)]
3742 impl ChannelAnnouncement {
3743         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
3744                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3745         }
3746         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
3747                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3748         }
3749         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3750         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3751                 assert!(self.is_owned);
3752                 let ret = ObjOps::untweak_ptr(self.inner);
3753                 self.inner = core::ptr::null_mut();
3754                 ret
3755         }
3756 }
3757 /// Authentication of the announcement by the first public node
3758 #[no_mangle]
3759 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3760         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
3761         crate::c_types::Signature::from_rust(&inner_val)
3762 }
3763 /// Authentication of the announcement by the first public node
3764 #[no_mangle]
3765 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3766         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
3767 }
3768 /// Authentication of the announcement by the second public node
3769 #[no_mangle]
3770 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3771         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
3772         crate::c_types::Signature::from_rust(&inner_val)
3773 }
3774 /// Authentication of the announcement by the second public node
3775 #[no_mangle]
3776 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3777         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
3778 }
3779 /// Proof of funding UTXO ownership by the first public node
3780 #[no_mangle]
3781 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3782         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
3783         crate::c_types::Signature::from_rust(&inner_val)
3784 }
3785 /// Proof of funding UTXO ownership by the first public node
3786 #[no_mangle]
3787 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3788         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
3789 }
3790 /// Proof of funding UTXO ownership by the second public node
3791 #[no_mangle]
3792 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3793         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
3794         crate::c_types::Signature::from_rust(&inner_val)
3795 }
3796 /// Proof of funding UTXO ownership by the second public node
3797 #[no_mangle]
3798 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3799         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
3800 }
3801 /// The actual announcement
3802 #[no_mangle]
3803 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3804         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3805         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 }
3806 }
3807 /// The actual announcement
3808 #[no_mangle]
3809 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3810         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3811 }
3812 /// Constructs a new ChannelAnnouncement given each field
3813 #[must_use]
3814 #[no_mangle]
3815 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 {
3816         ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
3817                 node_signature_1: node_signature_1_arg.into_rust(),
3818                 node_signature_2: node_signature_2_arg.into_rust(),
3819                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3820                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3821                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3822         }), is_owned: true }
3823 }
3824 impl Clone for ChannelAnnouncement {
3825         fn clone(&self) -> Self {
3826                 Self {
3827                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3828                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3829                         is_owned: true,
3830                 }
3831         }
3832 }
3833 #[allow(unused)]
3834 /// Used only if an object of this type is returned as a trait impl by a method
3835 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3836         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3837 }
3838 #[no_mangle]
3839 /// Creates a copy of the ChannelAnnouncement
3840 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3841         orig.clone()
3842 }
3843
3844 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3845 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3846
3847 /// The unsigned part of a channel_update
3848 #[must_use]
3849 #[repr(C)]
3850 pub struct UnsignedChannelUpdate {
3851         /// A pointer to the opaque Rust object.
3852
3853         /// Nearly everywhere, inner must be non-null, however in places where
3854         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3855         pub inner: *mut nativeUnsignedChannelUpdate,
3856         /// Indicates that this is the only struct which contains the same pointer.
3857
3858         /// Rust functions which take ownership of an object provided via an argument require
3859         /// this to be true and invalidate the object pointed to by inner.
3860         pub is_owned: bool,
3861 }
3862
3863 impl Drop for UnsignedChannelUpdate {
3864         fn drop(&mut self) {
3865                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3866                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3867                 }
3868         }
3869 }
3870 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3871 #[no_mangle]
3872 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3873 #[allow(unused)]
3874 /// Used only if an object of this type is returned as a trait impl by a method
3875 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3876         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3877 }
3878 #[allow(unused)]
3879 impl UnsignedChannelUpdate {
3880         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
3881                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3882         }
3883         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
3884                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3885         }
3886         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3887         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3888                 assert!(self.is_owned);
3889                 let ret = ObjOps::untweak_ptr(self.inner);
3890                 self.inner = core::ptr::null_mut();
3891                 ret
3892         }
3893 }
3894 /// The genesis hash of the blockchain where the channel is to be opened
3895 #[no_mangle]
3896 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3897         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3898         inner_val.as_inner()
3899 }
3900 /// The genesis hash of the blockchain where the channel is to be opened
3901 #[no_mangle]
3902 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3903         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3904 }
3905 /// The short channel ID
3906 #[no_mangle]
3907 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3908         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3909         *inner_val
3910 }
3911 /// The short channel ID
3912 #[no_mangle]
3913 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3914         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3915 }
3916 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3917 #[no_mangle]
3918 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3919         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3920         *inner_val
3921 }
3922 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3923 #[no_mangle]
3924 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3925         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3926 }
3927 /// Channel flags
3928 #[no_mangle]
3929 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3930         let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
3931         *inner_val
3932 }
3933 /// Channel flags
3934 #[no_mangle]
3935 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3936         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
3937 }
3938 /// The number of blocks such that if:
3939 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3940 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3941 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3942 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3943 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3944 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3945 /// constructing the route.
3946 #[no_mangle]
3947 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3948         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
3949         *inner_val
3950 }
3951 /// The number of blocks such that if:
3952 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3953 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3954 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3955 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3956 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3957 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3958 /// constructing the route.
3959 #[no_mangle]
3960 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3961         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
3962 }
3963 /// The minimum HTLC size incoming to sender, in milli-satoshi
3964 #[no_mangle]
3965 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3966         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
3967         *inner_val
3968 }
3969 /// The minimum HTLC size incoming to sender, in milli-satoshi
3970 #[no_mangle]
3971 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3972         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
3973 }
3974 /// The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
3975 #[no_mangle]
3976 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3977         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
3978         *inner_val
3979 }
3980 /// The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
3981 #[no_mangle]
3982 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3983         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
3984 }
3985 /// The base HTLC fee charged by sender, in milli-satoshi
3986 #[no_mangle]
3987 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3988         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
3989         *inner_val
3990 }
3991 /// The base HTLC fee charged by sender, in milli-satoshi
3992 #[no_mangle]
3993 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3994         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
3995 }
3996 /// The amount to fee multiplier, in micro-satoshi
3997 #[no_mangle]
3998 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3999         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
4000         *inner_val
4001 }
4002 /// The amount to fee multiplier, in micro-satoshi
4003 #[no_mangle]
4004 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
4005         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
4006 }
4007 /// Excess data which was signed as a part of the message which we do not (yet) understand how
4008 /// to decode. This is stored to ensure forward-compatibility as new fields are added to the
4009 /// lightning gossip
4010 ///
4011 /// Returns a copy of the field.
4012 #[no_mangle]
4013 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4014         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
4015         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4016         local_inner_val.into()
4017 }
4018 /// Excess data which was signed as a part of the message which we do not (yet) understand how
4019 /// to decode. This is stored to ensure forward-compatibility as new fields are added to the
4020 /// lightning gossip
4021 #[no_mangle]
4022 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
4023         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4024         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
4025 }
4026 /// Constructs a new UnsignedChannelUpdate given each field
4027 #[must_use]
4028 #[no_mangle]
4029 pub extern "C" fn UnsignedChannelUpdate_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut timestamp_arg: u32, mut flags_arg: u8, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelUpdate {
4030         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
4031         UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
4032                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4033                 short_channel_id: short_channel_id_arg,
4034                 timestamp: timestamp_arg,
4035                 flags: flags_arg,
4036                 cltv_expiry_delta: cltv_expiry_delta_arg,
4037                 htlc_minimum_msat: htlc_minimum_msat_arg,
4038                 htlc_maximum_msat: htlc_maximum_msat_arg,
4039                 fee_base_msat: fee_base_msat_arg,
4040                 fee_proportional_millionths: fee_proportional_millionths_arg,
4041                 excess_data: local_excess_data_arg,
4042         }), is_owned: true }
4043 }
4044 impl Clone for UnsignedChannelUpdate {
4045         fn clone(&self) -> Self {
4046                 Self {
4047                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4048                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4049                         is_owned: true,
4050                 }
4051         }
4052 }
4053 #[allow(unused)]
4054 /// Used only if an object of this type is returned as a trait impl by a method
4055 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4056         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
4057 }
4058 #[no_mangle]
4059 /// Creates a copy of the UnsignedChannelUpdate
4060 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
4061         orig.clone()
4062 }
4063
4064 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
4065 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
4066
4067 /// A channel_update message to be sent or received from a peer
4068 #[must_use]
4069 #[repr(C)]
4070 pub struct ChannelUpdate {
4071         /// A pointer to the opaque Rust object.
4072
4073         /// Nearly everywhere, inner must be non-null, however in places where
4074         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4075         pub inner: *mut nativeChannelUpdate,
4076         /// Indicates that this is the only struct which contains the same pointer.
4077
4078         /// Rust functions which take ownership of an object provided via an argument require
4079         /// this to be true and invalidate the object pointed to by inner.
4080         pub is_owned: bool,
4081 }
4082
4083 impl Drop for ChannelUpdate {
4084         fn drop(&mut self) {
4085                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
4086                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4087                 }
4088         }
4089 }
4090 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
4091 #[no_mangle]
4092 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
4093 #[allow(unused)]
4094 /// Used only if an object of this type is returned as a trait impl by a method
4095 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
4096         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
4097 }
4098 #[allow(unused)]
4099 impl ChannelUpdate {
4100         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
4101                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4102         }
4103         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
4104                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4105         }
4106         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4107         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
4108                 assert!(self.is_owned);
4109                 let ret = ObjOps::untweak_ptr(self.inner);
4110                 self.inner = core::ptr::null_mut();
4111                 ret
4112         }
4113 }
4114 /// A signature of the channel update
4115 #[no_mangle]
4116 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
4117         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4118         crate::c_types::Signature::from_rust(&inner_val)
4119 }
4120 /// A signature of the channel update
4121 #[no_mangle]
4122 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
4123         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4124 }
4125 /// The actual channel update
4126 #[no_mangle]
4127 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
4128         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
4129         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 }
4130 }
4131 /// The actual channel update
4132 #[no_mangle]
4133 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
4134         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
4135 }
4136 /// Constructs a new ChannelUpdate given each field
4137 #[must_use]
4138 #[no_mangle]
4139 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
4140         ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
4141                 signature: signature_arg.into_rust(),
4142                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
4143         }), is_owned: true }
4144 }
4145 impl Clone for ChannelUpdate {
4146         fn clone(&self) -> Self {
4147                 Self {
4148                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4149                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4150                         is_owned: true,
4151                 }
4152         }
4153 }
4154 #[allow(unused)]
4155 /// Used only if an object of this type is returned as a trait impl by a method
4156 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4157         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
4158 }
4159 #[no_mangle]
4160 /// Creates a copy of the ChannelUpdate
4161 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
4162         orig.clone()
4163 }
4164
4165 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
4166 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
4167
4168 /// A query_channel_range message is used to query a peer for channel
4169 /// UTXOs in a range of blocks. The recipient of a query makes a best
4170 /// effort to reply to the query using one or more reply_channel_range
4171 /// messages.
4172 #[must_use]
4173 #[repr(C)]
4174 pub struct QueryChannelRange {
4175         /// A pointer to the opaque Rust object.
4176
4177         /// Nearly everywhere, inner must be non-null, however in places where
4178         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4179         pub inner: *mut nativeQueryChannelRange,
4180         /// Indicates that this is the only struct which contains the same pointer.
4181
4182         /// Rust functions which take ownership of an object provided via an argument require
4183         /// this to be true and invalidate the object pointed to by inner.
4184         pub is_owned: bool,
4185 }
4186
4187 impl Drop for QueryChannelRange {
4188         fn drop(&mut self) {
4189                 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
4190                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4191                 }
4192         }
4193 }
4194 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
4195 #[no_mangle]
4196 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
4197 #[allow(unused)]
4198 /// Used only if an object of this type is returned as a trait impl by a method
4199 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
4200         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
4201 }
4202 #[allow(unused)]
4203 impl QueryChannelRange {
4204         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
4205                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4206         }
4207         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
4208                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4209         }
4210         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4211         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
4212                 assert!(self.is_owned);
4213                 let ret = ObjOps::untweak_ptr(self.inner);
4214                 self.inner = core::ptr::null_mut();
4215                 ret
4216         }
4217 }
4218 /// The genesis hash of the blockchain being queried
4219 #[no_mangle]
4220 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
4221         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4222         inner_val.as_inner()
4223 }
4224 /// The genesis hash of the blockchain being queried
4225 #[no_mangle]
4226 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4227         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4228 }
4229 /// The height of the first block for the channel UTXOs being queried
4230 #[no_mangle]
4231 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
4232         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4233         *inner_val
4234 }
4235 /// The height of the first block for the channel UTXOs being queried
4236 #[no_mangle]
4237 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
4238         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4239 }
4240 /// The number of blocks to include in the query results
4241 #[no_mangle]
4242 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
4243         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4244         *inner_val
4245 }
4246 /// The number of blocks to include in the query results
4247 #[no_mangle]
4248 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
4249         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4250 }
4251 /// Constructs a new QueryChannelRange given each field
4252 #[must_use]
4253 #[no_mangle]
4254 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 {
4255         QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
4256                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4257                 first_blocknum: first_blocknum_arg,
4258                 number_of_blocks: number_of_blocks_arg,
4259         }), is_owned: true }
4260 }
4261 impl Clone for QueryChannelRange {
4262         fn clone(&self) -> Self {
4263                 Self {
4264                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4265                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4266                         is_owned: true,
4267                 }
4268         }
4269 }
4270 #[allow(unused)]
4271 /// Used only if an object of this type is returned as a trait impl by a method
4272 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4273         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
4274 }
4275 #[no_mangle]
4276 /// Creates a copy of the QueryChannelRange
4277 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
4278         orig.clone()
4279 }
4280
4281 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
4282 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
4283
4284 /// A reply_channel_range message is a reply to a query_channel_range
4285 /// message. Multiple reply_channel_range messages can be sent in reply
4286 /// to a single query_channel_range message. The query recipient makes a
4287 /// best effort to respond based on their local network view which may
4288 /// not be a perfect view of the network. The short_channel_ids in the
4289 /// reply are encoded. We only support encoding_type=0 uncompressed
4290 /// serialization and do not support encoding_type=1 zlib serialization.
4291 #[must_use]
4292 #[repr(C)]
4293 pub struct ReplyChannelRange {
4294         /// A pointer to the opaque Rust object.
4295
4296         /// Nearly everywhere, inner must be non-null, however in places where
4297         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4298         pub inner: *mut nativeReplyChannelRange,
4299         /// Indicates that this is the only struct which contains the same pointer.
4300
4301         /// Rust functions which take ownership of an object provided via an argument require
4302         /// this to be true and invalidate the object pointed to by inner.
4303         pub is_owned: bool,
4304 }
4305
4306 impl Drop for ReplyChannelRange {
4307         fn drop(&mut self) {
4308                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
4309                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4310                 }
4311         }
4312 }
4313 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
4314 #[no_mangle]
4315 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
4316 #[allow(unused)]
4317 /// Used only if an object of this type is returned as a trait impl by a method
4318 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
4319         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
4320 }
4321 #[allow(unused)]
4322 impl ReplyChannelRange {
4323         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
4324                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4325         }
4326         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
4327                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4328         }
4329         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4330         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
4331                 assert!(self.is_owned);
4332                 let ret = ObjOps::untweak_ptr(self.inner);
4333                 self.inner = core::ptr::null_mut();
4334                 ret
4335         }
4336 }
4337 /// The genesis hash of the blockchain being queried
4338 #[no_mangle]
4339 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
4340         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4341         inner_val.as_inner()
4342 }
4343 /// The genesis hash of the blockchain being queried
4344 #[no_mangle]
4345 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4346         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4347 }
4348 /// The height of the first block in the range of the reply
4349 #[no_mangle]
4350 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
4351         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4352         *inner_val
4353 }
4354 /// The height of the first block in the range of the reply
4355 #[no_mangle]
4356 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4357         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4358 }
4359 /// The number of blocks included in the range of the reply
4360 #[no_mangle]
4361 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
4362         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4363         *inner_val
4364 }
4365 /// The number of blocks included in the range of the reply
4366 #[no_mangle]
4367 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4368         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4369 }
4370 /// True when this is the final reply for a query
4371 #[no_mangle]
4372 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
4373         let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
4374         *inner_val
4375 }
4376 /// True when this is the final reply for a query
4377 #[no_mangle]
4378 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4379         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4380 }
4381 /// The short_channel_ids in the channel range
4382 ///
4383 /// Returns a copy of the field.
4384 #[no_mangle]
4385 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
4386         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
4387         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4388         local_inner_val.into()
4389 }
4390 /// The short_channel_ids in the channel range
4391 #[no_mangle]
4392 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4393         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4394         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4395 }
4396 /// Constructs a new ReplyChannelRange given each field
4397 #[must_use]
4398 #[no_mangle]
4399 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 {
4400         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 }); };
4401         ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4402                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4403                 first_blocknum: first_blocknum_arg,
4404                 number_of_blocks: number_of_blocks_arg,
4405                 sync_complete: sync_complete_arg,
4406                 short_channel_ids: local_short_channel_ids_arg,
4407         }), is_owned: true }
4408 }
4409 impl Clone for ReplyChannelRange {
4410         fn clone(&self) -> Self {
4411                 Self {
4412                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4413                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4414                         is_owned: true,
4415                 }
4416         }
4417 }
4418 #[allow(unused)]
4419 /// Used only if an object of this type is returned as a trait impl by a method
4420 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4421         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
4422 }
4423 #[no_mangle]
4424 /// Creates a copy of the ReplyChannelRange
4425 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
4426         orig.clone()
4427 }
4428
4429 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
4430 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
4431
4432 /// A query_short_channel_ids message is used to query a peer for
4433 /// routing gossip messages related to one or more short_channel_ids.
4434 /// The query recipient will reply with the latest, if available,
4435 /// channel_announcement, channel_update and node_announcement messages
4436 /// it maintains for the requested short_channel_ids followed by a
4437 /// reply_short_channel_ids_end message. The short_channel_ids sent in
4438 /// this query are encoded. We only support encoding_type=0 uncompressed
4439 /// serialization and do not support encoding_type=1 zlib serialization.
4440 #[must_use]
4441 #[repr(C)]
4442 pub struct QueryShortChannelIds {
4443         /// A pointer to the opaque Rust object.
4444
4445         /// Nearly everywhere, inner must be non-null, however in places where
4446         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4447         pub inner: *mut nativeQueryShortChannelIds,
4448         /// Indicates that this is the only struct which contains the same pointer.
4449
4450         /// Rust functions which take ownership of an object provided via an argument require
4451         /// this to be true and invalidate the object pointed to by inner.
4452         pub is_owned: bool,
4453 }
4454
4455 impl Drop for QueryShortChannelIds {
4456         fn drop(&mut self) {
4457                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
4458                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4459                 }
4460         }
4461 }
4462 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
4463 #[no_mangle]
4464 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
4465 #[allow(unused)]
4466 /// Used only if an object of this type is returned as a trait impl by a method
4467 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
4468         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
4469 }
4470 #[allow(unused)]
4471 impl QueryShortChannelIds {
4472         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
4473                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4474         }
4475         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
4476                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4477         }
4478         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4479         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
4480                 assert!(self.is_owned);
4481                 let ret = ObjOps::untweak_ptr(self.inner);
4482                 self.inner = core::ptr::null_mut();
4483                 ret
4484         }
4485 }
4486 /// The genesis hash of the blockchain being queried
4487 #[no_mangle]
4488 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
4489         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4490         inner_val.as_inner()
4491 }
4492 /// The genesis hash of the blockchain being queried
4493 #[no_mangle]
4494 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
4495         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4496 }
4497 /// The short_channel_ids that are being queried
4498 ///
4499 /// Returns a copy of the field.
4500 #[no_mangle]
4501 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
4502         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
4503         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4504         local_inner_val.into()
4505 }
4506 /// The short_channel_ids that are being queried
4507 #[no_mangle]
4508 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
4509         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4510         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4511 }
4512 /// Constructs a new QueryShortChannelIds given each field
4513 #[must_use]
4514 #[no_mangle]
4515 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 {
4516         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 }); };
4517         QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
4518                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4519                 short_channel_ids: local_short_channel_ids_arg,
4520         }), is_owned: true }
4521 }
4522 impl Clone for QueryShortChannelIds {
4523         fn clone(&self) -> Self {
4524                 Self {
4525                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
4526                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4527                         is_owned: true,
4528                 }
4529         }
4530 }
4531 #[allow(unused)]
4532 /// Used only if an object of this type is returned as a trait impl by a method
4533 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
4534         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
4535 }
4536 #[no_mangle]
4537 /// Creates a copy of the QueryShortChannelIds
4538 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
4539         orig.clone()
4540 }
4541
4542 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
4543 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
4544
4545 /// A reply_short_channel_ids_end message is sent as a reply to a
4546 /// query_short_channel_ids message. The query recipient makes a best
4547 /// effort to respond based on their local network view which may not be
4548 /// a perfect view of the network.
4549 #[must_use]
4550 #[repr(C)]
4551 pub struct ReplyShortChannelIdsEnd {
4552         /// A pointer to the opaque Rust object.
4553
4554         /// Nearly everywhere, inner must be non-null, however in places where
4555         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4556         pub inner: *mut nativeReplyShortChannelIdsEnd,
4557         /// Indicates that this is the only struct which contains the same pointer.
4558
4559         /// Rust functions which take ownership of an object provided via an argument require
4560         /// this to be true and invalidate the object pointed to by inner.
4561         pub is_owned: bool,
4562 }
4563
4564 impl Drop for ReplyShortChannelIdsEnd {
4565         fn drop(&mut self) {
4566                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
4567                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4568                 }
4569         }
4570 }
4571 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
4572 #[no_mangle]
4573 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
4574 #[allow(unused)]
4575 /// Used only if an object of this type is returned as a trait impl by a method
4576 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
4577         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
4578 }
4579 #[allow(unused)]
4580 impl ReplyShortChannelIdsEnd {
4581         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
4582                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4583         }
4584         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
4585                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4586         }
4587         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4588         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
4589                 assert!(self.is_owned);
4590                 let ret = ObjOps::untweak_ptr(self.inner);
4591                 self.inner = core::ptr::null_mut();
4592                 ret
4593         }
4594 }
4595 /// The genesis hash of the blockchain that was queried
4596 #[no_mangle]
4597 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4598         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4599         inner_val.as_inner()
4600 }
4601 /// The genesis hash of the blockchain that was queried
4602 #[no_mangle]
4603 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4604         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4605 }
4606 /// Indicates if the query recipient maintains up-to-date channel
4607 /// information for the chain_hash
4608 #[no_mangle]
4609 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4610         let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
4611         *inner_val
4612 }
4613 /// Indicates if the query recipient maintains up-to-date channel
4614 /// information for the chain_hash
4615 #[no_mangle]
4616 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4617         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
4618 }
4619 /// Constructs a new ReplyShortChannelIdsEnd given each field
4620 #[must_use]
4621 #[no_mangle]
4622 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4623         ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
4624                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4625                 full_information: full_information_arg,
4626         }), is_owned: true }
4627 }
4628 impl Clone for ReplyShortChannelIdsEnd {
4629         fn clone(&self) -> Self {
4630                 Self {
4631                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
4632                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4633                         is_owned: true,
4634                 }
4635         }
4636 }
4637 #[allow(unused)]
4638 /// Used only if an object of this type is returned as a trait impl by a method
4639 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
4640         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
4641 }
4642 #[no_mangle]
4643 /// Creates a copy of the ReplyShortChannelIdsEnd
4644 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
4645         orig.clone()
4646 }
4647
4648 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
4649 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
4650
4651 /// A gossip_timestamp_filter message is used by a node to request
4652 /// gossip relay for messages in the requested time range when the
4653 /// gossip_queries feature has been negotiated.
4654 #[must_use]
4655 #[repr(C)]
4656 pub struct GossipTimestampFilter {
4657         /// A pointer to the opaque Rust object.
4658
4659         /// Nearly everywhere, inner must be non-null, however in places where
4660         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4661         pub inner: *mut nativeGossipTimestampFilter,
4662         /// Indicates that this is the only struct which contains the same pointer.
4663
4664         /// Rust functions which take ownership of an object provided via an argument require
4665         /// this to be true and invalidate the object pointed to by inner.
4666         pub is_owned: bool,
4667 }
4668
4669 impl Drop for GossipTimestampFilter {
4670         fn drop(&mut self) {
4671                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
4672                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4673                 }
4674         }
4675 }
4676 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
4677 #[no_mangle]
4678 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
4679 #[allow(unused)]
4680 /// Used only if an object of this type is returned as a trait impl by a method
4681 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
4682         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
4683 }
4684 #[allow(unused)]
4685 impl GossipTimestampFilter {
4686         pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
4687                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4688         }
4689         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
4690                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4691         }
4692         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4693         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
4694                 assert!(self.is_owned);
4695                 let ret = ObjOps::untweak_ptr(self.inner);
4696                 self.inner = core::ptr::null_mut();
4697                 ret
4698         }
4699 }
4700 /// The genesis hash of the blockchain for channel and node information
4701 #[no_mangle]
4702 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
4703         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4704         inner_val.as_inner()
4705 }
4706 /// The genesis hash of the blockchain for channel and node information
4707 #[no_mangle]
4708 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
4709         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4710 }
4711 /// The starting unix timestamp
4712 #[no_mangle]
4713 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
4714         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
4715         *inner_val
4716 }
4717 /// The starting unix timestamp
4718 #[no_mangle]
4719 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4720         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
4721 }
4722 /// The range of information in seconds
4723 #[no_mangle]
4724 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
4725         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
4726         *inner_val
4727 }
4728 /// The range of information in seconds
4729 #[no_mangle]
4730 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4731         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
4732 }
4733 /// Constructs a new GossipTimestampFilter given each field
4734 #[must_use]
4735 #[no_mangle]
4736 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 {
4737         GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
4738                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4739                 first_timestamp: first_timestamp_arg,
4740                 timestamp_range: timestamp_range_arg,
4741         }), is_owned: true }
4742 }
4743 impl Clone for GossipTimestampFilter {
4744         fn clone(&self) -> Self {
4745                 Self {
4746                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
4747                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4748                         is_owned: true,
4749                 }
4750         }
4751 }
4752 #[allow(unused)]
4753 /// Used only if an object of this type is returned as a trait impl by a method
4754 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
4755         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
4756 }
4757 #[no_mangle]
4758 /// Creates a copy of the GossipTimestampFilter
4759 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4760         orig.clone()
4761 }
4762 /// Used to put an error message in a LightningError
4763 #[derive(Clone)]
4764 #[must_use]
4765 #[repr(C)]
4766 pub enum ErrorAction {
4767         /// The peer took some action which made us think they were useless. Disconnect them.
4768         DisconnectPeer {
4769                 /// An error message which we should make an effort to send before we disconnect.
4770                 ///
4771                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4772                 msg: crate::lightning::ln::msgs::ErrorMessage,
4773         },
4774         /// The peer did something harmless that we weren't able to process, just log and ignore
4775         IgnoreError,
4776         /// The peer did something harmless that we weren't able to meaningfully process.
4777         /// If the error is logged, log it at the given level.
4778         IgnoreAndLog(
4779                 crate::lightning::util::logger::Level),
4780         /// The peer provided us with a gossip message which we'd already seen. In most cases this
4781         /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
4782         /// our own channel announcements.
4783         IgnoreDuplicateGossip,
4784         /// The peer did something incorrect. Tell them.
4785         SendErrorMessage {
4786                 /// The message to send.
4787                 msg: crate::lightning::ln::msgs::ErrorMessage,
4788         },
4789         /// The peer did something incorrect. Tell them without closing any channels.
4790         SendWarningMessage {
4791                 /// The message to send.
4792                 msg: crate::lightning::ln::msgs::WarningMessage,
4793                 /// The peer may have done something harmless that we weren't able to meaningfully process,
4794                 /// though we should still tell them about it.
4795                 /// If this event is logged, log it at the given level.
4796                 log_level: crate::lightning::util::logger::Level,
4797         },
4798 }
4799 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
4800 pub(crate) type nativeErrorAction = ErrorActionImport;
4801
4802 impl ErrorAction {
4803         #[allow(unused)]
4804         pub(crate) fn to_native(&self) -> nativeErrorAction {
4805                 match self {
4806                         ErrorAction::DisconnectPeer {ref msg, } => {
4807                                 let mut msg_nonref = (*msg).clone();
4808                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4809                                 nativeErrorAction::DisconnectPeer {
4810                                         msg: local_msg_nonref,
4811                                 }
4812                         },
4813                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4814                         ErrorAction::IgnoreAndLog (ref a, ) => {
4815                                 let mut a_nonref = (*a).clone();
4816                                 nativeErrorAction::IgnoreAndLog (
4817                                         a_nonref.into_native(),
4818                                 )
4819                         },
4820                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
4821                         ErrorAction::SendErrorMessage {ref msg, } => {
4822                                 let mut msg_nonref = (*msg).clone();
4823                                 nativeErrorAction::SendErrorMessage {
4824                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4825                                 }
4826                         },
4827                         ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
4828                                 let mut msg_nonref = (*msg).clone();
4829                                 let mut log_level_nonref = (*log_level).clone();
4830                                 nativeErrorAction::SendWarningMessage {
4831                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4832                                         log_level: log_level_nonref.into_native(),
4833                                 }
4834                         },
4835                 }
4836         }
4837         #[allow(unused)]
4838         pub(crate) fn into_native(self) -> nativeErrorAction {
4839                 match self {
4840                         ErrorAction::DisconnectPeer {mut msg, } => {
4841                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4842                                 nativeErrorAction::DisconnectPeer {
4843                                         msg: local_msg,
4844                                 }
4845                         },
4846                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4847                         ErrorAction::IgnoreAndLog (mut a, ) => {
4848                                 nativeErrorAction::IgnoreAndLog (
4849                                         a.into_native(),
4850                                 )
4851                         },
4852                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
4853                         ErrorAction::SendErrorMessage {mut msg, } => {
4854                                 nativeErrorAction::SendErrorMessage {
4855                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
4856                                 }
4857                         },
4858                         ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
4859                                 nativeErrorAction::SendWarningMessage {
4860                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
4861                                         log_level: log_level.into_native(),
4862                                 }
4863                         },
4864                 }
4865         }
4866         #[allow(unused)]
4867         pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4868                 match native {
4869                         nativeErrorAction::DisconnectPeer {ref msg, } => {
4870                                 let mut msg_nonref = (*msg).clone();
4871                                 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 };
4872                                 ErrorAction::DisconnectPeer {
4873                                         msg: local_msg_nonref,
4874                                 }
4875                         },
4876                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4877                         nativeErrorAction::IgnoreAndLog (ref a, ) => {
4878                                 let mut a_nonref = (*a).clone();
4879                                 ErrorAction::IgnoreAndLog (
4880                                         crate::lightning::util::logger::Level::native_into(a_nonref),
4881                                 )
4882                         },
4883                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
4884                         nativeErrorAction::SendErrorMessage {ref msg, } => {
4885                                 let mut msg_nonref = (*msg).clone();
4886                                 ErrorAction::SendErrorMessage {
4887                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4888                                 }
4889                         },
4890                         nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
4891                                 let mut msg_nonref = (*msg).clone();
4892                                 let mut log_level_nonref = (*log_level).clone();
4893                                 ErrorAction::SendWarningMessage {
4894                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4895                                         log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
4896                                 }
4897                         },
4898                 }
4899         }
4900         #[allow(unused)]
4901         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4902                 match native {
4903                         nativeErrorAction::DisconnectPeer {mut msg, } => {
4904                                 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 };
4905                                 ErrorAction::DisconnectPeer {
4906                                         msg: local_msg,
4907                                 }
4908                         },
4909                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4910                         nativeErrorAction::IgnoreAndLog (mut a, ) => {
4911                                 ErrorAction::IgnoreAndLog (
4912                                         crate::lightning::util::logger::Level::native_into(a),
4913                                 )
4914                         },
4915                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
4916                         nativeErrorAction::SendErrorMessage {mut msg, } => {
4917                                 ErrorAction::SendErrorMessage {
4918                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4919                                 }
4920                         },
4921                         nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
4922                                 ErrorAction::SendWarningMessage {
4923                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4924                                         log_level: crate::lightning::util::logger::Level::native_into(log_level),
4925                                 }
4926                         },
4927                 }
4928         }
4929 }
4930 /// Frees any resources used by the ErrorAction
4931 #[no_mangle]
4932 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4933 /// Creates a copy of the ErrorAction
4934 #[no_mangle]
4935 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4936         orig.clone()
4937 }
4938 #[no_mangle]
4939 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
4940 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4941         ErrorAction::DisconnectPeer {
4942                 msg,
4943         }
4944 }
4945 #[no_mangle]
4946 /// Utility method to constructs a new IgnoreError-variant ErrorAction
4947 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
4948         ErrorAction::IgnoreError}
4949 #[no_mangle]
4950 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
4951 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
4952         ErrorAction::IgnoreAndLog(a, )
4953 }
4954 #[no_mangle]
4955 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
4956 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
4957         ErrorAction::IgnoreDuplicateGossip}
4958 #[no_mangle]
4959 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
4960 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4961         ErrorAction::SendErrorMessage {
4962                 msg,
4963         }
4964 }
4965 #[no_mangle]
4966 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
4967 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
4968         ErrorAction::SendWarningMessage {
4969                 msg,
4970                 log_level,
4971         }
4972 }
4973
4974 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4975 pub(crate) type nativeLightningError = nativeLightningErrorImport;
4976
4977 /// An Err type for failure to process messages.
4978 #[must_use]
4979 #[repr(C)]
4980 pub struct LightningError {
4981         /// A pointer to the opaque Rust object.
4982
4983         /// Nearly everywhere, inner must be non-null, however in places where
4984         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4985         pub inner: *mut nativeLightningError,
4986         /// Indicates that this is the only struct which contains the same pointer.
4987
4988         /// Rust functions which take ownership of an object provided via an argument require
4989         /// this to be true and invalidate the object pointed to by inner.
4990         pub is_owned: bool,
4991 }
4992
4993 impl Drop for LightningError {
4994         fn drop(&mut self) {
4995                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4996                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4997                 }
4998         }
4999 }
5000 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
5001 #[no_mangle]
5002 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
5003 #[allow(unused)]
5004 /// Used only if an object of this type is returned as a trait impl by a method
5005 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
5006         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
5007 }
5008 #[allow(unused)]
5009 impl LightningError {
5010         pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
5011                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5012         }
5013         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
5014                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5015         }
5016         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5017         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
5018                 assert!(self.is_owned);
5019                 let ret = ObjOps::untweak_ptr(self.inner);
5020                 self.inner = core::ptr::null_mut();
5021                 ret
5022         }
5023 }
5024 /// A human-readable message describing the error
5025 #[no_mangle]
5026 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
5027         let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
5028         inner_val.as_str().into()
5029 }
5030 /// A human-readable message describing the error
5031 #[no_mangle]
5032 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
5033         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
5034 }
5035 /// The action which should be taken against the offending peer.
5036 #[no_mangle]
5037 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
5038         let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
5039         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
5040 }
5041 /// The action which should be taken against the offending peer.
5042 #[no_mangle]
5043 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
5044         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
5045 }
5046 /// Constructs a new LightningError given each field
5047 #[must_use]
5048 #[no_mangle]
5049 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
5050         LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
5051                 err: err_arg.into_string(),
5052                 action: action_arg.into_native(),
5053         }), is_owned: true }
5054 }
5055 impl Clone for LightningError {
5056         fn clone(&self) -> Self {
5057                 Self {
5058                         inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
5059                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5060                         is_owned: true,
5061                 }
5062         }
5063 }
5064 #[allow(unused)]
5065 /// Used only if an object of this type is returned as a trait impl by a method
5066 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
5067         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
5068 }
5069 #[no_mangle]
5070 /// Creates a copy of the LightningError
5071 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
5072         orig.clone()
5073 }
5074
5075 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
5076 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
5077
5078 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
5079 /// transaction updates if they were pending.
5080 #[must_use]
5081 #[repr(C)]
5082 pub struct CommitmentUpdate {
5083         /// A pointer to the opaque Rust object.
5084
5085         /// Nearly everywhere, inner must be non-null, however in places where
5086         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5087         pub inner: *mut nativeCommitmentUpdate,
5088         /// Indicates that this is the only struct which contains the same pointer.
5089
5090         /// Rust functions which take ownership of an object provided via an argument require
5091         /// this to be true and invalidate the object pointed to by inner.
5092         pub is_owned: bool,
5093 }
5094
5095 impl Drop for CommitmentUpdate {
5096         fn drop(&mut self) {
5097                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
5098                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5099                 }
5100         }
5101 }
5102 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
5103 #[no_mangle]
5104 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
5105 #[allow(unused)]
5106 /// Used only if an object of this type is returned as a trait impl by a method
5107 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
5108         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
5109 }
5110 #[allow(unused)]
5111 impl CommitmentUpdate {
5112         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
5113                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5114         }
5115         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
5116                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5117         }
5118         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5119         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
5120                 assert!(self.is_owned);
5121                 let ret = ObjOps::untweak_ptr(self.inner);
5122                 self.inner = core::ptr::null_mut();
5123                 ret
5124         }
5125 }
5126 /// update_add_htlc messages which should be sent
5127 #[no_mangle]
5128 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
5129         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
5130         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 } }); };
5131         local_inner_val.into()
5132 }
5133 /// update_add_htlc messages which should be sent
5134 #[no_mangle]
5135 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
5136         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5137         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
5138 }
5139 /// update_fulfill_htlc messages which should be sent
5140 #[no_mangle]
5141 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
5142         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
5143         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 } }); };
5144         local_inner_val.into()
5145 }
5146 /// update_fulfill_htlc messages which should be sent
5147 #[no_mangle]
5148 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
5149         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5150         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
5151 }
5152 /// update_fail_htlc messages which should be sent
5153 #[no_mangle]
5154 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
5155         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
5156         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 } }); };
5157         local_inner_val.into()
5158 }
5159 /// update_fail_htlc messages which should be sent
5160 #[no_mangle]
5161 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
5162         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5163         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
5164 }
5165 /// update_fail_malformed_htlc messages which should be sent
5166 #[no_mangle]
5167 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
5168         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
5169         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 } }); };
5170         local_inner_val.into()
5171 }
5172 /// update_fail_malformed_htlc messages which should be sent
5173 #[no_mangle]
5174 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
5175         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5176         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
5177 }
5178 /// An update_fee message which should be sent
5179 ///
5180 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
5181 #[no_mangle]
5182 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
5183         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
5184         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 };
5185         local_inner_val
5186 }
5187 /// An update_fee message which should be sent
5188 ///
5189 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
5190 #[no_mangle]
5191 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
5192         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
5193         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
5194 }
5195 /// Finally, the commitment_signed message which should be sent
5196 #[no_mangle]
5197 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
5198         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
5199         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 }
5200 }
5201 /// Finally, the commitment_signed message which should be sent
5202 #[no_mangle]
5203 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
5204         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
5205 }
5206 /// Constructs a new CommitmentUpdate given each field
5207 #[must_use]
5208 #[no_mangle]
5209 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 {
5210         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()) } }); };
5211         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()) } }); };
5212         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()) } }); };
5213         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()) } }); };
5214         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()) } }) };
5215         CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
5216                 update_add_htlcs: local_update_add_htlcs_arg,
5217                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
5218                 update_fail_htlcs: local_update_fail_htlcs_arg,
5219                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
5220                 update_fee: local_update_fee_arg,
5221                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
5222         }), is_owned: true }
5223 }
5224 impl Clone for CommitmentUpdate {
5225         fn clone(&self) -> Self {
5226                 Self {
5227                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
5228                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5229                         is_owned: true,
5230                 }
5231         }
5232 }
5233 #[allow(unused)]
5234 /// Used only if an object of this type is returned as a trait impl by a method
5235 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
5236         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
5237 }
5238 #[no_mangle]
5239 /// Creates a copy of the CommitmentUpdate
5240 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
5241         orig.clone()
5242 }
5243 /// A trait to describe an object which can receive channel messages.
5244 ///
5245 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
5246 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
5247 #[repr(C)]
5248 pub struct ChannelMessageHandler {
5249         /// An opaque pointer which is passed to your function implementations as an argument.
5250         /// This has no meaning in the LDK, and can be NULL or any other value.
5251         pub this_arg: *mut c_void,
5252         /// Handle an incoming open_channel message from the given peer.
5253         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),
5254         /// Handle an incoming accept_channel message from the given peer.
5255         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),
5256         /// Handle an incoming funding_created message from the given peer.
5257         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),
5258         /// Handle an incoming funding_signed message from the given peer.
5259         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),
5260         /// Handle an incoming channel_ready message from the given peer.
5261         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),
5262         /// Handle an incoming shutdown message from the given peer.
5263         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),
5264         /// Handle an incoming closing_signed message from the given peer.
5265         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),
5266         /// Handle an incoming update_add_htlc message from the given peer.
5267         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),
5268         /// Handle an incoming update_fulfill_htlc message from the given peer.
5269         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),
5270         /// Handle an incoming update_fail_htlc message from the given peer.
5271         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),
5272         /// Handle an incoming update_fail_malformed_htlc message from the given peer.
5273         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),
5274         /// Handle an incoming commitment_signed message from the given peer.
5275         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),
5276         /// Handle an incoming revoke_and_ack message from the given peer.
5277         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),
5278         /// Handle an incoming update_fee message from the given peer.
5279         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),
5280         /// Handle an incoming announcement_signatures message from the given peer.
5281         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),
5282         /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
5283         /// is believed to be possible in the future (eg they're sending us messages we don't
5284         /// understand or indicate they require unknown feature bits), no_connection_possible is set
5285         /// and any outstanding channels should be failed.
5286         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
5287         /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
5288         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
5289         /// Handle an incoming channel_reestablish message from the given peer.
5290         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),
5291         /// Handle an incoming channel update from the given peer.
5292         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),
5293         /// Handle an incoming error message from the given peer.
5294         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
5295         /// Gets the node feature flags which this handler itself supports. All available handlers are
5296         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
5297         /// which are broadcasted in our [`NodeAnnouncement`] message.
5298         #[must_use]
5299         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
5300         /// Gets the init feature flags which should be sent to the given peer. All available handlers
5301         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
5302         /// which are sent in our [`Init`] message.
5303         ///
5304         /// Note that this method is called before [`Self::peer_connected`].
5305         #[must_use]
5306         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
5307         /// Implementation of MessageSendEventsProvider for this object.
5308         pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5309         /// Frees any resources associated with this object given its this_arg pointer.
5310         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5311         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5312 }
5313 unsafe impl Send for ChannelMessageHandler {}
5314 unsafe impl Sync for ChannelMessageHandler {}
5315 #[no_mangle]
5316 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
5317         ChannelMessageHandler {
5318                 this_arg: orig.this_arg,
5319                 handle_open_channel: Clone::clone(&orig.handle_open_channel),
5320                 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
5321                 handle_funding_created: Clone::clone(&orig.handle_funding_created),
5322                 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
5323                 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
5324                 handle_shutdown: Clone::clone(&orig.handle_shutdown),
5325                 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
5326                 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
5327                 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
5328                 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
5329                 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
5330                 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
5331                 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
5332                 handle_update_fee: Clone::clone(&orig.handle_update_fee),
5333                 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
5334                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
5335                 peer_connected: Clone::clone(&orig.peer_connected),
5336                 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
5337                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5338                 handle_error: Clone::clone(&orig.handle_error),
5339                 provided_node_features: Clone::clone(&orig.provided_node_features),
5340                 provided_init_features: Clone::clone(&orig.provided_init_features),
5341                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5342                 free: Clone::clone(&orig.free),
5343         }
5344 }
5345 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
5346         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5347                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5348                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5349                 local_ret
5350         }
5351 }
5352
5353 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
5354 impl rustChannelMessageHandler for ChannelMessageHandler {
5355         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) {
5356                 (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 })
5357         }
5358         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) {
5359                 (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 })
5360         }
5361         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
5362                 (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 })
5363         }
5364         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
5365                 (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 })
5366         }
5367         fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
5368                 (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 })
5369         }
5370         fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut their_features: &lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::Shutdown) {
5371                 (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 })
5372         }
5373         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
5374                 (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 })
5375         }
5376         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
5377                 (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 })
5378         }
5379         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
5380                 (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 })
5381         }
5382         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
5383                 (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 })
5384         }
5385         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
5386                 (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 })
5387         }
5388         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
5389                 (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 })
5390         }
5391         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
5392                 (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 })
5393         }
5394         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
5395                 (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 })
5396         }
5397         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
5398                 (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 })
5399         }
5400         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut no_connection_possible: bool) {
5401                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
5402         }
5403         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init) {
5404                 (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 })
5405         }
5406         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
5407                 (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 })
5408         }
5409         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
5410                 (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 })
5411         }
5412         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
5413                 (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 })
5414         }
5415         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
5416                 let mut ret = (self.provided_node_features)(self.this_arg);
5417                 *unsafe { Box::from_raw(ret.take_inner()) }
5418         }
5419         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
5420                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
5421                 *unsafe { Box::from_raw(ret.take_inner()) }
5422         }
5423 }
5424
5425 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5426 // directly as a Deref trait in higher-level structs:
5427 impl core::ops::Deref for ChannelMessageHandler {
5428         type Target = Self;
5429         fn deref(&self) -> &Self {
5430                 self
5431         }
5432 }
5433 /// Calls the free function if one is set
5434 #[no_mangle]
5435 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
5436 impl Drop for ChannelMessageHandler {
5437         fn drop(&mut self) {
5438                 if let Some(f) = self.free {
5439                         f(self.this_arg);
5440                 }
5441         }
5442 }
5443 /// A trait to describe an object which can receive routing messages.
5444 ///
5445 /// # Implementor DoS Warnings
5446 ///
5447 /// For `gossip_queries` messages there are potential DoS vectors when handling
5448 /// inbound queries. Implementors using an on-disk network graph should be aware of
5449 /// repeated disk I/O for queries accessing different parts of the network graph.
5450 #[repr(C)]
5451 pub struct RoutingMessageHandler {
5452         /// An opaque pointer which is passed to your function implementations as an argument.
5453         /// This has no meaning in the LDK, and can be NULL or any other value.
5454         pub this_arg: *mut c_void,
5455         /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
5456         /// false or returning an Err otherwise.
5457         #[must_use]
5458         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5459         /// Handle a channel_announcement message, returning true if it should be forwarded on, false
5460         /// or returning an Err otherwise.
5461         #[must_use]
5462         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5463         /// Handle an incoming channel_update message, returning true if it should be forwarded on,
5464         /// false or returning an Err otherwise.
5465         #[must_use]
5466         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5467         /// Gets channel announcements and updates required to dump our routing table to a remote node,
5468         /// starting at the short_channel_id indicated by starting_point and including announcements
5469         /// for a single channel.
5470         #[must_use]
5471         pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
5472         /// Gets a node announcement required to dump our routing table to a remote node, starting at
5473         /// the node *after* the provided pubkey and including up to one announcement immediately
5474         /// higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
5475         /// If None is provided for starting_point, we start at the first node.
5476         ///
5477         /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
5478         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
5479         #[must_use]
5480         pub get_next_node_announcement: extern "C" fn (this_arg: *const c_void, starting_point: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::NodeAnnouncement,
5481         /// Called when a connection is established with a peer. This can be used to
5482         /// perform routing table synchronization using a strategy defined by the
5483         /// implementor.
5484         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init),
5485         /// Handles the reply of a query we initiated to learn about channels
5486         /// for a given range of blocks. We can expect to receive one or more
5487         /// replies to a single query.
5488         #[must_use]
5489         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,
5490         /// Handles the reply of a query we initiated asking for routing gossip
5491         /// messages for a list of channels. We should receive this message when
5492         /// a node has completed its best effort to send us the pertaining routing
5493         /// gossip messages.
5494         #[must_use]
5495         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,
5496         /// Handles when a peer asks us to send a list of short_channel_ids
5497         /// for the requested range of blocks.
5498         #[must_use]
5499         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,
5500         /// Handles when a peer asks us to send routing gossip messages for a
5501         /// list of short_channel_ids.
5502         #[must_use]
5503         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,
5504         /// Gets the node feature flags which this handler itself supports. All available handlers are
5505         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
5506         /// which are broadcasted in our [`NodeAnnouncement`] message.
5507         #[must_use]
5508         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
5509         /// Gets the init feature flags which should be sent to the given peer. All available handlers
5510         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
5511         /// which are sent in our [`Init`] message.
5512         ///
5513         /// Note that this method is called before [`Self::peer_connected`].
5514         #[must_use]
5515         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
5516         /// Implementation of MessageSendEventsProvider for this object.
5517         pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5518         /// Frees any resources associated with this object given its this_arg pointer.
5519         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5520         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5521 }
5522 unsafe impl Send for RoutingMessageHandler {}
5523 unsafe impl Sync for RoutingMessageHandler {}
5524 #[no_mangle]
5525 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
5526         RoutingMessageHandler {
5527                 this_arg: orig.this_arg,
5528                 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
5529                 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
5530                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5531                 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
5532                 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
5533                 peer_connected: Clone::clone(&orig.peer_connected),
5534                 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
5535                 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
5536                 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
5537                 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
5538                 provided_node_features: Clone::clone(&orig.provided_node_features),
5539                 provided_init_features: Clone::clone(&orig.provided_init_features),
5540                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5541                 free: Clone::clone(&orig.free),
5542         }
5543 }
5544 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
5545         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5546                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5547                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5548                 local_ret
5549         }
5550 }
5551
5552 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
5553 impl rustRoutingMessageHandler for RoutingMessageHandler {
5554         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5555                 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 });
5556                 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()) } })};
5557                 local_ret
5558         }
5559         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5560                 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 });
5561                 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()) } })};
5562                 local_ret
5563         }
5564         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
5565                 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 });
5566                 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()) } })};
5567                 local_ret
5568         }
5569         fn get_next_channel_announcement(&self, mut starting_point: u64) -> Option<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
5570                 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
5571                 let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = ret.take().to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }) } else { None };
5572                 local_ret
5573         }
5574         fn get_next_node_announcement(&self, mut starting_point: Option<&bitcoin::secp256k1::PublicKey>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
5575                 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())) } };
5576                 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
5577                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
5578                 local_ret
5579         }
5580         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init) {
5581                 (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 })
5582         }
5583         fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
5584                 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 });
5585                 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()) } })};
5586                 local_ret
5587         }
5588         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> {
5589                 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 });
5590                 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()) } })};
5591                 local_ret
5592         }
5593         fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
5594                 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 });
5595                 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()) } })};
5596                 local_ret
5597         }
5598         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> {
5599                 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 });
5600                 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()) } })};
5601                 local_ret
5602         }
5603         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
5604                 let mut ret = (self.provided_node_features)(self.this_arg);
5605                 *unsafe { Box::from_raw(ret.take_inner()) }
5606         }
5607         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
5608                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
5609                 *unsafe { Box::from_raw(ret.take_inner()) }
5610         }
5611 }
5612
5613 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5614 // directly as a Deref trait in higher-level structs:
5615 impl core::ops::Deref for RoutingMessageHandler {
5616         type Target = Self;
5617         fn deref(&self) -> &Self {
5618                 self
5619         }
5620 }
5621 /// Calls the free function if one is set
5622 #[no_mangle]
5623 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
5624 impl Drop for RoutingMessageHandler {
5625         fn drop(&mut self) {
5626                 if let Some(f) = self.free {
5627                         f(self.this_arg);
5628                 }
5629         }
5630 }
5631 /// A trait to describe an object that can receive onion messages.
5632 #[repr(C)]
5633 pub struct OnionMessageHandler {
5634         /// An opaque pointer which is passed to your function implementations as an argument.
5635         /// This has no meaning in the LDK, and can be NULL or any other value.
5636         pub this_arg: *mut c_void,
5637         /// Handle an incoming onion_message message from the given peer.
5638         pub handle_onion_message: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage),
5639         /// Called when a connection is established with a peer. Can be used to track which peers
5640         /// advertise onion message support and are online.
5641         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init),
5642         /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
5643         /// drop and refuse to forward onion messages to this peer.
5644         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
5645         /// Gets the node feature flags which this handler itself supports. All available handlers are
5646         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
5647         /// which are broadcasted in our [`NodeAnnouncement`] message.
5648         #[must_use]
5649         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
5650         /// Gets the init feature flags which should be sent to the given peer. All available handlers
5651         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
5652         /// which are sent in our [`Init`] message.
5653         ///
5654         /// Note that this method is called before [`Self::peer_connected`].
5655         #[must_use]
5656         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
5657         /// Implementation of OnionMessageProvider for this object.
5658         pub OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider,
5659         /// Frees any resources associated with this object given its this_arg pointer.
5660         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5661         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5662 }
5663 unsafe impl Send for OnionMessageHandler {}
5664 unsafe impl Sync for OnionMessageHandler {}
5665 #[no_mangle]
5666 pub(crate) extern "C" fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
5667         OnionMessageHandler {
5668                 this_arg: orig.this_arg,
5669                 handle_onion_message: Clone::clone(&orig.handle_onion_message),
5670                 peer_connected: Clone::clone(&orig.peer_connected),
5671                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
5672                 provided_node_features: Clone::clone(&orig.provided_node_features),
5673                 provided_init_features: Clone::clone(&orig.provided_init_features),
5674                 OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider),
5675                 free: Clone::clone(&orig.free),
5676         }
5677 }
5678 impl lightning::util::events::OnionMessageProvider for OnionMessageHandler {
5679         fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
5680                 let mut ret = (self.OnionMessageProvider.next_onion_message_for_peer)(self.OnionMessageProvider.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
5681                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
5682                 local_ret
5683         }
5684 }
5685
5686 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
5687 impl rustOnionMessageHandler for OnionMessageHandler {
5688         fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
5689                 (self.handle_onion_message)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id), &crate::lightning::ln::msgs::OnionMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OnionMessage<>) as *mut _) }, is_owned: false })
5690         }
5691         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init) {
5692                 (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 })
5693         }
5694         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut no_connection_possible: bool) {
5695                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
5696         }
5697         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
5698                 let mut ret = (self.provided_node_features)(self.this_arg);
5699                 *unsafe { Box::from_raw(ret.take_inner()) }
5700         }
5701         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
5702                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
5703                 *unsafe { Box::from_raw(ret.take_inner()) }
5704         }
5705 }
5706
5707 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5708 // directly as a Deref trait in higher-level structs:
5709 impl core::ops::Deref for OnionMessageHandler {
5710         type Target = Self;
5711         fn deref(&self) -> &Self {
5712                 self
5713         }
5714 }
5715 /// Calls the free function if one is set
5716 #[no_mangle]
5717 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
5718 impl Drop for OnionMessageHandler {
5719         fn drop(&mut self) {
5720                 if let Some(f) = self.free {
5721                         f(self.this_arg);
5722                 }
5723         }
5724 }
5725 mod fuzzy_internal_msgs {
5726
5727 use alloc::str::FromStr;
5728 use core::ffi::c_void;
5729 use core::convert::Infallible;
5730 use bitcoin::hashes::Hash;
5731 use crate::c_types::*;
5732 #[cfg(feature="no-std")]
5733 use alloc::{vec::Vec, boxed::Box};
5734
5735 }
5736 #[no_mangle]
5737 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
5738 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
5739         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5740 }
5741 #[no_mangle]
5742 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5743         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
5744 }
5745 #[no_mangle]
5746 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
5747 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
5748         let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5749         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() };
5750         local_res
5751 }
5752 #[no_mangle]
5753 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
5754 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
5755         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5756 }
5757 #[no_mangle]
5758 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5759         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
5760 }
5761 #[no_mangle]
5762 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
5763 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
5764         let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5765         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() };
5766         local_res
5767 }
5768 #[no_mangle]
5769 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
5770 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
5771         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5772 }
5773 #[no_mangle]
5774 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5775         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
5776 }
5777 #[no_mangle]
5778 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
5779 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
5780         let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5781         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() };
5782         local_res
5783 }
5784 #[no_mangle]
5785 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
5786 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
5787         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5788 }
5789 #[no_mangle]
5790 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5791         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
5792 }
5793 #[no_mangle]
5794 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
5795 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
5796         let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5797         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() };
5798         local_res
5799 }
5800 #[no_mangle]
5801 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
5802 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
5803         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5804 }
5805 #[no_mangle]
5806 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5807         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
5808 }
5809 #[no_mangle]
5810 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
5811 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
5812         let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5813         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() };
5814         local_res
5815 }
5816 #[no_mangle]
5817 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
5818 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
5819         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5820 }
5821 #[no_mangle]
5822 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5823         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
5824 }
5825 #[no_mangle]
5826 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
5827 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
5828         let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5829         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() };
5830         local_res
5831 }
5832 #[no_mangle]
5833 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
5834 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
5835         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5836 }
5837 #[no_mangle]
5838 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5839         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
5840 }
5841 #[no_mangle]
5842 /// Read a FundingCreated from a byte array, created by FundingCreated_write
5843 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
5844         let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5845         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() };
5846         local_res
5847 }
5848 #[no_mangle]
5849 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
5850 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
5851         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5852 }
5853 #[no_mangle]
5854 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5855         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
5856 }
5857 #[no_mangle]
5858 /// Read a FundingSigned from a byte array, created by FundingSigned_write
5859 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
5860         let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5861         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() };
5862         local_res
5863 }
5864 #[no_mangle]
5865 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
5866 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
5867         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5868 }
5869 #[no_mangle]
5870 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5871         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
5872 }
5873 #[no_mangle]
5874 /// Read a ChannelReady from a byte array, created by ChannelReady_write
5875 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
5876         let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5877         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() };
5878         local_res
5879 }
5880 #[no_mangle]
5881 /// Serialize the Init object into a byte array which can be read by Init_read
5882 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
5883         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5884 }
5885 #[no_mangle]
5886 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5887         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
5888 }
5889 #[no_mangle]
5890 /// Read a Init from a byte array, created by Init_write
5891 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
5892         let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5893         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() };
5894         local_res
5895 }
5896 #[no_mangle]
5897 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
5898 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
5899         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5900 }
5901 #[no_mangle]
5902 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5903         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
5904 }
5905 #[no_mangle]
5906 /// Read a OpenChannel from a byte array, created by OpenChannel_write
5907 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
5908         let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5909         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() };
5910         local_res
5911 }
5912 #[no_mangle]
5913 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
5914 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
5915         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5916 }
5917 #[no_mangle]
5918 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5919         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
5920 }
5921 #[no_mangle]
5922 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
5923 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
5924         let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5925         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() };
5926         local_res
5927 }
5928 #[no_mangle]
5929 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
5930 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
5931         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5932 }
5933 #[no_mangle]
5934 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5935         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
5936 }
5937 #[no_mangle]
5938 /// Read a Shutdown from a byte array, created by Shutdown_write
5939 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
5940         let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5941         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() };
5942         local_res
5943 }
5944 #[no_mangle]
5945 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
5946 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
5947         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5948 }
5949 #[no_mangle]
5950 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5951         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
5952 }
5953 #[no_mangle]
5954 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
5955 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
5956         let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5957         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() };
5958         local_res
5959 }
5960 #[no_mangle]
5961 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
5962 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
5963         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5964 }
5965 #[no_mangle]
5966 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5967         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
5968 }
5969 #[no_mangle]
5970 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
5971 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
5972         let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5973         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() };
5974         local_res
5975 }
5976 #[no_mangle]
5977 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5978 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
5979         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5980 }
5981 #[no_mangle]
5982 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5983         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5984 }
5985 #[no_mangle]
5986 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5987 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
5988         let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5989         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() };
5990         local_res
5991 }
5992 #[no_mangle]
5993 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5994 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
5995         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5996 }
5997 #[no_mangle]
5998 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5999         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
6000 }
6001 #[no_mangle]
6002 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
6003 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
6004         let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6005         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() };
6006         local_res
6007 }
6008 #[no_mangle]
6009 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
6010 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
6011         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6012 }
6013 #[no_mangle]
6014 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6015         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
6016 }
6017 #[no_mangle]
6018 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
6019 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
6020         let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6021         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() };
6022         local_res
6023 }
6024 #[no_mangle]
6025 /// Read a OnionMessage from a byte array, created by OnionMessage_write
6026 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
6027         let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6028         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
6029         local_res
6030 }
6031 #[no_mangle]
6032 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
6033 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
6034         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6035 }
6036 #[no_mangle]
6037 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6038         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
6039 }
6040 #[no_mangle]
6041 /// Serialize the Ping object into a byte array which can be read by Ping_read
6042 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
6043         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6044 }
6045 #[no_mangle]
6046 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6047         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
6048 }
6049 #[no_mangle]
6050 /// Read a Ping from a byte array, created by Ping_write
6051 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
6052         let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6053         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() };
6054         local_res
6055 }
6056 #[no_mangle]
6057 /// Serialize the Pong object into a byte array which can be read by Pong_read
6058 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
6059         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6060 }
6061 #[no_mangle]
6062 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6063         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
6064 }
6065 #[no_mangle]
6066 /// Read a Pong from a byte array, created by Pong_write
6067 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
6068         let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6069         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() };
6070         local_res
6071 }
6072 #[no_mangle]
6073 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
6074 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6075         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6076 }
6077 #[no_mangle]
6078 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6079         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
6080 }
6081 #[no_mangle]
6082 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
6083 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
6084         let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6085         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() };
6086         local_res
6087 }
6088 #[no_mangle]
6089 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
6090 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6091         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6092 }
6093 #[no_mangle]
6094 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6095         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
6096 }
6097 #[no_mangle]
6098 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
6099 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
6100         let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6101         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() };
6102         local_res
6103 }
6104 #[no_mangle]
6105 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
6106 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6107         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6108 }
6109 #[no_mangle]
6110 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6111         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
6112 }
6113 #[no_mangle]
6114 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
6115 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
6116         let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6117         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() };
6118         local_res
6119 }
6120 #[no_mangle]
6121 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
6122 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6123         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6124 }
6125 #[no_mangle]
6126 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6127         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
6128 }
6129 #[no_mangle]
6130 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
6131 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
6132         let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6133         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() };
6134         local_res
6135 }
6136 #[no_mangle]
6137 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
6138 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
6139         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6140 }
6141 #[no_mangle]
6142 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6143         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
6144 }
6145 #[no_mangle]
6146 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
6147 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
6148         let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6149         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() };
6150         local_res
6151 }
6152 #[no_mangle]
6153 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
6154 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
6155         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6156 }
6157 #[no_mangle]
6158 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6159         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
6160 }
6161 #[no_mangle]
6162 /// Read a WarningMessage from a byte array, created by WarningMessage_write
6163 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
6164         let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6165         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() };
6166         local_res
6167 }
6168 #[no_mangle]
6169 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
6170 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6171         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6172 }
6173 #[no_mangle]
6174 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6175         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
6176 }
6177 #[no_mangle]
6178 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
6179 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
6180         let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6181         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() };
6182         local_res
6183 }
6184 #[no_mangle]
6185 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
6186 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6187         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6188 }
6189 #[no_mangle]
6190 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6191         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
6192 }
6193 #[no_mangle]
6194 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
6195 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
6196         let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6197         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() };
6198         local_res
6199 }
6200 #[no_mangle]
6201 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
6202 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
6203         let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6204         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() };
6205         local_res
6206 }
6207 #[no_mangle]
6208 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
6209 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
6210         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6211 }
6212 #[no_mangle]
6213 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6214         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
6215 }
6216 #[no_mangle]
6217 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
6218 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
6219         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6220 }
6221 #[no_mangle]
6222 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6223         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
6224 }
6225 #[no_mangle]
6226 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
6227 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
6228         let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6229         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() };
6230         local_res
6231 }
6232 ///\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 
6233 #[must_use]
6234 #[no_mangle]
6235 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
6236         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
6237         ret
6238 }
6239
6240 #[no_mangle]
6241 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
6242 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
6243         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6244 }
6245 #[no_mangle]
6246 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6247         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
6248 }
6249 #[no_mangle]
6250 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
6251 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
6252         let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6253         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() };
6254         local_res
6255 }
6256 #[no_mangle]
6257 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
6258 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
6259         let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6260         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() };
6261         local_res
6262 }
6263 #[no_mangle]
6264 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
6265 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
6266         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6267 }
6268 #[no_mangle]
6269 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6270         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
6271 }
6272 #[no_mangle]
6273 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
6274 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
6275         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6276 }
6277 #[no_mangle]
6278 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6279         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
6280 }
6281 #[no_mangle]
6282 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
6283 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
6284         let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6285         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() };
6286         local_res
6287 }