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