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