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