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