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