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