Merge pull request #42 from TheBlueMatt/main
[ldk-c-bindings] / lightning-c-bindings / src / lightning / ln / msgs.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Wire messages, traits representing wire message handlers, and a few error types live here.
10 //!
11 //! For a normal node you probably don't need to use anything here, however, if you wish to split a
12 //! node into an internet-facing route/message socket handling daemon and a separate daemon (or
13 //! server entirely) which handles only channel-related messages you may wish to implement
14 //! ChannelMessageHandler yourself and use it to re-serialize messages and pass them across
15 //! daemons/servers.
16 //!
17 //! Note that if you go with such an architecture (instead of passing raw socket events to a
18 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
19 //! source node_id of the message, however this does allow you to significantly reduce bandwidth
20 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
21 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
22 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
23 //! raw socket events into your non-internet-facing system and then send routing events back to
24 //! track the network on the less-secure system.
25
26 use std::str::FromStr;
27 use std::ffi::c_void;
28 use core::convert::Infallible;
29 use bitcoin::hashes::Hash;
30 use crate::c_types::*;
31
32
33 use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport;
34 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 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 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 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 _) 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 _) 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 Result from a byte array, created by Result_write
2981 pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ {
2982         let res = crate::c_types::deserialize_obj(ser);
2983         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = match o { 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( { e }).into() }; local_res_0 }).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 #[no_mangle]
2987 /// Read a NetAddress from a byte array, created by NetAddress_write
2988 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
2989         let res = crate::c_types::deserialize_obj(ser);
2990         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() };
2991         local_res
2992 }
2993
2994 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2995 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2996
2997 /// The unsigned part of a node_announcement
2998 #[must_use]
2999 #[repr(C)]
3000 pub struct UnsignedNodeAnnouncement {
3001         /// A pointer to the opaque Rust object.
3002
3003         /// Nearly everywhere, inner must be non-null, however in places where
3004         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3005         pub inner: *mut nativeUnsignedNodeAnnouncement,
3006         /// Indicates that this is the only struct which contains the same pointer.
3007
3008         /// Rust functions which take ownership of an object provided via an argument require
3009         /// this to be true and invalidate the object pointed to by inner.
3010         pub is_owned: bool,
3011 }
3012
3013 impl Drop for UnsignedNodeAnnouncement {
3014         fn drop(&mut self) {
3015                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3016                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3017                 }
3018         }
3019 }
3020 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3021 #[no_mangle]
3022 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3023 #[allow(unused)]
3024 /// Used only if an object of this type is returned as a trait impl by a method
3025 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3026         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
3027 }
3028 #[allow(unused)]
3029 impl UnsignedNodeAnnouncement {
3030         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3031                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3032         }
3033         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3034                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3035         }
3036         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3037         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3038                 assert!(self.is_owned);
3039                 let ret = ObjOps::untweak_ptr(self.inner);
3040                 self.inner = std::ptr::null_mut();
3041                 ret
3042         }
3043 }
3044 /// The advertised features
3045 #[no_mangle]
3046 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3047         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3048         crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3049 }
3050 /// The advertised features
3051 #[no_mangle]
3052 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3053         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3054 }
3055 /// A strictly monotonic announcement counter, with gaps allowed
3056 #[no_mangle]
3057 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3058         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3059         *inner_val
3060 }
3061 /// A strictly monotonic announcement counter, with gaps allowed
3062 #[no_mangle]
3063 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3064         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = 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_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
3070         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3071         crate::c_types::PublicKey::from_rust(&inner_val)
3072 }
3073 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3074 /// to this node).
3075 #[no_mangle]
3076 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
3077         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
3078 }
3079 /// An RGB color for UI purposes
3080 #[no_mangle]
3081 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3082         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3083         inner_val
3084 }
3085 /// An RGB color for UI purposes
3086 #[no_mangle]
3087 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3088         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
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_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3094         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3095         inner_val
3096 }
3097 /// An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
3098 /// of uniqueness.
3099 #[no_mangle]
3100 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3101         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3102 }
3103 /// List of addresses on which this node is reachable
3104 #[no_mangle]
3105 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3106         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3107         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3108 }
3109 impl Clone for UnsignedNodeAnnouncement {
3110         fn clone(&self) -> Self {
3111                 Self {
3112                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3113                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3114                         is_owned: true,
3115                 }
3116         }
3117 }
3118 #[allow(unused)]
3119 /// Used only if an object of this type is returned as a trait impl by a method
3120 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3121         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3122 }
3123 #[no_mangle]
3124 /// Creates a copy of the UnsignedNodeAnnouncement
3125 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3126         orig.clone()
3127 }
3128
3129 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3130 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3131
3132 /// A node_announcement message to be sent or received from a peer
3133 #[must_use]
3134 #[repr(C)]
3135 pub struct NodeAnnouncement {
3136         /// A pointer to the opaque Rust object.
3137
3138         /// Nearly everywhere, inner must be non-null, however in places where
3139         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3140         pub inner: *mut nativeNodeAnnouncement,
3141         /// Indicates that this is the only struct which contains the same pointer.
3142
3143         /// Rust functions which take ownership of an object provided via an argument require
3144         /// this to be true and invalidate the object pointed to by inner.
3145         pub is_owned: bool,
3146 }
3147
3148 impl Drop for NodeAnnouncement {
3149         fn drop(&mut self) {
3150                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3151                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3152                 }
3153         }
3154 }
3155 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3156 #[no_mangle]
3157 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3158 #[allow(unused)]
3159 /// Used only if an object of this type is returned as a trait impl by a method
3160 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3161         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3162 }
3163 #[allow(unused)]
3164 impl NodeAnnouncement {
3165         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
3166                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3167         }
3168         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
3169                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3170         }
3171         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3172         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3173                 assert!(self.is_owned);
3174                 let ret = ObjOps::untweak_ptr(self.inner);
3175                 self.inner = std::ptr::null_mut();
3176                 ret
3177         }
3178 }
3179 /// The signature by the node key
3180 #[no_mangle]
3181 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3182         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3183         crate::c_types::Signature::from_rust(&inner_val)
3184 }
3185 /// The signature by the node key
3186 #[no_mangle]
3187 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3188         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3189 }
3190 /// The actual content of the announcement
3191 #[no_mangle]
3192 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3193         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3194         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3195 }
3196 /// The actual content of the announcement
3197 #[no_mangle]
3198 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3199         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3200 }
3201 /// Constructs a new NodeAnnouncement given each field
3202 #[must_use]
3203 #[no_mangle]
3204 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3205         NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
3206                 signature: signature_arg.into_rust(),
3207                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3208         }), is_owned: true }
3209 }
3210 impl Clone for NodeAnnouncement {
3211         fn clone(&self) -> Self {
3212                 Self {
3213                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3214                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3215                         is_owned: true,
3216                 }
3217         }
3218 }
3219 #[allow(unused)]
3220 /// Used only if an object of this type is returned as a trait impl by a method
3221 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3222         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3223 }
3224 #[no_mangle]
3225 /// Creates a copy of the NodeAnnouncement
3226 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3227         orig.clone()
3228 }
3229
3230 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3231 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3232
3233 /// The unsigned part of a channel_announcement
3234 #[must_use]
3235 #[repr(C)]
3236 pub struct UnsignedChannelAnnouncement {
3237         /// A pointer to the opaque Rust object.
3238
3239         /// Nearly everywhere, inner must be non-null, however in places where
3240         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3241         pub inner: *mut nativeUnsignedChannelAnnouncement,
3242         /// Indicates that this is the only struct which contains the same pointer.
3243
3244         /// Rust functions which take ownership of an object provided via an argument require
3245         /// this to be true and invalidate the object pointed to by inner.
3246         pub is_owned: bool,
3247 }
3248
3249 impl Drop for UnsignedChannelAnnouncement {
3250         fn drop(&mut self) {
3251                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3252                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3253                 }
3254         }
3255 }
3256 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3257 #[no_mangle]
3258 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3259 #[allow(unused)]
3260 /// Used only if an object of this type is returned as a trait impl by a method
3261 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3262         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3263 }
3264 #[allow(unused)]
3265 impl UnsignedChannelAnnouncement {
3266         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
3267                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3268         }
3269         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
3270                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3271         }
3272         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3273         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3274                 assert!(self.is_owned);
3275                 let ret = ObjOps::untweak_ptr(self.inner);
3276                 self.inner = std::ptr::null_mut();
3277                 ret
3278         }
3279 }
3280 /// The advertised channel features
3281 #[no_mangle]
3282 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3283         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3284         crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3285 }
3286 /// The advertised channel features
3287 #[no_mangle]
3288 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3289         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3290 }
3291 /// The genesis hash of the blockchain where the channel is to be opened
3292 #[no_mangle]
3293 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3294         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3295         inner_val.as_inner()
3296 }
3297 /// The genesis hash of the blockchain where the channel is to be opened
3298 #[no_mangle]
3299 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3300         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3301 }
3302 /// The short channel ID
3303 #[no_mangle]
3304 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3305         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3306         *inner_val
3307 }
3308 /// The short channel ID
3309 #[no_mangle]
3310 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3311         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3312 }
3313 /// One of the two node_ids which are endpoints of this channel
3314 #[no_mangle]
3315 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3316         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
3317         crate::c_types::PublicKey::from_rust(&inner_val)
3318 }
3319 /// One of the two node_ids which are endpoints of this channel
3320 #[no_mangle]
3321 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3322         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = val.into_rust();
3323 }
3324 /// The other of the two node_ids which are endpoints of this channel
3325 #[no_mangle]
3326 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3327         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
3328         crate::c_types::PublicKey::from_rust(&inner_val)
3329 }
3330 /// The other of the two node_ids which are endpoints of this channel
3331 #[no_mangle]
3332 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3333         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = val.into_rust();
3334 }
3335 /// The funding key for the first node
3336 #[no_mangle]
3337 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3338         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
3339         crate::c_types::PublicKey::from_rust(&inner_val)
3340 }
3341 /// The funding key for the first node
3342 #[no_mangle]
3343 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3344         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = val.into_rust();
3345 }
3346 /// The funding key for the second node
3347 #[no_mangle]
3348 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3349         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
3350         crate::c_types::PublicKey::from_rust(&inner_val)
3351 }
3352 /// The funding key for the second node
3353 #[no_mangle]
3354 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3355         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = val.into_rust();
3356 }
3357 impl Clone for UnsignedChannelAnnouncement {
3358         fn clone(&self) -> Self {
3359                 Self {
3360                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3361                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3362                         is_owned: true,
3363                 }
3364         }
3365 }
3366 #[allow(unused)]
3367 /// Used only if an object of this type is returned as a trait impl by a method
3368 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3369         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3370 }
3371 #[no_mangle]
3372 /// Creates a copy of the UnsignedChannelAnnouncement
3373 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3374         orig.clone()
3375 }
3376
3377 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3378 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3379
3380 /// A channel_announcement message to be sent or received from a peer
3381 #[must_use]
3382 #[repr(C)]
3383 pub struct ChannelAnnouncement {
3384         /// A pointer to the opaque Rust object.
3385
3386         /// Nearly everywhere, inner must be non-null, however in places where
3387         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3388         pub inner: *mut nativeChannelAnnouncement,
3389         /// Indicates that this is the only struct which contains the same pointer.
3390
3391         /// Rust functions which take ownership of an object provided via an argument require
3392         /// this to be true and invalidate the object pointed to by inner.
3393         pub is_owned: bool,
3394 }
3395
3396 impl Drop for ChannelAnnouncement {
3397         fn drop(&mut self) {
3398                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3399                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3400                 }
3401         }
3402 }
3403 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3404 #[no_mangle]
3405 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3406 #[allow(unused)]
3407 /// Used only if an object of this type is returned as a trait impl by a method
3408 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3409         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3410 }
3411 #[allow(unused)]
3412 impl ChannelAnnouncement {
3413         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
3414                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3415         }
3416         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
3417                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3418         }
3419         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3420         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3421                 assert!(self.is_owned);
3422                 let ret = ObjOps::untweak_ptr(self.inner);
3423                 self.inner = std::ptr::null_mut();
3424                 ret
3425         }
3426 }
3427 /// Authentication of the announcement by the first public node
3428 #[no_mangle]
3429 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3430         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
3431         crate::c_types::Signature::from_rust(&inner_val)
3432 }
3433 /// Authentication of the announcement by the first public node
3434 #[no_mangle]
3435 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3436         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
3437 }
3438 /// Authentication of the announcement by the second public node
3439 #[no_mangle]
3440 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3441         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
3442         crate::c_types::Signature::from_rust(&inner_val)
3443 }
3444 /// Authentication of the announcement by the second public node
3445 #[no_mangle]
3446 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3447         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
3448 }
3449 /// Proof of funding UTXO ownership by the first public node
3450 #[no_mangle]
3451 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3452         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
3453         crate::c_types::Signature::from_rust(&inner_val)
3454 }
3455 /// Proof of funding UTXO ownership by the first public node
3456 #[no_mangle]
3457 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3458         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
3459 }
3460 /// Proof of funding UTXO ownership by the second public node
3461 #[no_mangle]
3462 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3463         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
3464         crate::c_types::Signature::from_rust(&inner_val)
3465 }
3466 /// Proof of funding UTXO ownership by the second public node
3467 #[no_mangle]
3468 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3469         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
3470 }
3471 /// The actual announcement
3472 #[no_mangle]
3473 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3474         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3475         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3476 }
3477 /// The actual announcement
3478 #[no_mangle]
3479 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3480         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3481 }
3482 /// Constructs a new ChannelAnnouncement given each field
3483 #[must_use]
3484 #[no_mangle]
3485 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 {
3486         ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
3487                 node_signature_1: node_signature_1_arg.into_rust(),
3488                 node_signature_2: node_signature_2_arg.into_rust(),
3489                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3490                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3491                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3492         }), is_owned: true }
3493 }
3494 impl Clone for ChannelAnnouncement {
3495         fn clone(&self) -> Self {
3496                 Self {
3497                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3498                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3499                         is_owned: true,
3500                 }
3501         }
3502 }
3503 #[allow(unused)]
3504 /// Used only if an object of this type is returned as a trait impl by a method
3505 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3506         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3507 }
3508 #[no_mangle]
3509 /// Creates a copy of the ChannelAnnouncement
3510 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3511         orig.clone()
3512 }
3513
3514 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3515 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3516
3517 /// The unsigned part of a channel_update
3518 #[must_use]
3519 #[repr(C)]
3520 pub struct UnsignedChannelUpdate {
3521         /// A pointer to the opaque Rust object.
3522
3523         /// Nearly everywhere, inner must be non-null, however in places where
3524         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3525         pub inner: *mut nativeUnsignedChannelUpdate,
3526         /// Indicates that this is the only struct which contains the same pointer.
3527
3528         /// Rust functions which take ownership of an object provided via an argument require
3529         /// this to be true and invalidate the object pointed to by inner.
3530         pub is_owned: bool,
3531 }
3532
3533 impl Drop for UnsignedChannelUpdate {
3534         fn drop(&mut self) {
3535                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3536                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3537                 }
3538         }
3539 }
3540 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3541 #[no_mangle]
3542 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3543 #[allow(unused)]
3544 /// Used only if an object of this type is returned as a trait impl by a method
3545 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3546         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3547 }
3548 #[allow(unused)]
3549 impl UnsignedChannelUpdate {
3550         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
3551                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3552         }
3553         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
3554                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3555         }
3556         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3557         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3558                 assert!(self.is_owned);
3559                 let ret = ObjOps::untweak_ptr(self.inner);
3560                 self.inner = std::ptr::null_mut();
3561                 ret
3562         }
3563 }
3564 /// The genesis hash of the blockchain where the channel is to be opened
3565 #[no_mangle]
3566 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3567         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3568         inner_val.as_inner()
3569 }
3570 /// The genesis hash of the blockchain where the channel is to be opened
3571 #[no_mangle]
3572 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3573         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3574 }
3575 /// The short channel ID
3576 #[no_mangle]
3577 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3578         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3579         *inner_val
3580 }
3581 /// The short channel ID
3582 #[no_mangle]
3583 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3584         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3585 }
3586 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3587 #[no_mangle]
3588 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3589         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3590         *inner_val
3591 }
3592 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3593 #[no_mangle]
3594 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3595         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3596 }
3597 /// Channel flags
3598 #[no_mangle]
3599 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3600         let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
3601         *inner_val
3602 }
3603 /// Channel flags
3604 #[no_mangle]
3605 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3606         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
3607 }
3608 /// The number of blocks such that if:
3609 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3610 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3611 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3612 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3613 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3614 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3615 /// constructing the route.
3616 #[no_mangle]
3617 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3618         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
3619         *inner_val
3620 }
3621 /// The number of blocks such that if:
3622 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3623 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3624 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3625 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3626 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3627 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3628 /// constructing the route.
3629 #[no_mangle]
3630 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3631         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
3632 }
3633 /// The minimum HTLC size incoming to sender, in milli-satoshi
3634 #[no_mangle]
3635 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3636         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
3637         *inner_val
3638 }
3639 /// The minimum HTLC size incoming to sender, in milli-satoshi
3640 #[no_mangle]
3641 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3642         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
3643 }
3644 /// The base HTLC fee charged by sender, in milli-satoshi
3645 #[no_mangle]
3646 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3647         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
3648         *inner_val
3649 }
3650 /// The base HTLC fee charged by sender, in milli-satoshi
3651 #[no_mangle]
3652 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3653         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
3654 }
3655 /// The amount to fee multiplier, in micro-satoshi
3656 #[no_mangle]
3657 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3658         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
3659         *inner_val
3660 }
3661 /// The amount to fee multiplier, in micro-satoshi
3662 #[no_mangle]
3663 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3664         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
3665 }
3666 impl Clone for UnsignedChannelUpdate {
3667         fn clone(&self) -> Self {
3668                 Self {
3669                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3670                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3671                         is_owned: true,
3672                 }
3673         }
3674 }
3675 #[allow(unused)]
3676 /// Used only if an object of this type is returned as a trait impl by a method
3677 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3678         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3679 }
3680 #[no_mangle]
3681 /// Creates a copy of the UnsignedChannelUpdate
3682 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3683         orig.clone()
3684 }
3685
3686 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3687 type nativeChannelUpdate = nativeChannelUpdateImport;
3688
3689 /// A channel_update message to be sent or received from a peer
3690 #[must_use]
3691 #[repr(C)]
3692 pub struct ChannelUpdate {
3693         /// A pointer to the opaque Rust object.
3694
3695         /// Nearly everywhere, inner must be non-null, however in places where
3696         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3697         pub inner: *mut nativeChannelUpdate,
3698         /// Indicates that this is the only struct which contains the same pointer.
3699
3700         /// Rust functions which take ownership of an object provided via an argument require
3701         /// this to be true and invalidate the object pointed to by inner.
3702         pub is_owned: bool,
3703 }
3704
3705 impl Drop for ChannelUpdate {
3706         fn drop(&mut self) {
3707                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
3708                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3709                 }
3710         }
3711 }
3712 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
3713 #[no_mangle]
3714 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
3715 #[allow(unused)]
3716 /// Used only if an object of this type is returned as a trait impl by a method
3717 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3718         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3719 }
3720 #[allow(unused)]
3721 impl ChannelUpdate {
3722         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
3723                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3724         }
3725         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
3726                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3727         }
3728         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3729         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3730                 assert!(self.is_owned);
3731                 let ret = ObjOps::untweak_ptr(self.inner);
3732                 self.inner = std::ptr::null_mut();
3733                 ret
3734         }
3735 }
3736 /// A signature of the channel update
3737 #[no_mangle]
3738 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3739         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3740         crate::c_types::Signature::from_rust(&inner_val)
3741 }
3742 /// A signature of the channel update
3743 #[no_mangle]
3744 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3745         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3746 }
3747 /// The actual channel update
3748 #[no_mangle]
3749 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
3750         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3751         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3752 }
3753 /// The actual channel update
3754 #[no_mangle]
3755 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
3756         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3757 }
3758 /// Constructs a new ChannelUpdate given each field
3759 #[must_use]
3760 #[no_mangle]
3761 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3762         ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
3763                 signature: signature_arg.into_rust(),
3764                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3765         }), is_owned: true }
3766 }
3767 impl Clone for ChannelUpdate {
3768         fn clone(&self) -> Self {
3769                 Self {
3770                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3771                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3772                         is_owned: true,
3773                 }
3774         }
3775 }
3776 #[allow(unused)]
3777 /// Used only if an object of this type is returned as a trait impl by a method
3778 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3779         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3780 }
3781 #[no_mangle]
3782 /// Creates a copy of the ChannelUpdate
3783 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3784         orig.clone()
3785 }
3786
3787 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3788 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3789
3790 /// A query_channel_range message is used to query a peer for channel
3791 /// UTXOs in a range of blocks. The recipient of a query makes a best
3792 /// effort to reply to the query using one or more reply_channel_range
3793 /// messages.
3794 #[must_use]
3795 #[repr(C)]
3796 pub struct QueryChannelRange {
3797         /// A pointer to the opaque Rust object.
3798
3799         /// Nearly everywhere, inner must be non-null, however in places where
3800         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3801         pub inner: *mut nativeQueryChannelRange,
3802         /// Indicates that this is the only struct which contains the same pointer.
3803
3804         /// Rust functions which take ownership of an object provided via an argument require
3805         /// this to be true and invalidate the object pointed to by inner.
3806         pub is_owned: bool,
3807 }
3808
3809 impl Drop for QueryChannelRange {
3810         fn drop(&mut self) {
3811                 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
3812                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3813                 }
3814         }
3815 }
3816 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
3817 #[no_mangle]
3818 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
3819 #[allow(unused)]
3820 /// Used only if an object of this type is returned as a trait impl by a method
3821 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3822         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3823 }
3824 #[allow(unused)]
3825 impl QueryChannelRange {
3826         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
3827                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3828         }
3829         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
3830                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3831         }
3832         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3833         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3834                 assert!(self.is_owned);
3835                 let ret = ObjOps::untweak_ptr(self.inner);
3836                 self.inner = std::ptr::null_mut();
3837                 ret
3838         }
3839 }
3840 /// The genesis hash of the blockchain being queried
3841 #[no_mangle]
3842 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3843         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3844         inner_val.as_inner()
3845 }
3846 /// The genesis hash of the blockchain being queried
3847 #[no_mangle]
3848 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3849         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3850 }
3851 /// The height of the first block for the channel UTXOs being queried
3852 #[no_mangle]
3853 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3854         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3855         *inner_val
3856 }
3857 /// The height of the first block for the channel UTXOs being queried
3858 #[no_mangle]
3859 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3860         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3861 }
3862 /// The number of blocks to include in the query results
3863 #[no_mangle]
3864 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3865         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3866         *inner_val
3867 }
3868 /// The number of blocks to include in the query results
3869 #[no_mangle]
3870 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3871         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3872 }
3873 /// Constructs a new QueryChannelRange given each field
3874 #[must_use]
3875 #[no_mangle]
3876 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 {
3877         QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
3878                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3879                 first_blocknum: first_blocknum_arg,
3880                 number_of_blocks: number_of_blocks_arg,
3881         }), is_owned: true }
3882 }
3883 impl Clone for QueryChannelRange {
3884         fn clone(&self) -> Self {
3885                 Self {
3886                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
3887                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3888                         is_owned: true,
3889                 }
3890         }
3891 }
3892 #[allow(unused)]
3893 /// Used only if an object of this type is returned as a trait impl by a method
3894 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3895         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3896 }
3897 #[no_mangle]
3898 /// Creates a copy of the QueryChannelRange
3899 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3900         orig.clone()
3901 }
3902
3903 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3904 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3905
3906 /// A reply_channel_range message is a reply to a query_channel_range
3907 /// message. Multiple reply_channel_range messages can be sent in reply
3908 /// to a single query_channel_range message. The query recipient makes a
3909 /// best effort to respond based on their local network view which may
3910 /// not be a perfect view of the network. The short_channel_ids in the
3911 /// reply are encoded. We only support encoding_type=0 uncompressed
3912 /// serialization and do not support encoding_type=1 zlib serialization.
3913 #[must_use]
3914 #[repr(C)]
3915 pub struct ReplyChannelRange {
3916         /// A pointer to the opaque Rust object.
3917
3918         /// Nearly everywhere, inner must be non-null, however in places where
3919         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3920         pub inner: *mut nativeReplyChannelRange,
3921         /// Indicates that this is the only struct which contains the same pointer.
3922
3923         /// Rust functions which take ownership of an object provided via an argument require
3924         /// this to be true and invalidate the object pointed to by inner.
3925         pub is_owned: bool,
3926 }
3927
3928 impl Drop for ReplyChannelRange {
3929         fn drop(&mut self) {
3930                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
3931                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3932                 }
3933         }
3934 }
3935 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
3936 #[no_mangle]
3937 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
3938 #[allow(unused)]
3939 /// Used only if an object of this type is returned as a trait impl by a method
3940 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3941         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3942 }
3943 #[allow(unused)]
3944 impl ReplyChannelRange {
3945         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
3946                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3947         }
3948         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
3949                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3950         }
3951         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3952         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3953                 assert!(self.is_owned);
3954                 let ret = ObjOps::untweak_ptr(self.inner);
3955                 self.inner = std::ptr::null_mut();
3956                 ret
3957         }
3958 }
3959 /// The genesis hash of the blockchain being queried
3960 #[no_mangle]
3961 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3962         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3963         inner_val.as_inner()
3964 }
3965 /// The genesis hash of the blockchain being queried
3966 #[no_mangle]
3967 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3968         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3969 }
3970 /// The height of the first block in the range of the reply
3971 #[no_mangle]
3972 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3973         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3974         *inner_val
3975 }
3976 /// The height of the first block in the range of the reply
3977 #[no_mangle]
3978 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3979         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3980 }
3981 /// The number of blocks included in the range of the reply
3982 #[no_mangle]
3983 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3984         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3985         *inner_val
3986 }
3987 /// The number of blocks included in the range of the reply
3988 #[no_mangle]
3989 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3990         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3991 }
3992 /// True when this is the final reply for a query
3993 #[no_mangle]
3994 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
3995         let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
3996         *inner_val
3997 }
3998 /// True when this is the final reply for a query
3999 #[no_mangle]
4000 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4001         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4002 }
4003 /// The short_channel_ids in the channel range
4004 #[no_mangle]
4005 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4006         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4007         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4008 }
4009 /// Constructs a new ReplyChannelRange given each field
4010 #[must_use]
4011 #[no_mangle]
4012 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 {
4013         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 }); };
4014         ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4015                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4016                 first_blocknum: first_blocknum_arg,
4017                 number_of_blocks: number_of_blocks_arg,
4018                 sync_complete: sync_complete_arg,
4019                 short_channel_ids: local_short_channel_ids_arg,
4020         }), is_owned: true }
4021 }
4022 impl Clone for ReplyChannelRange {
4023         fn clone(&self) -> Self {
4024                 Self {
4025                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
4026                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4027                         is_owned: true,
4028                 }
4029         }
4030 }
4031 #[allow(unused)]
4032 /// Used only if an object of this type is returned as a trait impl by a method
4033 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4034         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
4035 }
4036 #[no_mangle]
4037 /// Creates a copy of the ReplyChannelRange
4038 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
4039         orig.clone()
4040 }
4041
4042 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
4043 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
4044
4045 /// A query_short_channel_ids message is used to query a peer for
4046 /// routing gossip messages related to one or more short_channel_ids.
4047 /// The query recipient will reply with the latest, if available,
4048 /// channel_announcement, channel_update and node_announcement messages
4049 /// it maintains for the requested short_channel_ids followed by a
4050 /// reply_short_channel_ids_end message. The short_channel_ids sent in
4051 /// this query are encoded. We only support encoding_type=0 uncompressed
4052 /// serialization and do not support encoding_type=1 zlib serialization.
4053 #[must_use]
4054 #[repr(C)]
4055 pub struct QueryShortChannelIds {
4056         /// A pointer to the opaque Rust object.
4057
4058         /// Nearly everywhere, inner must be non-null, however in places where
4059         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4060         pub inner: *mut nativeQueryShortChannelIds,
4061         /// Indicates that this is the only struct which contains the same pointer.
4062
4063         /// Rust functions which take ownership of an object provided via an argument require
4064         /// this to be true and invalidate the object pointed to by inner.
4065         pub is_owned: bool,
4066 }
4067
4068 impl Drop for QueryShortChannelIds {
4069         fn drop(&mut self) {
4070                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
4071                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4072                 }
4073         }
4074 }
4075 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
4076 #[no_mangle]
4077 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
4078 #[allow(unused)]
4079 /// Used only if an object of this type is returned as a trait impl by a method
4080 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
4081         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
4082 }
4083 #[allow(unused)]
4084 impl QueryShortChannelIds {
4085         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
4086                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4087         }
4088         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
4089                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4090         }
4091         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4092         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
4093                 assert!(self.is_owned);
4094                 let ret = ObjOps::untweak_ptr(self.inner);
4095                 self.inner = std::ptr::null_mut();
4096                 ret
4097         }
4098 }
4099 /// The genesis hash of the blockchain being queried
4100 #[no_mangle]
4101 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
4102         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4103         inner_val.as_inner()
4104 }
4105 /// The genesis hash of the blockchain being queried
4106 #[no_mangle]
4107 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
4108         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4109 }
4110 /// The short_channel_ids that are being queried
4111 #[no_mangle]
4112 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
4113         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4114         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4115 }
4116 /// Constructs a new QueryShortChannelIds given each field
4117 #[must_use]
4118 #[no_mangle]
4119 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 {
4120         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 }); };
4121         QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
4122                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4123                 short_channel_ids: local_short_channel_ids_arg,
4124         }), is_owned: true }
4125 }
4126 impl Clone for QueryShortChannelIds {
4127         fn clone(&self) -> Self {
4128                 Self {
4129                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else {
4130                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4131                         is_owned: true,
4132                 }
4133         }
4134 }
4135 #[allow(unused)]
4136 /// Used only if an object of this type is returned as a trait impl by a method
4137 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
4138         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
4139 }
4140 #[no_mangle]
4141 /// Creates a copy of the QueryShortChannelIds
4142 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
4143         orig.clone()
4144 }
4145
4146 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
4147 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
4148
4149 /// A reply_short_channel_ids_end message is sent as a reply to a
4150 /// query_short_channel_ids message. The query recipient makes a best
4151 /// effort to respond based on their local network view which may not be
4152 /// a perfect view of the network.
4153 #[must_use]
4154 #[repr(C)]
4155 pub struct ReplyShortChannelIdsEnd {
4156         /// A pointer to the opaque Rust object.
4157
4158         /// Nearly everywhere, inner must be non-null, however in places where
4159         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4160         pub inner: *mut nativeReplyShortChannelIdsEnd,
4161         /// Indicates that this is the only struct which contains the same pointer.
4162
4163         /// Rust functions which take ownership of an object provided via an argument require
4164         /// this to be true and invalidate the object pointed to by inner.
4165         pub is_owned: bool,
4166 }
4167
4168 impl Drop for ReplyShortChannelIdsEnd {
4169         fn drop(&mut self) {
4170                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
4171                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4172                 }
4173         }
4174 }
4175 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
4176 #[no_mangle]
4177 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
4178 #[allow(unused)]
4179 /// Used only if an object of this type is returned as a trait impl by a method
4180 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
4181         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
4182 }
4183 #[allow(unused)]
4184 impl ReplyShortChannelIdsEnd {
4185         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
4186                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4187         }
4188         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
4189                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4190         }
4191         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4192         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
4193                 assert!(self.is_owned);
4194                 let ret = ObjOps::untweak_ptr(self.inner);
4195                 self.inner = std::ptr::null_mut();
4196                 ret
4197         }
4198 }
4199 /// The genesis hash of the blockchain that was queried
4200 #[no_mangle]
4201 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4202         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4203         inner_val.as_inner()
4204 }
4205 /// The genesis hash of the blockchain that was queried
4206 #[no_mangle]
4207 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4208         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
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_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4214         let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
4215         *inner_val
4216 }
4217 /// Indicates if the query recipient maintains up-to-date channel
4218 /// information for the chain_hash
4219 #[no_mangle]
4220 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4221         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
4222 }
4223 /// Constructs a new ReplyShortChannelIdsEnd given each field
4224 #[must_use]
4225 #[no_mangle]
4226 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4227         ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
4228                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4229                 full_information: full_information_arg,
4230         }), is_owned: true }
4231 }
4232 impl Clone for ReplyShortChannelIdsEnd {
4233         fn clone(&self) -> Self {
4234                 Self {
4235                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else {
4236                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4237                         is_owned: true,
4238                 }
4239         }
4240 }
4241 #[allow(unused)]
4242 /// Used only if an object of this type is returned as a trait impl by a method
4243 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
4244         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
4245 }
4246 #[no_mangle]
4247 /// Creates a copy of the ReplyShortChannelIdsEnd
4248 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
4249         orig.clone()
4250 }
4251
4252 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
4253 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
4254
4255 /// A gossip_timestamp_filter message is used by a node to request
4256 /// gossip relay for messages in the requested time range when the
4257 /// gossip_queries feature has been negotiated.
4258 #[must_use]
4259 #[repr(C)]
4260 pub struct GossipTimestampFilter {
4261         /// A pointer to the opaque Rust object.
4262
4263         /// Nearly everywhere, inner must be non-null, however in places where
4264         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4265         pub inner: *mut nativeGossipTimestampFilter,
4266         /// Indicates that this is the only struct which contains the same pointer.
4267
4268         /// Rust functions which take ownership of an object provided via an argument require
4269         /// this to be true and invalidate the object pointed to by inner.
4270         pub is_owned: bool,
4271 }
4272
4273 impl Drop for GossipTimestampFilter {
4274         fn drop(&mut self) {
4275                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
4276                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4277                 }
4278         }
4279 }
4280 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
4281 #[no_mangle]
4282 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
4283 #[allow(unused)]
4284 /// Used only if an object of this type is returned as a trait impl by a method
4285 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
4286         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
4287 }
4288 #[allow(unused)]
4289 impl GossipTimestampFilter {
4290         pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
4291                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4292         }
4293         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
4294                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4295         }
4296         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4297         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
4298                 assert!(self.is_owned);
4299                 let ret = ObjOps::untweak_ptr(self.inner);
4300                 self.inner = std::ptr::null_mut();
4301                 ret
4302         }
4303 }
4304 /// The genesis hash of the blockchain for channel and node information
4305 #[no_mangle]
4306 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
4307         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4308         inner_val.as_inner()
4309 }
4310 /// The genesis hash of the blockchain for channel and node information
4311 #[no_mangle]
4312 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
4313         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4314 }
4315 /// The starting unix timestamp
4316 #[no_mangle]
4317 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
4318         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
4319         *inner_val
4320 }
4321 /// The starting unix timestamp
4322 #[no_mangle]
4323 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4324         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
4325 }
4326 /// The range of information in seconds
4327 #[no_mangle]
4328 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
4329         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
4330         *inner_val
4331 }
4332 /// The range of information in seconds
4333 #[no_mangle]
4334 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4335         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
4336 }
4337 /// Constructs a new GossipTimestampFilter given each field
4338 #[must_use]
4339 #[no_mangle]
4340 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 {
4341         GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
4342                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4343                 first_timestamp: first_timestamp_arg,
4344                 timestamp_range: timestamp_range_arg,
4345         }), is_owned: true }
4346 }
4347 impl Clone for GossipTimestampFilter {
4348         fn clone(&self) -> Self {
4349                 Self {
4350                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else {
4351                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4352                         is_owned: true,
4353                 }
4354         }
4355 }
4356 #[allow(unused)]
4357 /// Used only if an object of this type is returned as a trait impl by a method
4358 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
4359         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
4360 }
4361 #[no_mangle]
4362 /// Creates a copy of the GossipTimestampFilter
4363 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4364         orig.clone()
4365 }
4366 /// Used to put an error message in a LightningError
4367 #[must_use]
4368 #[derive(Clone)]
4369 #[repr(C)]
4370 pub enum ErrorAction {
4371         /// The peer took some action which made us think they were useless. Disconnect them.
4372         DisconnectPeer {
4373                 /// An error message which we should make an effort to send before we disconnect.
4374                 ///
4375                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4376                 msg: crate::lightning::ln::msgs::ErrorMessage,
4377         },
4378         /// The peer did something harmless that we weren't able to process, just log and ignore
4379         IgnoreError,
4380         /// The peer did something harmless that we weren't able to meaningfully process.
4381         /// If the error is logged, log it at the given level.
4382         IgnoreAndLog(crate::lightning::util::logger::Level),
4383         /// The peer did something incorrect. Tell them.
4384         SendErrorMessage {
4385                 /// The message to send.
4386                 msg: crate::lightning::ln::msgs::ErrorMessage,
4387         },
4388 }
4389 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
4390 impl ErrorAction {
4391         #[allow(unused)]
4392         pub(crate) fn to_native(&self) -> nativeErrorAction {
4393                 match self {
4394                         ErrorAction::DisconnectPeer {ref msg, } => {
4395                                 let mut msg_nonref = (*msg).clone();
4396                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4397                                 nativeErrorAction::DisconnectPeer {
4398                                         msg: local_msg_nonref,
4399                                 }
4400                         },
4401                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4402                         ErrorAction::IgnoreAndLog (ref a, ) => {
4403                                 let mut a_nonref = (*a).clone();
4404                                 nativeErrorAction::IgnoreAndLog (
4405                                         a_nonref.into_native(),
4406                                 )
4407                         },
4408                         ErrorAction::SendErrorMessage {ref msg, } => {
4409                                 let mut msg_nonref = (*msg).clone();
4410                                 nativeErrorAction::SendErrorMessage {
4411                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4412                                 }
4413                         },
4414                 }
4415         }
4416         #[allow(unused)]
4417         pub(crate) fn into_native(self) -> nativeErrorAction {
4418                 match self {
4419                         ErrorAction::DisconnectPeer {mut msg, } => {
4420                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4421                                 nativeErrorAction::DisconnectPeer {
4422                                         msg: local_msg,
4423                                 }
4424                         },
4425                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4426                         ErrorAction::IgnoreAndLog (mut a, ) => {
4427                                 nativeErrorAction::IgnoreAndLog (
4428                                         a.into_native(),
4429                                 )
4430                         },
4431                         ErrorAction::SendErrorMessage {mut msg, } => {
4432                                 nativeErrorAction::SendErrorMessage {
4433                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
4434                                 }
4435                         },
4436                 }
4437         }
4438         #[allow(unused)]
4439         pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4440                 match native {
4441                         nativeErrorAction::DisconnectPeer {ref msg, } => {
4442                                 let mut msg_nonref = (*msg).clone();
4443                                 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 };
4444                                 ErrorAction::DisconnectPeer {
4445                                         msg: local_msg_nonref,
4446                                 }
4447                         },
4448                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4449                         nativeErrorAction::IgnoreAndLog (ref a, ) => {
4450                                 let mut a_nonref = (*a).clone();
4451                                 ErrorAction::IgnoreAndLog (
4452                                         crate::lightning::util::logger::Level::native_into(a_nonref),
4453                                 )
4454                         },
4455                         nativeErrorAction::SendErrorMessage {ref msg, } => {
4456                                 let mut msg_nonref = (*msg).clone();
4457                                 ErrorAction::SendErrorMessage {
4458                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4459                                 }
4460                         },
4461                 }
4462         }
4463         #[allow(unused)]
4464         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4465                 match native {
4466                         nativeErrorAction::DisconnectPeer {mut msg, } => {
4467                                 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 };
4468                                 ErrorAction::DisconnectPeer {
4469                                         msg: local_msg,
4470                                 }
4471                         },
4472                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4473                         nativeErrorAction::IgnoreAndLog (mut a, ) => {
4474                                 ErrorAction::IgnoreAndLog (
4475                                         crate::lightning::util::logger::Level::native_into(a),
4476                                 )
4477                         },
4478                         nativeErrorAction::SendErrorMessage {mut msg, } => {
4479                                 ErrorAction::SendErrorMessage {
4480                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4481                                 }
4482                         },
4483                 }
4484         }
4485 }
4486 /// Frees any resources used by the ErrorAction
4487 #[no_mangle]
4488 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4489 /// Creates a copy of the ErrorAction
4490 #[no_mangle]
4491 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4492         orig.clone()
4493 }
4494 #[no_mangle]
4495 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
4496 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4497         ErrorAction::DisconnectPeer {
4498                 msg,
4499         }
4500 }
4501 #[no_mangle]
4502 /// Utility method to constructs a new IgnoreError-variant ErrorAction
4503 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
4504         ErrorAction::IgnoreError}
4505 #[no_mangle]
4506 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
4507 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
4508         ErrorAction::IgnoreAndLog(a, )
4509 }
4510 #[no_mangle]
4511 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
4512 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4513         ErrorAction::SendErrorMessage {
4514                 msg,
4515         }
4516 }
4517
4518 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4519 type nativeLightningError = nativeLightningErrorImport;
4520
4521 /// An Err type for failure to process messages.
4522 #[must_use]
4523 #[repr(C)]
4524 pub struct LightningError {
4525         /// A pointer to the opaque Rust object.
4526
4527         /// Nearly everywhere, inner must be non-null, however in places where
4528         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4529         pub inner: *mut nativeLightningError,
4530         /// Indicates that this is the only struct which contains the same pointer.
4531
4532         /// Rust functions which take ownership of an object provided via an argument require
4533         /// this to be true and invalidate the object pointed to by inner.
4534         pub is_owned: bool,
4535 }
4536
4537 impl Drop for LightningError {
4538         fn drop(&mut self) {
4539                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4540                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4541                 }
4542         }
4543 }
4544 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
4545 #[no_mangle]
4546 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
4547 #[allow(unused)]
4548 /// Used only if an object of this type is returned as a trait impl by a method
4549 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
4550         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
4551 }
4552 #[allow(unused)]
4553 impl LightningError {
4554         pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
4555                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4556         }
4557         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
4558                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4559         }
4560         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4561         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
4562                 assert!(self.is_owned);
4563                 let ret = ObjOps::untweak_ptr(self.inner);
4564                 self.inner = std::ptr::null_mut();
4565                 ret
4566         }
4567 }
4568 /// A human-readable message describing the error
4569 #[no_mangle]
4570 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
4571         let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
4572         inner_val.as_str().into()
4573 }
4574 /// A human-readable message describing the error
4575 #[no_mangle]
4576 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
4577         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
4578 }
4579 /// The action which should be taken against the offending peer.
4580 #[no_mangle]
4581 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
4582         let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
4583         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
4584 }
4585 /// The action which should be taken against the offending peer.
4586 #[no_mangle]
4587 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
4588         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
4589 }
4590 /// Constructs a new LightningError given each field
4591 #[must_use]
4592 #[no_mangle]
4593 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
4594         LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
4595                 err: err_arg.into_string(),
4596                 action: action_arg.into_native(),
4597         }), is_owned: true }
4598 }
4599 impl Clone for LightningError {
4600         fn clone(&self) -> Self {
4601                 Self {
4602                         inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else {
4603                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4604                         is_owned: true,
4605                 }
4606         }
4607 }
4608 #[allow(unused)]
4609 /// Used only if an object of this type is returned as a trait impl by a method
4610 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
4611         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
4612 }
4613 #[no_mangle]
4614 /// Creates a copy of the LightningError
4615 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
4616         orig.clone()
4617 }
4618
4619 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
4620 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
4621
4622 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
4623 /// transaction updates if they were pending.
4624 #[must_use]
4625 #[repr(C)]
4626 pub struct CommitmentUpdate {
4627         /// A pointer to the opaque Rust object.
4628
4629         /// Nearly everywhere, inner must be non-null, however in places where
4630         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4631         pub inner: *mut nativeCommitmentUpdate,
4632         /// Indicates that this is the only struct which contains the same pointer.
4633
4634         /// Rust functions which take ownership of an object provided via an argument require
4635         /// this to be true and invalidate the object pointed to by inner.
4636         pub is_owned: bool,
4637 }
4638
4639 impl Drop for CommitmentUpdate {
4640         fn drop(&mut self) {
4641                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
4642                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4643                 }
4644         }
4645 }
4646 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
4647 #[no_mangle]
4648 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
4649 #[allow(unused)]
4650 /// Used only if an object of this type is returned as a trait impl by a method
4651 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
4652         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
4653 }
4654 #[allow(unused)]
4655 impl CommitmentUpdate {
4656         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
4657                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4658         }
4659         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
4660                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4661         }
4662         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4663         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
4664                 assert!(self.is_owned);
4665                 let ret = ObjOps::untweak_ptr(self.inner);
4666                 self.inner = std::ptr::null_mut();
4667                 ret
4668         }
4669 }
4670 /// update_add_htlc messages which should be sent
4671 #[no_mangle]
4672 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
4673         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
4674         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 _) as *mut _) }, is_owned: false } }); };
4675         local_inner_val.into()
4676 }
4677 /// update_add_htlc messages which should be sent
4678 #[no_mangle]
4679 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
4680         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4681         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
4682 }
4683 /// update_fulfill_htlc messages which should be sent
4684 #[no_mangle]
4685 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
4686         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
4687         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 _) as *mut _) }, is_owned: false } }); };
4688         local_inner_val.into()
4689 }
4690 /// update_fulfill_htlc messages which should be sent
4691 #[no_mangle]
4692 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
4693         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4694         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
4695 }
4696 /// update_fail_htlc messages which should be sent
4697 #[no_mangle]
4698 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
4699         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
4700         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 _) as *mut _) }, is_owned: false } }); };
4701         local_inner_val.into()
4702 }
4703 /// update_fail_htlc messages which should be sent
4704 #[no_mangle]
4705 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
4706         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4707         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
4708 }
4709 /// update_fail_malformed_htlc messages which should be sent
4710 #[no_mangle]
4711 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
4712         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
4713         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 _) as *mut _) }, is_owned: false } }); };
4714         local_inner_val.into()
4715 }
4716 /// update_fail_malformed_htlc messages which should be sent
4717 #[no_mangle]
4718 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
4719         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4720         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
4721 }
4722 /// An update_fee message which should be sent
4723 ///
4724 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4725 #[no_mangle]
4726 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
4727         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
4728         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 _) as *mut _ }, is_owned: false };
4729         local_inner_val
4730 }
4731 /// An update_fee message which should be sent
4732 ///
4733 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4734 #[no_mangle]
4735 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
4736         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4737         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
4738 }
4739 /// Finally, the commitment_signed message which should be sent
4740 #[no_mangle]
4741 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
4742         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
4743         crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
4744 }
4745 /// Finally, the commitment_signed message which should be sent
4746 #[no_mangle]
4747 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
4748         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
4749 }
4750 /// Constructs a new CommitmentUpdate given each field
4751 #[must_use]
4752 #[no_mangle]
4753 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 {
4754         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()) } }); };
4755         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()) } }); };
4756         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()) } }); };
4757         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()) } }); };
4758         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()) } }) };
4759         CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
4760                 update_add_htlcs: local_update_add_htlcs_arg,
4761                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
4762                 update_fail_htlcs: local_update_fail_htlcs_arg,
4763                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
4764                 update_fee: local_update_fee_arg,
4765                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
4766         }), is_owned: true }
4767 }
4768 impl Clone for CommitmentUpdate {
4769         fn clone(&self) -> Self {
4770                 Self {
4771                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
4772                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4773                         is_owned: true,
4774                 }
4775         }
4776 }
4777 #[allow(unused)]
4778 /// Used only if an object of this type is returned as a trait impl by a method
4779 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4780         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
4781 }
4782 #[no_mangle]
4783 /// Creates a copy of the CommitmentUpdate
4784 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
4785         orig.clone()
4786 }
4787 /// A trait to describe an object which can receive channel messages.
4788 ///
4789 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4790 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4791 #[repr(C)]
4792 pub struct ChannelMessageHandler {
4793         /// An opaque pointer which is passed to your function implementations as an argument.
4794         /// This has no meaning in the LDK, and can be NULL or any other value.
4795         pub this_arg: *mut c_void,
4796         /// Handle an incoming open_channel message from the given peer.
4797         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),
4798         /// Handle an incoming accept_channel message from the given peer.
4799         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),
4800         /// Handle an incoming funding_created message from the given peer.
4801         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),
4802         /// Handle an incoming funding_signed message from the given peer.
4803         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),
4804         /// Handle an incoming funding_locked message from the given peer.
4805         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),
4806         /// Handle an incoming shutdown message from the given peer.
4807         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),
4808         /// Handle an incoming closing_signed message from the given peer.
4809         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),
4810         /// Handle an incoming update_add_htlc message from the given peer.
4811         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),
4812         /// Handle an incoming update_fulfill_htlc message from the given peer.
4813         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),
4814         /// Handle an incoming update_fail_htlc message from the given peer.
4815         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),
4816         /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4817         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),
4818         /// Handle an incoming commitment_signed message from the given peer.
4819         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),
4820         /// Handle an incoming revoke_and_ack message from the given peer.
4821         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),
4822         /// Handle an incoming update_fee message from the given peer.
4823         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),
4824         /// Handle an incoming announcement_signatures message from the given peer.
4825         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),
4826         /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4827         /// is believed to be possible in the future (eg they're sending us messages we don't
4828         /// understand or indicate they require unknown feature bits), no_connection_possible is set
4829         /// and any outstanding channels should be failed.
4830         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4831         /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4832         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
4833         /// Handle an incoming channel_reestablish message from the given peer.
4834         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),
4835         /// Handle an incoming channel update from the given peer.
4836         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),
4837         /// Handle an incoming error message from the given peer.
4838         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
4839         /// Implementation of MessageSendEventsProvider for this object.
4840         pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
4841         /// Frees any resources associated with this object given its this_arg pointer.
4842         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4843         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4844 }
4845 unsafe impl Send for ChannelMessageHandler {}
4846 unsafe impl Sync for ChannelMessageHandler {}
4847 #[no_mangle]
4848 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
4849         ChannelMessageHandler {
4850                 this_arg: orig.this_arg,
4851                 handle_open_channel: Clone::clone(&orig.handle_open_channel),
4852                 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
4853                 handle_funding_created: Clone::clone(&orig.handle_funding_created),
4854                 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
4855                 handle_funding_locked: Clone::clone(&orig.handle_funding_locked),
4856                 handle_shutdown: Clone::clone(&orig.handle_shutdown),
4857                 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
4858                 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
4859                 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
4860                 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
4861                 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
4862                 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
4863                 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
4864                 handle_update_fee: Clone::clone(&orig.handle_update_fee),
4865                 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
4866                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
4867                 peer_connected: Clone::clone(&orig.peer_connected),
4868                 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
4869                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
4870                 handle_error: Clone::clone(&orig.handle_error),
4871                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
4872                 free: Clone::clone(&orig.free),
4873         }
4874 }
4875 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4876         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4877                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
4878                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4879                 local_ret
4880         }
4881 }
4882
4883 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4884 impl rustChannelMessageHandler for ChannelMessageHandler {
4885         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) {
4886                 (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 _) as *mut _) }, is_owned: false })
4887         }
4888         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) {
4889                 (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 _) as *mut _) }, is_owned: false })
4890         }
4891         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
4892                 (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 _) as *mut _) }, is_owned: false })
4893         }
4894         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
4895                 (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 _) as *mut _) }, is_owned: false })
4896         }
4897         fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) {
4898                 (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 _) as *mut _) }, is_owned: false })
4899         }
4900         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) {
4901                 (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 _) as *mut _) }, is_owned: false }, &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false })
4902         }
4903         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
4904                 (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 _) as *mut _) }, is_owned: false })
4905         }
4906         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
4907                 (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 _) as *mut _) }, is_owned: false })
4908         }
4909         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4910                 (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 _) as *mut _) }, is_owned: false })
4911         }
4912         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
4913                 (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 _) as *mut _) }, is_owned: false })
4914         }
4915         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4916                 (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 _) as *mut _) }, is_owned: false })
4917         }
4918         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
4919                 (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 _) as *mut _) }, is_owned: false })
4920         }
4921         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
4922                 (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 _) as *mut _) }, is_owned: false })
4923         }
4924         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
4925                 (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 _) as *mut _) }, is_owned: false })
4926         }
4927         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
4928                 (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 _) as *mut _) }, is_owned: false })
4929         }
4930         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) {
4931                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4932         }
4933         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) {
4934                 (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 _) as *mut _) }, is_owned: false })
4935         }
4936         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
4937                 (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 _) as *mut _) }, is_owned: false })
4938         }
4939         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
4940                 (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 _) as *mut _) }, is_owned: false })
4941         }
4942         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
4943                 (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 _) as *mut _) }, is_owned: false })
4944         }
4945 }
4946
4947 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4948 // directly as a Deref trait in higher-level structs:
4949 impl std::ops::Deref for ChannelMessageHandler {
4950         type Target = Self;
4951         fn deref(&self) -> &Self {
4952                 self
4953         }
4954 }
4955 /// Calls the free function if one is set
4956 #[no_mangle]
4957 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4958 impl Drop for ChannelMessageHandler {
4959         fn drop(&mut self) {
4960                 if let Some(f) = self.free {
4961                         f(self.this_arg);
4962                 }
4963         }
4964 }
4965 /// A trait to describe an object which can receive routing messages.
4966 ///
4967 /// # Implementor DoS Warnings
4968 ///
4969 /// For `gossip_queries` messages there are potential DoS vectors when handling
4970 /// inbound queries. Implementors using an on-disk network graph should be aware of
4971 /// repeated disk I/O for queries accessing different parts of the network graph.
4972 #[repr(C)]
4973 pub struct RoutingMessageHandler {
4974         /// An opaque pointer which is passed to your function implementations as an argument.
4975         /// This has no meaning in the LDK, and can be NULL or any other value.
4976         pub this_arg: *mut c_void,
4977         /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4978         /// false or returning an Err otherwise.
4979         #[must_use]
4980         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4981         /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4982         /// or returning an Err otherwise.
4983         #[must_use]
4984         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4985         /// Handle an incoming channel_update message, returning true if it should be forwarded on,
4986         /// false or returning an Err otherwise.
4987         #[must_use]
4988         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4989         /// Gets a subset of the channel announcements and updates required to dump our routing table
4990         /// to a remote node, starting at the short_channel_id indicated by starting_point and
4991         /// including the batch_amount entries immediately higher in numerical value than starting_point.
4992         #[must_use]
4993         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,
4994         /// Gets a subset of the node announcements required to dump our routing table to a remote node,
4995         /// starting at the node *after* the provided publickey and including batch_amount entries
4996         /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
4997         /// If None is provided for starting_point, we start at the first node.
4998         ///
4999         /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
5000         #[must_use]
5001         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,
5002         /// Called when a connection is established with a peer. This can be used to
5003         /// perform routing table synchronization using a strategy defined by the
5004         /// implementor.
5005         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),
5006         /// Handles the reply of a query we initiated to learn about channels
5007         /// for a given range of blocks. We can expect to receive one or more
5008         /// replies to a single query.
5009         #[must_use]
5010         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,
5011         /// Handles the reply of a query we initiated asking for routing gossip
5012         /// messages for a list of channels. We should receive this message when
5013         /// a node has completed its best effort to send us the pertaining routing
5014         /// gossip messages.
5015         #[must_use]
5016         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,
5017         /// Handles when a peer asks us to send a list of short_channel_ids
5018         /// for the requested range of blocks.
5019         #[must_use]
5020         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,
5021         /// Handles when a peer asks us to send routing gossip messages for a
5022         /// list of short_channel_ids.
5023         #[must_use]
5024         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,
5025         /// Implementation of MessageSendEventsProvider for this object.
5026         pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5027         /// Frees any resources associated with this object given its this_arg pointer.
5028         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5029         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5030 }
5031 unsafe impl Send for RoutingMessageHandler {}
5032 unsafe impl Sync for RoutingMessageHandler {}
5033 #[no_mangle]
5034 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
5035         RoutingMessageHandler {
5036                 this_arg: orig.this_arg,
5037                 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
5038                 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
5039                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5040                 get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
5041                 get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
5042                 sync_routing_table: Clone::clone(&orig.sync_routing_table),
5043                 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
5044                 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
5045                 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
5046                 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
5047                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5048                 free: Clone::clone(&orig.free),
5049         }
5050 }
5051 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
5052         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5053                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5054                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5055                 local_ret
5056         }
5057 }
5058
5059 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
5060 impl rustRoutingMessageHandler for RoutingMessageHandler {
5061         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5062                 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 _) as *mut _) }, is_owned: false });
5063                 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()) } })};
5064                 local_ret
5065         }
5066         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5067                 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 _) as *mut _) }, is_owned: false });
5068                 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()) } })};
5069                 local_ret
5070         }
5071         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
5072                 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 _) as *mut _) }, is_owned: false });
5073                 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()) } })};
5074                 local_ret
5075         }
5076         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>)> {
5077                 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
5078                 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 }); };
5079                 local_ret
5080         }
5081         fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
5082                 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())) } };
5083                 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
5084                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5085                 local_ret
5086         }
5087         fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
5088                 (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 _) as *mut _) }, is_owned: false })
5089         }
5090         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> {
5091                 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 });
5092                 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()) } })};
5093                 local_ret
5094         }
5095         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> {
5096                 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 });
5097                 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()) } })};
5098                 local_ret
5099         }
5100         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> {
5101                 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 });
5102                 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()) } })};
5103                 local_ret
5104         }
5105         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> {
5106                 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 });
5107                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
5108                 local_ret
5109         }
5110 }
5111
5112 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5113 // directly as a Deref trait in higher-level structs:
5114 impl std::ops::Deref for RoutingMessageHandler {
5115         type Target = Self;
5116         fn deref(&self) -> &Self {
5117                 self
5118         }
5119 }
5120 /// Calls the free function if one is set
5121 #[no_mangle]
5122 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
5123 impl Drop for RoutingMessageHandler {
5124         fn drop(&mut self) {
5125                 if let Some(f) = self.free {
5126                         f(self.this_arg);
5127                 }
5128         }
5129 }
5130 mod fuzzy_internal_msgs {
5131
5132 use std::str::FromStr;
5133 use std::ffi::c_void;
5134 use core::convert::Infallible;
5135 use bitcoin::hashes::Hash;
5136 use crate::c_types::*;
5137
5138 }
5139 #[no_mangle]
5140 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
5141 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
5142         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5143 }
5144 #[no_mangle]
5145 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5146         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
5147 }
5148 #[no_mangle]
5149 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
5150 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
5151         let res = crate::c_types::deserialize_obj(ser);
5152         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() };
5153         local_res
5154 }
5155 #[no_mangle]
5156 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
5157 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
5158         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5159 }
5160 #[no_mangle]
5161 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5162         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
5163 }
5164 #[no_mangle]
5165 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
5166 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
5167         let res = crate::c_types::deserialize_obj(ser);
5168         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() };
5169         local_res
5170 }
5171 #[no_mangle]
5172 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
5173 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
5174         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5175 }
5176 #[no_mangle]
5177 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5178         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
5179 }
5180 #[no_mangle]
5181 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
5182 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
5183         let res = crate::c_types::deserialize_obj(ser);
5184         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() };
5185         local_res
5186 }
5187 #[no_mangle]
5188 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
5189 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
5190         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5191 }
5192 #[no_mangle]
5193 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5194         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
5195 }
5196 #[no_mangle]
5197 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
5198 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
5199         let res = crate::c_types::deserialize_obj(ser);
5200         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() };
5201         local_res
5202 }
5203 #[no_mangle]
5204 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
5205 pub extern "C" fn ClosingSignedFeeRange_write(obj: &ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
5206         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5207 }
5208 #[no_mangle]
5209 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5210         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
5211 }
5212 #[no_mangle]
5213 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
5214 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
5215         let res = crate::c_types::deserialize_obj(ser);
5216         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() };
5217         local_res
5218 }
5219 #[no_mangle]
5220 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
5221 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
5222         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5223 }
5224 #[no_mangle]
5225 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5226         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
5227 }
5228 #[no_mangle]
5229 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
5230 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
5231         let res = crate::c_types::deserialize_obj(ser);
5232         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() };
5233         local_res
5234 }
5235 #[no_mangle]
5236 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
5237 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
5238         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5239 }
5240 #[no_mangle]
5241 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5242         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
5243 }
5244 #[no_mangle]
5245 /// Read a FundingCreated from a byte array, created by FundingCreated_write
5246 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
5247         let res = crate::c_types::deserialize_obj(ser);
5248         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() };
5249         local_res
5250 }
5251 #[no_mangle]
5252 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
5253 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
5254         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5255 }
5256 #[no_mangle]
5257 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5258         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
5259 }
5260 #[no_mangle]
5261 /// Read a FundingSigned from a byte array, created by FundingSigned_write
5262 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
5263         let res = crate::c_types::deserialize_obj(ser);
5264         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() };
5265         local_res
5266 }
5267 #[no_mangle]
5268 /// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read
5269 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
5270         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5271 }
5272 #[no_mangle]
5273 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5274         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
5275 }
5276 #[no_mangle]
5277 /// Read a FundingLocked from a byte array, created by FundingLocked_write
5278 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
5279         let res = crate::c_types::deserialize_obj(ser);
5280         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() };
5281         local_res
5282 }
5283 #[no_mangle]
5284 /// Serialize the Init object into a byte array which can be read by Init_read
5285 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
5286         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5287 }
5288 #[no_mangle]
5289 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5290         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
5291 }
5292 #[no_mangle]
5293 /// Read a Init from a byte array, created by Init_write
5294 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
5295         let res = crate::c_types::deserialize_obj(ser);
5296         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() };
5297         local_res
5298 }
5299 #[no_mangle]
5300 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
5301 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
5302         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5303 }
5304 #[no_mangle]
5305 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5306         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
5307 }
5308 #[no_mangle]
5309 /// Read a OpenChannel from a byte array, created by OpenChannel_write
5310 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
5311         let res = crate::c_types::deserialize_obj(ser);
5312         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() };
5313         local_res
5314 }
5315 #[no_mangle]
5316 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
5317 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
5318         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5319 }
5320 #[no_mangle]
5321 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5322         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
5323 }
5324 #[no_mangle]
5325 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
5326 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
5327         let res = crate::c_types::deserialize_obj(ser);
5328         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() };
5329         local_res
5330 }
5331 #[no_mangle]
5332 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
5333 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
5334         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5335 }
5336 #[no_mangle]
5337 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5338         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
5339 }
5340 #[no_mangle]
5341 /// Read a Shutdown from a byte array, created by Shutdown_write
5342 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
5343         let res = crate::c_types::deserialize_obj(ser);
5344         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() };
5345         local_res
5346 }
5347 #[no_mangle]
5348 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
5349 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
5350         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5351 }
5352 #[no_mangle]
5353 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5354         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
5355 }
5356 #[no_mangle]
5357 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
5358 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
5359         let res = crate::c_types::deserialize_obj(ser);
5360         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() };
5361         local_res
5362 }
5363 #[no_mangle]
5364 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
5365 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
5366         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5367 }
5368 #[no_mangle]
5369 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5370         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
5371 }
5372 #[no_mangle]
5373 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
5374 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
5375         let res = crate::c_types::deserialize_obj(ser);
5376         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() };
5377         local_res
5378 }
5379 #[no_mangle]
5380 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5381 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
5382         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5383 }
5384 #[no_mangle]
5385 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5386         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5387 }
5388 #[no_mangle]
5389 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5390 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
5391         let res = crate::c_types::deserialize_obj(ser);
5392         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() };
5393         local_res
5394 }
5395 #[no_mangle]
5396 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5397 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
5398         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5399 }
5400 #[no_mangle]
5401 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5402         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
5403 }
5404 #[no_mangle]
5405 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
5406 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
5407         let res = crate::c_types::deserialize_obj(ser);
5408         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5409         local_res
5410 }
5411 #[no_mangle]
5412 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
5413 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
5414         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5415 }
5416 #[no_mangle]
5417 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5418         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
5419 }
5420 #[no_mangle]
5421 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
5422 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
5423         let res = crate::c_types::deserialize_obj(ser);
5424         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5425         local_res
5426 }
5427 #[no_mangle]
5428 /// Serialize the Ping object into a byte array which can be read by Ping_read
5429 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
5430         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5431 }
5432 #[no_mangle]
5433 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5434         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
5435 }
5436 #[no_mangle]
5437 /// Read a Ping from a byte array, created by Ping_write
5438 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
5439         let res = crate::c_types::deserialize_obj(ser);
5440         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5441         local_res
5442 }
5443 #[no_mangle]
5444 /// Serialize the Pong object into a byte array which can be read by Pong_read
5445 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
5446         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5447 }
5448 #[no_mangle]
5449 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5450         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
5451 }
5452 #[no_mangle]
5453 /// Read a Pong from a byte array, created by Pong_write
5454 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
5455         let res = crate::c_types::deserialize_obj(ser);
5456         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5457         local_res
5458 }
5459 #[no_mangle]
5460 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
5461 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5462         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5463 }
5464 #[no_mangle]
5465 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5466         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
5467 }
5468 #[no_mangle]
5469 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
5470 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
5471         let res = crate::c_types::deserialize_obj(ser);
5472         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5473         local_res
5474 }
5475 #[no_mangle]
5476 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
5477 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5478         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5479 }
5480 #[no_mangle]
5481 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5482         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
5483 }
5484 #[no_mangle]
5485 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
5486 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
5487         let res = crate::c_types::deserialize_obj(ser);
5488         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5489         local_res
5490 }
5491 #[no_mangle]
5492 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
5493 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5494         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5495 }
5496 #[no_mangle]
5497 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5498         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
5499 }
5500 #[no_mangle]
5501 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
5502 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
5503         let res = crate::c_types::deserialize_obj(ser);
5504         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5505         local_res
5506 }
5507 #[no_mangle]
5508 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
5509 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5510         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5511 }
5512 #[no_mangle]
5513 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5514         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
5515 }
5516 #[no_mangle]
5517 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
5518 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
5519         let res = crate::c_types::deserialize_obj(ser);
5520         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5521         local_res
5522 }
5523 #[no_mangle]
5524 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
5525 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
5526         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5527 }
5528 #[no_mangle]
5529 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5530         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
5531 }
5532 #[no_mangle]
5533 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
5534 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
5535         let res = crate::c_types::deserialize_obj(ser);
5536         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5537         local_res
5538 }
5539 #[no_mangle]
5540 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
5541 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5542         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5543 }
5544 #[no_mangle]
5545 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5546         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
5547 }
5548 #[no_mangle]
5549 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
5550 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
5551         let res = crate::c_types::deserialize_obj(ser);
5552         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5553         local_res
5554 }
5555 #[no_mangle]
5556 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
5557 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5558         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5559 }
5560 #[no_mangle]
5561 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5562         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
5563 }
5564 #[no_mangle]
5565 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
5566 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
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::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() };
5569         local_res
5570 }
5571 #[no_mangle]
5572 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
5573 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
5574         let res = crate::c_types::deserialize_obj(ser);
5575         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() };
5576         local_res
5577 }
5578 #[no_mangle]
5579 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
5580 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
5581         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5582 }
5583 #[no_mangle]
5584 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5585         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
5586 }
5587 #[no_mangle]
5588 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
5589 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
5590         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5591 }
5592 #[no_mangle]
5593 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5594         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
5595 }
5596 #[no_mangle]
5597 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
5598 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
5599         let res = crate::c_types::deserialize_obj(ser);
5600         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5601         local_res
5602 }
5603 ///\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 
5604 #[must_use]
5605 #[no_mangle]
5606 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 {
5607         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
5608         ret
5609 }
5610
5611 #[no_mangle]
5612 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
5613 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
5614         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5615 }
5616 #[no_mangle]
5617 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5618         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
5619 }
5620 #[no_mangle]
5621 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
5622 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
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::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() };
5625         local_res
5626 }
5627 #[no_mangle]
5628 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
5629 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
5630         let res = crate::c_types::deserialize_obj(ser);
5631         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() };
5632         local_res
5633 }
5634 #[no_mangle]
5635 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
5636 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
5637         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5638 }
5639 #[no_mangle]
5640 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5641         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
5642 }
5643 #[no_mangle]
5644 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
5645 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
5646         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5647 }
5648 #[no_mangle]
5649 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5650         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
5651 }
5652 #[no_mangle]
5653 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
5654 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
5655         let res = crate::c_types::deserialize_obj(ser);
5656         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() };
5657         local_res
5658 }