Regenerate 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 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
2681 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2682         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2683 }
2684 #[no_mangle]
2685 /// Read a Result from a byte array, created by Result_write
2686 pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ {
2687         let res = crate::c_types::deserialize_obj(ser);
2688         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() };
2689         local_res
2690 }
2691 #[no_mangle]
2692 /// Read a NetAddress from a byte array, created by NetAddress_write
2693 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
2694         let res = crate::c_types::deserialize_obj(ser);
2695         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() };
2696         local_res
2697 }
2698
2699 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2700 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2701
2702 /// The unsigned part of a node_announcement
2703 #[must_use]
2704 #[repr(C)]
2705 pub struct UnsignedNodeAnnouncement {
2706         /// A pointer to the opaque Rust object.
2707
2708         /// Nearly everywhere, inner must be non-null, however in places where
2709         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2710         pub inner: *mut nativeUnsignedNodeAnnouncement,
2711         /// Indicates that this is the only struct which contains the same pointer.
2712
2713         /// Rust functions which take ownership of an object provided via an argument require
2714         /// this to be true and invalidate the object pointed to by inner.
2715         pub is_owned: bool,
2716 }
2717
2718 impl Drop for UnsignedNodeAnnouncement {
2719         fn drop(&mut self) {
2720                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
2721                         let _ = unsafe { Box::from_raw(self.inner) };
2722                 }
2723         }
2724 }
2725 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
2726 #[no_mangle]
2727 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
2728 #[allow(unused)]
2729 /// Used only if an object of this type is returned as a trait impl by a method
2730 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
2731         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
2732 }
2733 #[allow(unused)]
2734 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2735 impl UnsignedNodeAnnouncement {
2736         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
2737                 assert!(self.is_owned);
2738                 let ret = self.inner;
2739                 self.inner = std::ptr::null_mut();
2740                 ret
2741         }
2742 }
2743 /// The advertised features
2744 #[no_mangle]
2745 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
2746         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2747         crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
2748 }
2749 /// The advertised features
2750 #[no_mangle]
2751 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
2752         unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2753 }
2754 /// A strictly monotonic announcement counter, with gaps allowed
2755 #[no_mangle]
2756 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
2757         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2758         *inner_val
2759 }
2760 /// A strictly monotonic announcement counter, with gaps allowed
2761 #[no_mangle]
2762 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
2763         unsafe { &mut *this_ptr.inner }.timestamp = val;
2764 }
2765 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2766 /// to this node).
2767 #[no_mangle]
2768 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
2769         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
2770         crate::c_types::PublicKey::from_rust(&inner_val)
2771 }
2772 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2773 /// to this node).
2774 #[no_mangle]
2775 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
2776         unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
2777 }
2778 /// An RGB color for UI purposes
2779 #[no_mangle]
2780 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
2781         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
2782         inner_val
2783 }
2784 /// An RGB color for UI purposes
2785 #[no_mangle]
2786 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
2787         unsafe { &mut *this_ptr.inner }.rgb = val.data;
2788 }
2789 /// An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
2790 /// of uniqueness.
2791 #[no_mangle]
2792 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
2793         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
2794         inner_val
2795 }
2796 /// An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
2797 /// of uniqueness.
2798 #[no_mangle]
2799 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2800         unsafe { &mut *this_ptr.inner }.alias = val.data;
2801 }
2802 /// List of addresses on which this node is reachable
2803 #[no_mangle]
2804 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
2805         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
2806         unsafe { &mut *this_ptr.inner }.addresses = local_val;
2807 }
2808 impl Clone for UnsignedNodeAnnouncement {
2809         fn clone(&self) -> Self {
2810                 Self {
2811                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
2812                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2813                         is_owned: true,
2814                 }
2815         }
2816 }
2817 #[allow(unused)]
2818 /// Used only if an object of this type is returned as a trait impl by a method
2819 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2820         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
2821 }
2822 #[no_mangle]
2823 /// Creates a copy of the UnsignedNodeAnnouncement
2824 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
2825         orig.clone()
2826 }
2827
2828 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
2829 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
2830
2831 /// A node_announcement message to be sent or received from a peer
2832 #[must_use]
2833 #[repr(C)]
2834 pub struct NodeAnnouncement {
2835         /// A pointer to the opaque Rust object.
2836
2837         /// Nearly everywhere, inner must be non-null, however in places where
2838         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2839         pub inner: *mut nativeNodeAnnouncement,
2840         /// Indicates that this is the only struct which contains the same pointer.
2841
2842         /// Rust functions which take ownership of an object provided via an argument require
2843         /// this to be true and invalidate the object pointed to by inner.
2844         pub is_owned: bool,
2845 }
2846
2847 impl Drop for NodeAnnouncement {
2848         fn drop(&mut self) {
2849                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
2850                         let _ = unsafe { Box::from_raw(self.inner) };
2851                 }
2852         }
2853 }
2854 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
2855 #[no_mangle]
2856 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
2857 #[allow(unused)]
2858 /// Used only if an object of this type is returned as a trait impl by a method
2859 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
2860         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
2861 }
2862 #[allow(unused)]
2863 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2864 impl NodeAnnouncement {
2865         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
2866                 assert!(self.is_owned);
2867                 let ret = self.inner;
2868                 self.inner = std::ptr::null_mut();
2869                 ret
2870         }
2871 }
2872 /// The signature by the node key
2873 #[no_mangle]
2874 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
2875         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2876         crate::c_types::Signature::from_rust(&inner_val)
2877 }
2878 /// The signature by the node key
2879 #[no_mangle]
2880 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
2881         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2882 }
2883 /// The actual content of the announcement
2884 #[no_mangle]
2885 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
2886         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2887         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
2888 }
2889 /// The actual content of the announcement
2890 #[no_mangle]
2891 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
2892         unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2893 }
2894 /// Constructs a new NodeAnnouncement given each field
2895 #[must_use]
2896 #[no_mangle]
2897 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
2898         NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement {
2899                 signature: signature_arg.into_rust(),
2900                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2901         })), is_owned: true }
2902 }
2903 impl Clone for NodeAnnouncement {
2904         fn clone(&self) -> Self {
2905                 Self {
2906                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
2907                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2908                         is_owned: true,
2909                 }
2910         }
2911 }
2912 #[allow(unused)]
2913 /// Used only if an object of this type is returned as a trait impl by a method
2914 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2915         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
2916 }
2917 #[no_mangle]
2918 /// Creates a copy of the NodeAnnouncement
2919 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
2920         orig.clone()
2921 }
2922
2923 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
2924 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
2925
2926 /// The unsigned part of a channel_announcement
2927 #[must_use]
2928 #[repr(C)]
2929 pub struct UnsignedChannelAnnouncement {
2930         /// A pointer to the opaque Rust object.
2931
2932         /// Nearly everywhere, inner must be non-null, however in places where
2933         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2934         pub inner: *mut nativeUnsignedChannelAnnouncement,
2935         /// Indicates that this is the only struct which contains the same pointer.
2936
2937         /// Rust functions which take ownership of an object provided via an argument require
2938         /// this to be true and invalidate the object pointed to by inner.
2939         pub is_owned: bool,
2940 }
2941
2942 impl Drop for UnsignedChannelAnnouncement {
2943         fn drop(&mut self) {
2944                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
2945                         let _ = unsafe { Box::from_raw(self.inner) };
2946                 }
2947         }
2948 }
2949 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
2950 #[no_mangle]
2951 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
2952 #[allow(unused)]
2953 /// Used only if an object of this type is returned as a trait impl by a method
2954 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2955         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
2956 }
2957 #[allow(unused)]
2958 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2959 impl UnsignedChannelAnnouncement {
2960         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
2961                 assert!(self.is_owned);
2962                 let ret = self.inner;
2963                 self.inner = std::ptr::null_mut();
2964                 ret
2965         }
2966 }
2967 /// The advertised channel features
2968 #[no_mangle]
2969 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
2970         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2971         crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
2972 }
2973 /// The advertised channel features
2974 #[no_mangle]
2975 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
2976         unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2977 }
2978 /// The genesis hash of the blockchain where the channel is to be opened
2979 #[no_mangle]
2980 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
2981         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2982         inner_val.as_inner()
2983 }
2984 /// The genesis hash of the blockchain where the channel is to be opened
2985 #[no_mangle]
2986 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2987         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2988 }
2989 /// The short channel ID
2990 #[no_mangle]
2991 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
2992         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2993         *inner_val
2994 }
2995 /// The short channel ID
2996 #[no_mangle]
2997 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
2998         unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2999 }
3000 /// One of the two node_ids which are endpoints of this channel
3001 #[no_mangle]
3002 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3003         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1;
3004         crate::c_types::PublicKey::from_rust(&inner_val)
3005 }
3006 /// One of the two node_ids which are endpoints of this channel
3007 #[no_mangle]
3008 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3009         unsafe { &mut *this_ptr.inner }.node_id_1 = val.into_rust();
3010 }
3011 /// The other of the two node_ids which are endpoints of this channel
3012 #[no_mangle]
3013 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3014         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2;
3015         crate::c_types::PublicKey::from_rust(&inner_val)
3016 }
3017 /// The other of the two node_ids which are endpoints of this channel
3018 #[no_mangle]
3019 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3020         unsafe { &mut *this_ptr.inner }.node_id_2 = val.into_rust();
3021 }
3022 /// The funding key for the first node
3023 #[no_mangle]
3024 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3025         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1;
3026         crate::c_types::PublicKey::from_rust(&inner_val)
3027 }
3028 /// The funding key for the first node
3029 #[no_mangle]
3030 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3031         unsafe { &mut *this_ptr.inner }.bitcoin_key_1 = val.into_rust();
3032 }
3033 /// The funding key for the second node
3034 #[no_mangle]
3035 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3036         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2;
3037         crate::c_types::PublicKey::from_rust(&inner_val)
3038 }
3039 /// The funding key for the second node
3040 #[no_mangle]
3041 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3042         unsafe { &mut *this_ptr.inner }.bitcoin_key_2 = val.into_rust();
3043 }
3044 impl Clone for UnsignedChannelAnnouncement {
3045         fn clone(&self) -> Self {
3046                 Self {
3047                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3048                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3049                         is_owned: true,
3050                 }
3051         }
3052 }
3053 #[allow(unused)]
3054 /// Used only if an object of this type is returned as a trait impl by a method
3055 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3056         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3057 }
3058 #[no_mangle]
3059 /// Creates a copy of the UnsignedChannelAnnouncement
3060 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3061         orig.clone()
3062 }
3063
3064 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3065 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3066
3067 /// A channel_announcement message to be sent or received from a peer
3068 #[must_use]
3069 #[repr(C)]
3070 pub struct ChannelAnnouncement {
3071         /// A pointer to the opaque Rust object.
3072
3073         /// Nearly everywhere, inner must be non-null, however in places where
3074         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3075         pub inner: *mut nativeChannelAnnouncement,
3076         /// Indicates that this is the only struct which contains the same pointer.
3077
3078         /// Rust functions which take ownership of an object provided via an argument require
3079         /// this to be true and invalidate the object pointed to by inner.
3080         pub is_owned: bool,
3081 }
3082
3083 impl Drop for ChannelAnnouncement {
3084         fn drop(&mut self) {
3085                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3086                         let _ = unsafe { Box::from_raw(self.inner) };
3087                 }
3088         }
3089 }
3090 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3091 #[no_mangle]
3092 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3093 #[allow(unused)]
3094 /// Used only if an object of this type is returned as a trait impl by a method
3095 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3096         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3097 }
3098 #[allow(unused)]
3099 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3100 impl ChannelAnnouncement {
3101         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3102                 assert!(self.is_owned);
3103                 let ret = self.inner;
3104                 self.inner = std::ptr::null_mut();
3105                 ret
3106         }
3107 }
3108 /// Authentication of the announcement by the first public node
3109 #[no_mangle]
3110 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3111         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1;
3112         crate::c_types::Signature::from_rust(&inner_val)
3113 }
3114 /// Authentication of the announcement by the first public node
3115 #[no_mangle]
3116 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3117         unsafe { &mut *this_ptr.inner }.node_signature_1 = val.into_rust();
3118 }
3119 /// Authentication of the announcement by the second public node
3120 #[no_mangle]
3121 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3122         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2;
3123         crate::c_types::Signature::from_rust(&inner_val)
3124 }
3125 /// Authentication of the announcement by the second public node
3126 #[no_mangle]
3127 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3128         unsafe { &mut *this_ptr.inner }.node_signature_2 = val.into_rust();
3129 }
3130 /// Proof of funding UTXO ownership by the first public node
3131 #[no_mangle]
3132 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3133         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1;
3134         crate::c_types::Signature::from_rust(&inner_val)
3135 }
3136 /// Proof of funding UTXO ownership by the first public node
3137 #[no_mangle]
3138 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3139         unsafe { &mut *this_ptr.inner }.bitcoin_signature_1 = val.into_rust();
3140 }
3141 /// Proof of funding UTXO ownership by the second public node
3142 #[no_mangle]
3143 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3144         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2;
3145         crate::c_types::Signature::from_rust(&inner_val)
3146 }
3147 /// Proof of funding UTXO ownership by the second public node
3148 #[no_mangle]
3149 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3150         unsafe { &mut *this_ptr.inner }.bitcoin_signature_2 = val.into_rust();
3151 }
3152 /// The actual announcement
3153 #[no_mangle]
3154 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3155         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
3156         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
3157 }
3158 /// The actual announcement
3159 #[no_mangle]
3160 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3161         unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3162 }
3163 /// Constructs a new ChannelAnnouncement given each field
3164 #[must_use]
3165 #[no_mangle]
3166 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 {
3167         ChannelAnnouncement { inner: Box::into_raw(Box::new(nativeChannelAnnouncement {
3168                 node_signature_1: node_signature_1_arg.into_rust(),
3169                 node_signature_2: node_signature_2_arg.into_rust(),
3170                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3171                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3172                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3173         })), is_owned: true }
3174 }
3175 impl Clone for ChannelAnnouncement {
3176         fn clone(&self) -> Self {
3177                 Self {
3178                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3179                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3180                         is_owned: true,
3181                 }
3182         }
3183 }
3184 #[allow(unused)]
3185 /// Used only if an object of this type is returned as a trait impl by a method
3186 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3187         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3188 }
3189 #[no_mangle]
3190 /// Creates a copy of the ChannelAnnouncement
3191 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3192         orig.clone()
3193 }
3194
3195 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3196 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3197
3198 /// The unsigned part of a channel_update
3199 #[must_use]
3200 #[repr(C)]
3201 pub struct UnsignedChannelUpdate {
3202         /// A pointer to the opaque Rust object.
3203
3204         /// Nearly everywhere, inner must be non-null, however in places where
3205         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3206         pub inner: *mut nativeUnsignedChannelUpdate,
3207         /// Indicates that this is the only struct which contains the same pointer.
3208
3209         /// Rust functions which take ownership of an object provided via an argument require
3210         /// this to be true and invalidate the object pointed to by inner.
3211         pub is_owned: bool,
3212 }
3213
3214 impl Drop for UnsignedChannelUpdate {
3215         fn drop(&mut self) {
3216                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3217                         let _ = unsafe { Box::from_raw(self.inner) };
3218                 }
3219         }
3220 }
3221 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3222 #[no_mangle]
3223 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3224 #[allow(unused)]
3225 /// Used only if an object of this type is returned as a trait impl by a method
3226 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3227         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3228 }
3229 #[allow(unused)]
3230 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3231 impl UnsignedChannelUpdate {
3232         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3233                 assert!(self.is_owned);
3234                 let ret = self.inner;
3235                 self.inner = std::ptr::null_mut();
3236                 ret
3237         }
3238 }
3239 /// The genesis hash of the blockchain where the channel is to be opened
3240 #[no_mangle]
3241 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3242         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3243         inner_val.as_inner()
3244 }
3245 /// The genesis hash of the blockchain where the channel is to be opened
3246 #[no_mangle]
3247 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3248         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3249 }
3250 /// The short channel ID
3251 #[no_mangle]
3252 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3253         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
3254         *inner_val
3255 }
3256 /// The short channel ID
3257 #[no_mangle]
3258 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3259         unsafe { &mut *this_ptr.inner }.short_channel_id = val;
3260 }
3261 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3262 #[no_mangle]
3263 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3264         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
3265         *inner_val
3266 }
3267 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3268 #[no_mangle]
3269 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3270         unsafe { &mut *this_ptr.inner }.timestamp = val;
3271 }
3272 /// Channel flags
3273 #[no_mangle]
3274 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3275         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags;
3276         *inner_val
3277 }
3278 /// Channel flags
3279 #[no_mangle]
3280 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3281         unsafe { &mut *this_ptr.inner }.flags = val;
3282 }
3283 /// The number of blocks such that if:
3284 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3285 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3286 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3287 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3288 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3289 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3290 /// constructing the route.
3291 #[no_mangle]
3292 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3293         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
3294         *inner_val
3295 }
3296 /// The number of blocks such that if:
3297 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3298 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3299 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3300 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3301 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3302 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3303 /// constructing the route.
3304 #[no_mangle]
3305 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3306         unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
3307 }
3308 /// The minimum HTLC size incoming to sender, in milli-satoshi
3309 #[no_mangle]
3310 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3311         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
3312         *inner_val
3313 }
3314 /// The minimum HTLC size incoming to sender, in milli-satoshi
3315 #[no_mangle]
3316 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3317         unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
3318 }
3319 /// The base HTLC fee charged by sender, in milli-satoshi
3320 #[no_mangle]
3321 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3322         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat;
3323         *inner_val
3324 }
3325 /// The base HTLC fee charged by sender, in milli-satoshi
3326 #[no_mangle]
3327 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3328         unsafe { &mut *this_ptr.inner }.fee_base_msat = val;
3329 }
3330 /// The amount to fee multiplier, in micro-satoshi
3331 #[no_mangle]
3332 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3333         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
3334         *inner_val
3335 }
3336 /// The amount to fee multiplier, in micro-satoshi
3337 #[no_mangle]
3338 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3339         unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
3340 }
3341 impl Clone for UnsignedChannelUpdate {
3342         fn clone(&self) -> Self {
3343                 Self {
3344                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3345                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3346                         is_owned: true,
3347                 }
3348         }
3349 }
3350 #[allow(unused)]
3351 /// Used only if an object of this type is returned as a trait impl by a method
3352 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3353         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3354 }
3355 #[no_mangle]
3356 /// Creates a copy of the UnsignedChannelUpdate
3357 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3358         orig.clone()
3359 }
3360
3361 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3362 type nativeChannelUpdate = nativeChannelUpdateImport;
3363
3364 /// A channel_update message to be sent or received from a peer
3365 #[must_use]
3366 #[repr(C)]
3367 pub struct ChannelUpdate {
3368         /// A pointer to the opaque Rust object.
3369
3370         /// Nearly everywhere, inner must be non-null, however in places where
3371         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3372         pub inner: *mut nativeChannelUpdate,
3373         /// Indicates that this is the only struct which contains the same pointer.
3374
3375         /// Rust functions which take ownership of an object provided via an argument require
3376         /// this to be true and invalidate the object pointed to by inner.
3377         pub is_owned: bool,
3378 }
3379
3380 impl Drop for ChannelUpdate {
3381         fn drop(&mut self) {
3382                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
3383                         let _ = unsafe { Box::from_raw(self.inner) };
3384                 }
3385         }
3386 }
3387 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
3388 #[no_mangle]
3389 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
3390 #[allow(unused)]
3391 /// Used only if an object of this type is returned as a trait impl by a method
3392 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3393         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3394 }
3395 #[allow(unused)]
3396 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3397 impl ChannelUpdate {
3398         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3399                 assert!(self.is_owned);
3400                 let ret = self.inner;
3401                 self.inner = std::ptr::null_mut();
3402                 ret
3403         }
3404 }
3405 /// A signature of the channel update
3406 #[no_mangle]
3407 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3408         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
3409         crate::c_types::Signature::from_rust(&inner_val)
3410 }
3411 /// A signature of the channel update
3412 #[no_mangle]
3413 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3414         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
3415 }
3416 /// The actual channel update
3417 #[no_mangle]
3418 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
3419         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
3420         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
3421 }
3422 /// The actual channel update
3423 #[no_mangle]
3424 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
3425         unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3426 }
3427 /// Constructs a new ChannelUpdate given each field
3428 #[must_use]
3429 #[no_mangle]
3430 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3431         ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate {
3432                 signature: signature_arg.into_rust(),
3433                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3434         })), is_owned: true }
3435 }
3436 impl Clone for ChannelUpdate {
3437         fn clone(&self) -> Self {
3438                 Self {
3439                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3440                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3441                         is_owned: true,
3442                 }
3443         }
3444 }
3445 #[allow(unused)]
3446 /// Used only if an object of this type is returned as a trait impl by a method
3447 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3448         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3449 }
3450 #[no_mangle]
3451 /// Creates a copy of the ChannelUpdate
3452 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3453         orig.clone()
3454 }
3455
3456 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3457 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3458
3459 /// A query_channel_range message is used to query a peer for channel
3460 /// UTXOs in a range of blocks. The recipient of a query makes a best
3461 /// effort to reply to the query using one or more reply_channel_range
3462 /// messages.
3463 #[must_use]
3464 #[repr(C)]
3465 pub struct QueryChannelRange {
3466         /// A pointer to the opaque Rust object.
3467
3468         /// Nearly everywhere, inner must be non-null, however in places where
3469         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3470         pub inner: *mut nativeQueryChannelRange,
3471         /// Indicates that this is the only struct which contains the same pointer.
3472
3473         /// Rust functions which take ownership of an object provided via an argument require
3474         /// this to be true and invalidate the object pointed to by inner.
3475         pub is_owned: bool,
3476 }
3477
3478 impl Drop for QueryChannelRange {
3479         fn drop(&mut self) {
3480                 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
3481                         let _ = unsafe { Box::from_raw(self.inner) };
3482                 }
3483         }
3484 }
3485 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
3486 #[no_mangle]
3487 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
3488 #[allow(unused)]
3489 /// Used only if an object of this type is returned as a trait impl by a method
3490 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3491         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3492 }
3493 #[allow(unused)]
3494 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3495 impl QueryChannelRange {
3496         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3497                 assert!(self.is_owned);
3498                 let ret = self.inner;
3499                 self.inner = std::ptr::null_mut();
3500                 ret
3501         }
3502 }
3503 /// The genesis hash of the blockchain being queried
3504 #[no_mangle]
3505 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3506         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3507         inner_val.as_inner()
3508 }
3509 /// The genesis hash of the blockchain being queried
3510 #[no_mangle]
3511 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3512         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3513 }
3514 /// The height of the first block for the channel UTXOs being queried
3515 #[no_mangle]
3516 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3517         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3518         *inner_val
3519 }
3520 /// The height of the first block for the channel UTXOs being queried
3521 #[no_mangle]
3522 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3523         unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3524 }
3525 /// The number of blocks to include in the query results
3526 #[no_mangle]
3527 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3528         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3529         *inner_val
3530 }
3531 /// The number of blocks to include in the query results
3532 #[no_mangle]
3533 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3534         unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3535 }
3536 /// Constructs a new QueryChannelRange given each field
3537 #[must_use]
3538 #[no_mangle]
3539 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 {
3540         QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange {
3541                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3542                 first_blocknum: first_blocknum_arg,
3543                 number_of_blocks: number_of_blocks_arg,
3544         })), is_owned: true }
3545 }
3546 impl Clone for QueryChannelRange {
3547         fn clone(&self) -> Self {
3548                 Self {
3549                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
3550                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3551                         is_owned: true,
3552                 }
3553         }
3554 }
3555 #[allow(unused)]
3556 /// Used only if an object of this type is returned as a trait impl by a method
3557 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3558         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3559 }
3560 #[no_mangle]
3561 /// Creates a copy of the QueryChannelRange
3562 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3563         orig.clone()
3564 }
3565
3566 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3567 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3568
3569 /// A reply_channel_range message is a reply to a query_channel_range
3570 /// message. Multiple reply_channel_range messages can be sent in reply
3571 /// to a single query_channel_range message. The query recipient makes a
3572 /// best effort to respond based on their local network view which may
3573 /// not be a perfect view of the network. The short_channel_ids in the
3574 /// reply are encoded. We only support encoding_type=0 uncompressed
3575 /// serialization and do not support encoding_type=1 zlib serialization.
3576 #[must_use]
3577 #[repr(C)]
3578 pub struct ReplyChannelRange {
3579         /// A pointer to the opaque Rust object.
3580
3581         /// Nearly everywhere, inner must be non-null, however in places where
3582         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3583         pub inner: *mut nativeReplyChannelRange,
3584         /// Indicates that this is the only struct which contains the same pointer.
3585
3586         /// Rust functions which take ownership of an object provided via an argument require
3587         /// this to be true and invalidate the object pointed to by inner.
3588         pub is_owned: bool,
3589 }
3590
3591 impl Drop for ReplyChannelRange {
3592         fn drop(&mut self) {
3593                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
3594                         let _ = unsafe { Box::from_raw(self.inner) };
3595                 }
3596         }
3597 }
3598 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
3599 #[no_mangle]
3600 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
3601 #[allow(unused)]
3602 /// Used only if an object of this type is returned as a trait impl by a method
3603 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3604         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3605 }
3606 #[allow(unused)]
3607 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3608 impl ReplyChannelRange {
3609         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3610                 assert!(self.is_owned);
3611                 let ret = self.inner;
3612                 self.inner = std::ptr::null_mut();
3613                 ret
3614         }
3615 }
3616 /// The genesis hash of the blockchain being queried
3617 #[no_mangle]
3618 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3619         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3620         inner_val.as_inner()
3621 }
3622 /// The genesis hash of the blockchain being queried
3623 #[no_mangle]
3624 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3625         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3626 }
3627 /// The height of the first block in the range of the reply
3628 #[no_mangle]
3629 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3630         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3631         *inner_val
3632 }
3633 /// The height of the first block in the range of the reply
3634 #[no_mangle]
3635 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3636         unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3637 }
3638 /// The number of blocks included in the range of the reply
3639 #[no_mangle]
3640 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3641         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3642         *inner_val
3643 }
3644 /// The number of blocks included in the range of the reply
3645 #[no_mangle]
3646 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3647         unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3648 }
3649 /// True when this is the final reply for a query
3650 #[no_mangle]
3651 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
3652         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.sync_complete;
3653         *inner_val
3654 }
3655 /// True when this is the final reply for a query
3656 #[no_mangle]
3657 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
3658         unsafe { &mut *this_ptr.inner }.sync_complete = val;
3659 }
3660 /// The short_channel_ids in the channel range
3661 #[no_mangle]
3662 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
3663         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3664         unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3665 }
3666 /// Constructs a new ReplyChannelRange given each field
3667 #[must_use]
3668 #[no_mangle]
3669 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 {
3670         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 }); };
3671         ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange {
3672                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3673                 first_blocknum: first_blocknum_arg,
3674                 number_of_blocks: number_of_blocks_arg,
3675                 sync_complete: sync_complete_arg,
3676                 short_channel_ids: local_short_channel_ids_arg,
3677         })), is_owned: true }
3678 }
3679 impl Clone for ReplyChannelRange {
3680         fn clone(&self) -> Self {
3681                 Self {
3682                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
3683                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3684                         is_owned: true,
3685                 }
3686         }
3687 }
3688 #[allow(unused)]
3689 /// Used only if an object of this type is returned as a trait impl by a method
3690 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3691         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
3692 }
3693 #[no_mangle]
3694 /// Creates a copy of the ReplyChannelRange
3695 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
3696         orig.clone()
3697 }
3698
3699 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
3700 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
3701
3702 /// A query_short_channel_ids message is used to query a peer for
3703 /// routing gossip messages related to one or more short_channel_ids.
3704 /// The query recipient will reply with the latest, if available,
3705 /// channel_announcement, channel_update and node_announcement messages
3706 /// it maintains for the requested short_channel_ids followed by a
3707 /// reply_short_channel_ids_end message. The short_channel_ids sent in
3708 /// this query are encoded. We only support encoding_type=0 uncompressed
3709 /// serialization and do not support encoding_type=1 zlib serialization.
3710 #[must_use]
3711 #[repr(C)]
3712 pub struct QueryShortChannelIds {
3713         /// A pointer to the opaque Rust object.
3714
3715         /// Nearly everywhere, inner must be non-null, however in places where
3716         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3717         pub inner: *mut nativeQueryShortChannelIds,
3718         /// Indicates that this is the only struct which contains the same pointer.
3719
3720         /// Rust functions which take ownership of an object provided via an argument require
3721         /// this to be true and invalidate the object pointed to by inner.
3722         pub is_owned: bool,
3723 }
3724
3725 impl Drop for QueryShortChannelIds {
3726         fn drop(&mut self) {
3727                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
3728                         let _ = unsafe { Box::from_raw(self.inner) };
3729                 }
3730         }
3731 }
3732 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
3733 #[no_mangle]
3734 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
3735 #[allow(unused)]
3736 /// Used only if an object of this type is returned as a trait impl by a method
3737 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
3738         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
3739 }
3740 #[allow(unused)]
3741 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3742 impl QueryShortChannelIds {
3743         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
3744                 assert!(self.is_owned);
3745                 let ret = self.inner;
3746                 self.inner = std::ptr::null_mut();
3747                 ret
3748         }
3749 }
3750 /// The genesis hash of the blockchain being queried
3751 #[no_mangle]
3752 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
3753         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3754         inner_val.as_inner()
3755 }
3756 /// The genesis hash of the blockchain being queried
3757 #[no_mangle]
3758 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
3759         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3760 }
3761 /// The short_channel_ids that are being queried
3762 #[no_mangle]
3763 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
3764         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3765         unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3766 }
3767 /// Constructs a new QueryShortChannelIds given each field
3768 #[must_use]
3769 #[no_mangle]
3770 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 {
3771         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 }); };
3772         QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds {
3773                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3774                 short_channel_ids: local_short_channel_ids_arg,
3775         })), is_owned: true }
3776 }
3777 impl Clone for QueryShortChannelIds {
3778         fn clone(&self) -> Self {
3779                 Self {
3780                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else {
3781                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3782                         is_owned: true,
3783                 }
3784         }
3785 }
3786 #[allow(unused)]
3787 /// Used only if an object of this type is returned as a trait impl by a method
3788 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
3789         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
3790 }
3791 #[no_mangle]
3792 /// Creates a copy of the QueryShortChannelIds
3793 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
3794         orig.clone()
3795 }
3796
3797 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
3798 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
3799
3800 /// A reply_short_channel_ids_end message is sent as a reply to a
3801 /// query_short_channel_ids message. The query recipient makes a best
3802 /// effort to respond based on their local network view which may not be
3803 /// a perfect view of the network.
3804 #[must_use]
3805 #[repr(C)]
3806 pub struct ReplyShortChannelIdsEnd {
3807         /// A pointer to the opaque Rust object.
3808
3809         /// Nearly everywhere, inner must be non-null, however in places where
3810         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3811         pub inner: *mut nativeReplyShortChannelIdsEnd,
3812         /// Indicates that this is the only struct which contains the same pointer.
3813
3814         /// Rust functions which take ownership of an object provided via an argument require
3815         /// this to be true and invalidate the object pointed to by inner.
3816         pub is_owned: bool,
3817 }
3818
3819 impl Drop for ReplyShortChannelIdsEnd {
3820         fn drop(&mut self) {
3821                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
3822                         let _ = unsafe { Box::from_raw(self.inner) };
3823                 }
3824         }
3825 }
3826 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
3827 #[no_mangle]
3828 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
3829 #[allow(unused)]
3830 /// Used only if an object of this type is returned as a trait impl by a method
3831 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
3832         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
3833 }
3834 #[allow(unused)]
3835 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3836 impl ReplyShortChannelIdsEnd {
3837         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
3838                 assert!(self.is_owned);
3839                 let ret = self.inner;
3840                 self.inner = std::ptr::null_mut();
3841                 ret
3842         }
3843 }
3844 /// The genesis hash of the blockchain that was queried
3845 #[no_mangle]
3846 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
3847         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3848         inner_val.as_inner()
3849 }
3850 /// The genesis hash of the blockchain that was queried
3851 #[no_mangle]
3852 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
3853         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3854 }
3855 /// Indicates if the query recipient maintains up-to-date channel
3856 /// information for the chain_hash
3857 #[no_mangle]
3858 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
3859         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3860         *inner_val
3861 }
3862 /// Indicates if the query recipient maintains up-to-date channel
3863 /// information for the chain_hash
3864 #[no_mangle]
3865 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
3866         unsafe { &mut *this_ptr.inner }.full_information = val;
3867 }
3868 /// Constructs a new ReplyShortChannelIdsEnd given each field
3869 #[must_use]
3870 #[no_mangle]
3871 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
3872         ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd {
3873                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3874                 full_information: full_information_arg,
3875         })), is_owned: true }
3876 }
3877 impl Clone for ReplyShortChannelIdsEnd {
3878         fn clone(&self) -> Self {
3879                 Self {
3880                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else {
3881                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3882                         is_owned: true,
3883                 }
3884         }
3885 }
3886 #[allow(unused)]
3887 /// Used only if an object of this type is returned as a trait impl by a method
3888 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
3889         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
3890 }
3891 #[no_mangle]
3892 /// Creates a copy of the ReplyShortChannelIdsEnd
3893 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
3894         orig.clone()
3895 }
3896
3897 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
3898 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
3899
3900 /// A gossip_timestamp_filter message is used by a node to request
3901 /// gossip relay for messages in the requested time range when the
3902 /// gossip_queries feature has been negotiated.
3903 #[must_use]
3904 #[repr(C)]
3905 pub struct GossipTimestampFilter {
3906         /// A pointer to the opaque Rust object.
3907
3908         /// Nearly everywhere, inner must be non-null, however in places where
3909         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3910         pub inner: *mut nativeGossipTimestampFilter,
3911         /// Indicates that this is the only struct which contains the same pointer.
3912
3913         /// Rust functions which take ownership of an object provided via an argument require
3914         /// this to be true and invalidate the object pointed to by inner.
3915         pub is_owned: bool,
3916 }
3917
3918 impl Drop for GossipTimestampFilter {
3919         fn drop(&mut self) {
3920                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
3921                         let _ = unsafe { Box::from_raw(self.inner) };
3922                 }
3923         }
3924 }
3925 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
3926 #[no_mangle]
3927 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
3928 #[allow(unused)]
3929 /// Used only if an object of this type is returned as a trait impl by a method
3930 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
3931         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
3932 }
3933 #[allow(unused)]
3934 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3935 impl GossipTimestampFilter {
3936         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
3937                 assert!(self.is_owned);
3938                 let ret = self.inner;
3939                 self.inner = std::ptr::null_mut();
3940                 ret
3941         }
3942 }
3943 /// The genesis hash of the blockchain for channel and node information
3944 #[no_mangle]
3945 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
3946         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3947         inner_val.as_inner()
3948 }
3949 /// The genesis hash of the blockchain for channel and node information
3950 #[no_mangle]
3951 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
3952         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3953 }
3954 /// The starting unix timestamp
3955 #[no_mangle]
3956 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
3957         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp;
3958         *inner_val
3959 }
3960 /// The starting unix timestamp
3961 #[no_mangle]
3962 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3963         unsafe { &mut *this_ptr.inner }.first_timestamp = val;
3964 }
3965 /// The range of information in seconds
3966 #[no_mangle]
3967 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
3968         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range;
3969         *inner_val
3970 }
3971 /// The range of information in seconds
3972 #[no_mangle]
3973 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3974         unsafe { &mut *this_ptr.inner }.timestamp_range = val;
3975 }
3976 /// Constructs a new GossipTimestampFilter given each field
3977 #[must_use]
3978 #[no_mangle]
3979 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 {
3980         GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter {
3981                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3982                 first_timestamp: first_timestamp_arg,
3983                 timestamp_range: timestamp_range_arg,
3984         })), is_owned: true }
3985 }
3986 impl Clone for GossipTimestampFilter {
3987         fn clone(&self) -> Self {
3988                 Self {
3989                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else {
3990                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3991                         is_owned: true,
3992                 }
3993         }
3994 }
3995 #[allow(unused)]
3996 /// Used only if an object of this type is returned as a trait impl by a method
3997 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
3998         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
3999 }
4000 #[no_mangle]
4001 /// Creates a copy of the GossipTimestampFilter
4002 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4003         orig.clone()
4004 }
4005 /// Used to put an error message in a LightningError
4006 #[must_use]
4007 #[derive(Clone)]
4008 #[repr(C)]
4009 pub enum ErrorAction {
4010         /// The peer took some action which made us think they were useless. Disconnect them.
4011         DisconnectPeer {
4012                 /// An error message which we should make an effort to send before we disconnect.
4013                 msg: crate::lightning::ln::msgs::ErrorMessage,
4014         },
4015         /// The peer did something harmless that we weren't able to process, just log and ignore
4016         IgnoreError,
4017         /// The peer did something incorrect. Tell them.
4018         SendErrorMessage {
4019                 /// The message to send.
4020                 msg: crate::lightning::ln::msgs::ErrorMessage,
4021         },
4022 }
4023 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
4024 impl ErrorAction {
4025         #[allow(unused)]
4026         pub(crate) fn to_native(&self) -> nativeErrorAction {
4027                 match self {
4028                         ErrorAction::DisconnectPeer {ref msg, } => {
4029                                 let mut msg_nonref = (*msg).clone();
4030                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4031                                 nativeErrorAction::DisconnectPeer {
4032                                         msg: local_msg_nonref,
4033                                 }
4034                         },
4035                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4036                         ErrorAction::SendErrorMessage {ref msg, } => {
4037                                 let mut msg_nonref = (*msg).clone();
4038                                 nativeErrorAction::SendErrorMessage {
4039                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4040                                 }
4041                         },
4042                 }
4043         }
4044         #[allow(unused)]
4045         pub(crate) fn into_native(self) -> nativeErrorAction {
4046                 match self {
4047                         ErrorAction::DisconnectPeer {mut msg, } => {
4048                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4049                                 nativeErrorAction::DisconnectPeer {
4050                                         msg: local_msg,
4051                                 }
4052                         },
4053                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4054                         ErrorAction::SendErrorMessage {mut msg, } => {
4055                                 nativeErrorAction::SendErrorMessage {
4056                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
4057                                 }
4058                         },
4059                 }
4060         }
4061         #[allow(unused)]
4062         pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4063                 match native {
4064                         nativeErrorAction::DisconnectPeer {ref msg, } => {
4065                                 let mut msg_nonref = (*msg).clone();
4066                                 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 };
4067                                 ErrorAction::DisconnectPeer {
4068                                         msg: local_msg_nonref,
4069                                 }
4070                         },
4071                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4072                         nativeErrorAction::SendErrorMessage {ref msg, } => {
4073                                 let mut msg_nonref = (*msg).clone();
4074                                 ErrorAction::SendErrorMessage {
4075                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
4076                                 }
4077                         },
4078                 }
4079         }
4080         #[allow(unused)]
4081         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4082                 match native {
4083                         nativeErrorAction::DisconnectPeer {mut msg, } => {
4084                                 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 };
4085                                 ErrorAction::DisconnectPeer {
4086                                         msg: local_msg,
4087                                 }
4088                         },
4089                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4090                         nativeErrorAction::SendErrorMessage {mut msg, } => {
4091                                 ErrorAction::SendErrorMessage {
4092                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
4093                                 }
4094                         },
4095                 }
4096         }
4097 }
4098 /// Frees any resources used by the ErrorAction
4099 #[no_mangle]
4100 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4101 /// Creates a copy of the ErrorAction
4102 #[no_mangle]
4103 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4104         orig.clone()
4105 }
4106
4107 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4108 type nativeLightningError = nativeLightningErrorImport;
4109
4110 /// An Err type for failure to process messages.
4111 #[must_use]
4112 #[repr(C)]
4113 pub struct LightningError {
4114         /// A pointer to the opaque Rust object.
4115
4116         /// Nearly everywhere, inner must be non-null, however in places where
4117         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4118         pub inner: *mut nativeLightningError,
4119         /// Indicates that this is the only struct which contains the same pointer.
4120
4121         /// Rust functions which take ownership of an object provided via an argument require
4122         /// this to be true and invalidate the object pointed to by inner.
4123         pub is_owned: bool,
4124 }
4125
4126 impl Drop for LightningError {
4127         fn drop(&mut self) {
4128                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4129                         let _ = unsafe { Box::from_raw(self.inner) };
4130                 }
4131         }
4132 }
4133 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
4134 #[no_mangle]
4135 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
4136 #[allow(unused)]
4137 /// Used only if an object of this type is returned as a trait impl by a method
4138 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
4139         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
4140 }
4141 #[allow(unused)]
4142 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4143 impl LightningError {
4144         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
4145                 assert!(self.is_owned);
4146                 let ret = self.inner;
4147                 self.inner = std::ptr::null_mut();
4148                 ret
4149         }
4150 }
4151 /// A human-readable message describing the error
4152 #[no_mangle]
4153 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
4154         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
4155         inner_val.as_str().into()
4156 }
4157 /// A human-readable message describing the error
4158 #[no_mangle]
4159 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
4160         unsafe { &mut *this_ptr.inner }.err = val.into_string();
4161 }
4162 /// The action which should be taken against the offending peer.
4163 #[no_mangle]
4164 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
4165         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
4166         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
4167 }
4168 /// The action which should be taken against the offending peer.
4169 #[no_mangle]
4170 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
4171         unsafe { &mut *this_ptr.inner }.action = val.into_native();
4172 }
4173 /// Constructs a new LightningError given each field
4174 #[must_use]
4175 #[no_mangle]
4176 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
4177         LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
4178                 err: err_arg.into_string(),
4179                 action: action_arg.into_native(),
4180         })), is_owned: true }
4181 }
4182 impl Clone for LightningError {
4183         fn clone(&self) -> Self {
4184                 Self {
4185                         inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else {
4186                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
4187                         is_owned: true,
4188                 }
4189         }
4190 }
4191 #[allow(unused)]
4192 /// Used only if an object of this type is returned as a trait impl by a method
4193 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
4194         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
4195 }
4196 #[no_mangle]
4197 /// Creates a copy of the LightningError
4198 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
4199         orig.clone()
4200 }
4201
4202 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
4203 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
4204
4205 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
4206 /// transaction updates if they were pending.
4207 #[must_use]
4208 #[repr(C)]
4209 pub struct CommitmentUpdate {
4210         /// A pointer to the opaque Rust object.
4211
4212         /// Nearly everywhere, inner must be non-null, however in places where
4213         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4214         pub inner: *mut nativeCommitmentUpdate,
4215         /// Indicates that this is the only struct which contains the same pointer.
4216
4217         /// Rust functions which take ownership of an object provided via an argument require
4218         /// this to be true and invalidate the object pointed to by inner.
4219         pub is_owned: bool,
4220 }
4221
4222 impl Drop for CommitmentUpdate {
4223         fn drop(&mut self) {
4224                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
4225                         let _ = unsafe { Box::from_raw(self.inner) };
4226                 }
4227         }
4228 }
4229 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
4230 #[no_mangle]
4231 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
4232 #[allow(unused)]
4233 /// Used only if an object of this type is returned as a trait impl by a method
4234 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
4235         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
4236 }
4237 #[allow(unused)]
4238 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4239 impl CommitmentUpdate {
4240         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
4241                 assert!(self.is_owned);
4242                 let ret = self.inner;
4243                 self.inner = std::ptr::null_mut();
4244                 ret
4245         }
4246 }
4247 /// update_add_htlc messages which should be sent
4248 #[no_mangle]
4249 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
4250         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4251         unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
4252 }
4253 /// update_fulfill_htlc messages which should be sent
4254 #[no_mangle]
4255 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
4256         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4257         unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
4258 }
4259 /// update_fail_htlc messages which should be sent
4260 #[no_mangle]
4261 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
4262         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4263         unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
4264 }
4265 /// update_fail_malformed_htlc messages which should be sent
4266 #[no_mangle]
4267 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
4268         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4269         unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val;
4270 }
4271 /// An update_fee message which should be sent
4272 #[no_mangle]
4273 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
4274         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
4275         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 };
4276         local_inner_val
4277 }
4278 /// An update_fee message which should be sent
4279 #[no_mangle]
4280 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
4281         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4282         unsafe { &mut *this_ptr.inner }.update_fee = local_val;
4283 }
4284 /// Finally, the commitment_signed message which should be sent
4285 #[no_mangle]
4286 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
4287         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
4288         crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
4289 }
4290 /// Finally, the commitment_signed message which should be sent
4291 #[no_mangle]
4292 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
4293         unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
4294 }
4295 /// Constructs a new CommitmentUpdate given each field
4296 #[must_use]
4297 #[no_mangle]
4298 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 {
4299         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()) } }); };
4300         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()) } }); };
4301         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()) } }); };
4302         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()) } }); };
4303         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()) } }) };
4304         CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
4305                 update_add_htlcs: local_update_add_htlcs_arg,
4306                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
4307                 update_fail_htlcs: local_update_fail_htlcs_arg,
4308                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
4309                 update_fee: local_update_fee_arg,
4310                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
4311         })), is_owned: true }
4312 }
4313 impl Clone for CommitmentUpdate {
4314         fn clone(&self) -> Self {
4315                 Self {
4316                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
4317                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
4318                         is_owned: true,
4319                 }
4320         }
4321 }
4322 #[allow(unused)]
4323 /// Used only if an object of this type is returned as a trait impl by a method
4324 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4325         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
4326 }
4327 #[no_mangle]
4328 /// Creates a copy of the CommitmentUpdate
4329 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
4330         orig.clone()
4331 }
4332 /// The information we received from a peer along the route of a payment we originated. This is
4333 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
4334 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
4335 #[must_use]
4336 #[derive(Clone)]
4337 #[repr(C)]
4338 pub enum HTLCFailChannelUpdate {
4339         /// We received an error which included a full ChannelUpdate message.
4340         ChannelUpdateMessage {
4341                 /// The unwrapped message we received
4342                 msg: crate::lightning::ln::msgs::ChannelUpdate,
4343         },
4344         /// We received an error which indicated only that a channel has been closed
4345         ChannelClosed {
4346                 /// The short_channel_id which has now closed.
4347                 short_channel_id: u64,
4348                 /// when this true, this channel should be permanently removed from the
4349                 /// consideration. Otherwise, this channel can be restored as new channel_update is received
4350                 is_permanent: bool,
4351         },
4352         /// We received an error which indicated only that a node has failed
4353         NodeFailure {
4354                 /// The node_id that has failed.
4355                 node_id: crate::c_types::PublicKey,
4356                 /// when this true, node should be permanently removed from the
4357                 /// consideration. Otherwise, the channels connected to this node can be
4358                 /// restored as new channel_update is received
4359                 is_permanent: bool,
4360         },
4361 }
4362 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
4363 impl HTLCFailChannelUpdate {
4364         #[allow(unused)]
4365         pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
4366                 match self {
4367                         HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
4368                                 let mut msg_nonref = (*msg).clone();
4369                                 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
4370                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4371                                 }
4372                         },
4373                         HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
4374                                 let mut short_channel_id_nonref = (*short_channel_id).clone();
4375                                 let mut is_permanent_nonref = (*is_permanent).clone();
4376                                 nativeHTLCFailChannelUpdate::ChannelClosed {
4377                                         short_channel_id: short_channel_id_nonref,
4378                                         is_permanent: is_permanent_nonref,
4379                                 }
4380                         },
4381                         HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4382                                 let mut node_id_nonref = (*node_id).clone();
4383                                 let mut is_permanent_nonref = (*is_permanent).clone();
4384                                 nativeHTLCFailChannelUpdate::NodeFailure {
4385                                         node_id: node_id_nonref.into_rust(),
4386                                         is_permanent: is_permanent_nonref,
4387                                 }
4388                         },
4389                 }
4390         }
4391         #[allow(unused)]
4392         pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
4393                 match self {
4394                         HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4395                                 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
4396                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
4397                                 }
4398                         },
4399                         HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4400                                 nativeHTLCFailChannelUpdate::ChannelClosed {
4401                                         short_channel_id: short_channel_id,
4402                                         is_permanent: is_permanent,
4403                                 }
4404                         },
4405                         HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4406                                 nativeHTLCFailChannelUpdate::NodeFailure {
4407                                         node_id: node_id.into_rust(),
4408                                         is_permanent: is_permanent,
4409                                 }
4410                         },
4411                 }
4412         }
4413         #[allow(unused)]
4414         pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
4415                 match native {
4416                         nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
4417                                 let mut msg_nonref = (*msg).clone();
4418                                 HTLCFailChannelUpdate::ChannelUpdateMessage {
4419                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
4420                                 }
4421                         },
4422                         nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
4423                                 let mut short_channel_id_nonref = (*short_channel_id).clone();
4424                                 let mut is_permanent_nonref = (*is_permanent).clone();
4425                                 HTLCFailChannelUpdate::ChannelClosed {
4426                                         short_channel_id: short_channel_id_nonref,
4427                                         is_permanent: is_permanent_nonref,
4428                                 }
4429                         },
4430                         nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4431                                 let mut node_id_nonref = (*node_id).clone();
4432                                 let mut is_permanent_nonref = (*is_permanent).clone();
4433                                 HTLCFailChannelUpdate::NodeFailure {
4434                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
4435                                         is_permanent: is_permanent_nonref,
4436                                 }
4437                         },
4438                 }
4439         }
4440         #[allow(unused)]
4441         pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
4442                 match native {
4443                         nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4444                                 HTLCFailChannelUpdate::ChannelUpdateMessage {
4445                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
4446                                 }
4447                         },
4448                         nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4449                                 HTLCFailChannelUpdate::ChannelClosed {
4450                                         short_channel_id: short_channel_id,
4451                                         is_permanent: is_permanent,
4452                                 }
4453                         },
4454                         nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4455                                 HTLCFailChannelUpdate::NodeFailure {
4456                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
4457                                         is_permanent: is_permanent,
4458                                 }
4459                         },
4460                 }
4461         }
4462 }
4463 /// Frees any resources used by the HTLCFailChannelUpdate
4464 #[no_mangle]
4465 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
4466 /// Creates a copy of the HTLCFailChannelUpdate
4467 #[no_mangle]
4468 pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate {
4469         orig.clone()
4470 }
4471 /// A trait to describe an object which can receive channel messages.
4472 ///
4473 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4474 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4475 #[repr(C)]
4476 pub struct ChannelMessageHandler {
4477         /// An opaque pointer which is passed to your function implementations as an argument.
4478         /// This has no meaning in the LDK, and can be NULL or any other value.
4479         pub this_arg: *mut c_void,
4480         /// Handle an incoming open_channel message from the given peer.
4481         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),
4482         /// Handle an incoming accept_channel message from the given peer.
4483         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),
4484         /// Handle an incoming funding_created message from the given peer.
4485         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),
4486         /// Handle an incoming funding_signed message from the given peer.
4487         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),
4488         /// Handle an incoming funding_locked message from the given peer.
4489         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),
4490         /// Handle an incoming shutdown message from the given peer.
4491         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),
4492         /// Handle an incoming closing_signed message from the given peer.
4493         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),
4494         /// Handle an incoming update_add_htlc message from the given peer.
4495         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),
4496         /// Handle an incoming update_fulfill_htlc message from the given peer.
4497         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),
4498         /// Handle an incoming update_fail_htlc message from the given peer.
4499         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),
4500         /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4501         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),
4502         /// Handle an incoming commitment_signed message from the given peer.
4503         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),
4504         /// Handle an incoming revoke_and_ack message from the given peer.
4505         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),
4506         /// Handle an incoming update_fee message from the given peer.
4507         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),
4508         /// Handle an incoming announcement_signatures message from the given peer.
4509         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),
4510         /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4511         /// is believed to be possible in the future (eg they're sending us messages we don't
4512         /// understand or indicate they require unknown feature bits), no_connection_possible is set
4513         /// and any outstanding channels should be failed.
4514         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4515         /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4516         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
4517         /// Handle an incoming channel_reestablish message from the given peer.
4518         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),
4519         /// Handle an incoming channel update from the given peer.
4520         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),
4521         /// Handle an incoming error message from the given peer.
4522         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
4523         /// Implementation of MessageSendEventsProvider for this object.
4524         pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
4525         /// Frees any resources associated with this object given its this_arg pointer.
4526         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4527         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4528 }
4529 unsafe impl Send for ChannelMessageHandler {}
4530 unsafe impl Sync for ChannelMessageHandler {}
4531 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4532         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4533                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.this_arg);
4534                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4535                 local_ret
4536         }
4537 }
4538
4539 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4540 impl rustChannelMessageHandler for ChannelMessageHandler {
4541         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) {
4542                 (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 })
4543         }
4544         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) {
4545                 (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 })
4546         }
4547         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
4548                 (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 })
4549         }
4550         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
4551                 (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 })
4552         }
4553         fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) {
4554                 (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 })
4555         }
4556         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) {
4557                 (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 })
4558         }
4559         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
4560                 (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 })
4561         }
4562         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
4563                 (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 })
4564         }
4565         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4566                 (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 })
4567         }
4568         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
4569                 (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 })
4570         }
4571         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4572                 (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 })
4573         }
4574         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
4575                 (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 })
4576         }
4577         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
4578                 (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 })
4579         }
4580         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
4581                 (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 })
4582         }
4583         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
4584                 (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 })
4585         }
4586         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) {
4587                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4588         }
4589         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) {
4590                 (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 })
4591         }
4592         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
4593                 (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 })
4594         }
4595         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
4596                 (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 })
4597         }
4598         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
4599                 (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 })
4600         }
4601 }
4602
4603 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4604 // directly as a Deref trait in higher-level structs:
4605 impl std::ops::Deref for ChannelMessageHandler {
4606         type Target = Self;
4607         fn deref(&self) -> &Self {
4608                 self
4609         }
4610 }
4611 /// Calls the free function if one is set
4612 #[no_mangle]
4613 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4614 impl Drop for ChannelMessageHandler {
4615         fn drop(&mut self) {
4616                 if let Some(f) = self.free {
4617                         f(self.this_arg);
4618                 }
4619         }
4620 }
4621 /// A trait to describe an object which can receive routing messages.
4622 ///
4623 /// # Implementor DoS Warnings
4624 ///
4625 /// For `gossip_queries` messages there are potential DoS vectors when handling
4626 /// inbound queries. Implementors using an on-disk network graph should be aware of
4627 /// repeated disk I/O for queries accessing different parts of the network graph.
4628 #[repr(C)]
4629 pub struct RoutingMessageHandler {
4630         /// An opaque pointer which is passed to your function implementations as an argument.
4631         /// This has no meaning in the LDK, and can be NULL or any other value.
4632         pub this_arg: *mut c_void,
4633         /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4634         /// false or returning an Err otherwise.
4635         #[must_use]
4636         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4637         /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4638         /// or returning an Err otherwise.
4639         #[must_use]
4640         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4641         /// Handle an incoming channel_update message, returning true if it should be forwarded on,
4642         /// false or returning an Err otherwise.
4643         #[must_use]
4644         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4645         /// Handle some updates to the route graph that we learned due to an outbound failed payment.
4646         pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate),
4647         /// Gets a subset of the channel announcements and updates required to dump our routing table
4648         /// to a remote node, starting at the short_channel_id indicated by starting_point and
4649         /// including the batch_amount entries immediately higher in numerical value than starting_point.
4650         #[must_use]
4651         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,
4652         /// Gets a subset of the node announcements required to dump our routing table to a remote node,
4653         /// starting at the node *after* the provided publickey and including batch_amount entries
4654         /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
4655         /// If None is provided for starting_point, we start at the first node.
4656         #[must_use]
4657         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,
4658         /// Called when a connection is established with a peer. This can be used to
4659         /// perform routing table synchronization using a strategy defined by the
4660         /// implementor.
4661         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),
4662         /// Handles the reply of a query we initiated to learn about channels
4663         /// for a given range of blocks. We can expect to receive one or more
4664         /// replies to a single query.
4665         #[must_use]
4666         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,
4667         /// Handles the reply of a query we initiated asking for routing gossip
4668         /// messages for a list of channels. We should receive this message when
4669         /// a node has completed its best effort to send us the pertaining routing
4670         /// gossip messages.
4671         #[must_use]
4672         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,
4673         /// Handles when a peer asks us to send a list of short_channel_ids
4674         /// for the requested range of blocks.
4675         #[must_use]
4676         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,
4677         /// Handles when a peer asks us to send routing gossip messages for a
4678         /// list of short_channel_ids.
4679         #[must_use]
4680         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,
4681         /// Implementation of MessageSendEventsProvider for this object.
4682         pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
4683         /// Frees any resources associated with this object given its this_arg pointer.
4684         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4685         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4686 }
4687 unsafe impl Send for RoutingMessageHandler {}
4688 unsafe impl Sync for RoutingMessageHandler {}
4689 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
4690         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4691                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.this_arg);
4692                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4693                 local_ret
4694         }
4695 }
4696
4697 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
4698 impl rustRoutingMessageHandler for RoutingMessageHandler {
4699         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4700                 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 });
4701                 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()) } })};
4702                 local_ret
4703         }
4704         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4705                 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 });
4706                 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()) } })};
4707                 local_ret
4708         }
4709         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
4710                 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 });
4711                 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()) } })};
4712                 local_ret
4713         }
4714         fn handle_htlc_fail_channel_update(&self, mut update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
4715                 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::lightning::ln::msgs::HTLCFailChannelUpdate::from_native(update))
4716         }
4717         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>)> {
4718                 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
4719                 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 }); };
4720                 local_ret
4721         }
4722         fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
4723                 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())) } };
4724                 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
4725                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4726                 local_ret
4727         }
4728         fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
4729                 (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 })
4730         }
4731         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> {
4732                 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 });
4733                 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()) } })};
4734                 local_ret
4735         }
4736         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> {
4737                 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 });
4738                 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()) } })};
4739                 local_ret
4740         }
4741         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> {
4742                 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 });
4743                 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()) } })};
4744                 local_ret
4745         }
4746         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> {
4747                 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 });
4748                 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()) } })};
4749                 local_ret
4750         }
4751 }
4752
4753 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4754 // directly as a Deref trait in higher-level structs:
4755 impl std::ops::Deref for RoutingMessageHandler {
4756         type Target = Self;
4757         fn deref(&self) -> &Self {
4758                 self
4759         }
4760 }
4761 /// Calls the free function if one is set
4762 #[no_mangle]
4763 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
4764 impl Drop for RoutingMessageHandler {
4765         fn drop(&mut self) {
4766                 if let Some(f) = self.free {
4767                         f(self.this_arg);
4768                 }
4769         }
4770 }
4771 mod fuzzy_internal_msgs {
4772
4773 use std::str::FromStr;
4774 use std::ffi::c_void;
4775 use bitcoin::hashes::Hash;
4776 use crate::c_types::*;
4777
4778 }
4779 #[no_mangle]
4780 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
4781 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
4782         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4783 }
4784 #[no_mangle]
4785 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4786         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
4787 }
4788 #[no_mangle]
4789 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
4790 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
4791         let res = crate::c_types::deserialize_obj(ser);
4792         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() };
4793         local_res
4794 }
4795 #[no_mangle]
4796 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
4797 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
4798         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4799 }
4800 #[no_mangle]
4801 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4802         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
4803 }
4804 #[no_mangle]
4805 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
4806 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
4807         let res = crate::c_types::deserialize_obj(ser);
4808         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() };
4809         local_res
4810 }
4811 #[no_mangle]
4812 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
4813 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
4814         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4815 }
4816 #[no_mangle]
4817 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4818         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
4819 }
4820 #[no_mangle]
4821 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
4822 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
4823         let res = crate::c_types::deserialize_obj(ser);
4824         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() };
4825         local_res
4826 }
4827 #[no_mangle]
4828 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
4829 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
4830         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4831 }
4832 #[no_mangle]
4833 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4834         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
4835 }
4836 #[no_mangle]
4837 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
4838 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
4839         let res = crate::c_types::deserialize_obj(ser);
4840         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() };
4841         local_res
4842 }
4843 #[no_mangle]
4844 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
4845 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
4846         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4847 }
4848 #[no_mangle]
4849 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4850         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
4851 }
4852 #[no_mangle]
4853 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
4854 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
4855         let res = crate::c_types::deserialize_obj(ser);
4856         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() };
4857         local_res
4858 }
4859 #[no_mangle]
4860 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
4861 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
4862         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4863 }
4864 #[no_mangle]
4865 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4866         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
4867 }
4868 #[no_mangle]
4869 /// Read a FundingCreated from a byte array, created by FundingCreated_write
4870 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
4871         let res = crate::c_types::deserialize_obj(ser);
4872         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() };
4873         local_res
4874 }
4875 #[no_mangle]
4876 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
4877 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
4878         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4879 }
4880 #[no_mangle]
4881 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4882         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
4883 }
4884 #[no_mangle]
4885 /// Read a FundingSigned from a byte array, created by FundingSigned_write
4886 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
4887         let res = crate::c_types::deserialize_obj(ser);
4888         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() };
4889         local_res
4890 }
4891 #[no_mangle]
4892 /// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read
4893 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
4894         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4895 }
4896 #[no_mangle]
4897 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4898         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
4899 }
4900 #[no_mangle]
4901 /// Read a FundingLocked from a byte array, created by FundingLocked_write
4902 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
4903         let res = crate::c_types::deserialize_obj(ser);
4904         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() };
4905         local_res
4906 }
4907 #[no_mangle]
4908 /// Serialize the Init object into a byte array which can be read by Init_read
4909 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
4910         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4911 }
4912 #[no_mangle]
4913 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4914         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
4915 }
4916 #[no_mangle]
4917 /// Read a Init from a byte array, created by Init_write
4918 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
4919         let res = crate::c_types::deserialize_obj(ser);
4920         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() };
4921         local_res
4922 }
4923 #[no_mangle]
4924 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
4925 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
4926         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4927 }
4928 #[no_mangle]
4929 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4930         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
4931 }
4932 #[no_mangle]
4933 /// Read a OpenChannel from a byte array, created by OpenChannel_write
4934 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
4935         let res = crate::c_types::deserialize_obj(ser);
4936         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() };
4937         local_res
4938 }
4939 #[no_mangle]
4940 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
4941 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> 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 RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4946         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
4947 }
4948 #[no_mangle]
4949 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
4950 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
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::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() };
4953         local_res
4954 }
4955 #[no_mangle]
4956 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
4957 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> 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 Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4962         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
4963 }
4964 #[no_mangle]
4965 /// Read a Shutdown from a byte array, created by Shutdown_write
4966 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
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::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() };
4969         local_res
4970 }
4971 #[no_mangle]
4972 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
4973 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> 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 UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4978         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
4979 }
4980 #[no_mangle]
4981 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
4982 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
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::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() };
4985         local_res
4986 }
4987 #[no_mangle]
4988 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
4989 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> 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 UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4994         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
4995 }
4996 #[no_mangle]
4997 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
4998 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
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::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() };
5001         local_res
5002 }
5003 #[no_mangle]
5004 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5005 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> 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 UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5010         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5011 }
5012 #[no_mangle]
5013 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5014 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
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::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() };
5017         local_res
5018 }
5019 #[no_mangle]
5020 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5021 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> 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 UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5026         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
5027 }
5028 #[no_mangle]
5029 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
5030 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
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::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() };
5033         local_res
5034 }
5035 #[no_mangle]
5036 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
5037 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> 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 UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5042         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
5043 }
5044 #[no_mangle]
5045 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
5046 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
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::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() };
5049         local_res
5050 }
5051 #[no_mangle]
5052 /// Serialize the Ping object into a byte array which can be read by Ping_read
5053 pub extern "C" fn Ping_write(obj: &Ping) -> 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 Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5058         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
5059 }
5060 #[no_mangle]
5061 /// Read a Ping from a byte array, created by Ping_write
5062 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
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::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() };
5065         local_res
5066 }
5067 #[no_mangle]
5068 /// Serialize the Pong object into a byte array which can be read by Pong_read
5069 pub extern "C" fn Pong_write(obj: &Pong) -> 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 Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5074         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
5075 }
5076 #[no_mangle]
5077 /// Read a Pong from a byte array, created by Pong_write
5078 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
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::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() };
5081         local_res
5082 }
5083 #[no_mangle]
5084 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
5085 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> 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 UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5090         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
5091 }
5092 #[no_mangle]
5093 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
5094 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
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::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() };
5097         local_res
5098 }
5099 #[no_mangle]
5100 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
5101 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> 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 ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5106         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
5107 }
5108 #[no_mangle]
5109 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
5110 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
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::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() };
5113         local_res
5114 }
5115 #[no_mangle]
5116 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
5117 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> 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 UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5122         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
5123 }
5124 #[no_mangle]
5125 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
5126 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
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::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() };
5129         local_res
5130 }
5131 #[no_mangle]
5132 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
5133 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> 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 ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5138         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
5139 }
5140 #[no_mangle]
5141 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
5142 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
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::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() };
5145         local_res
5146 }
5147 #[no_mangle]
5148 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
5149 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> 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 ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5154         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
5155 }
5156 #[no_mangle]
5157 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
5158 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
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::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() };
5161         local_res
5162 }
5163 #[no_mangle]
5164 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
5165 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> 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 UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5170         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
5171 }
5172 #[no_mangle]
5173 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
5174 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
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::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() };
5177         local_res
5178 }
5179 #[no_mangle]
5180 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
5181 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> 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 NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5186         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
5187 }
5188 #[no_mangle]
5189 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
5190 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
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::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() };
5193         local_res
5194 }
5195 #[no_mangle]
5196 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
5197 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
5198         let res = crate::c_types::deserialize_obj(ser);
5199         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() };
5200         local_res
5201 }
5202 #[no_mangle]
5203 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
5204 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
5205         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5206 }
5207 #[no_mangle]
5208 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5209         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
5210 }
5211 #[no_mangle]
5212 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
5213 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
5214         let res = crate::c_types::deserialize_obj(ser);
5215         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() };
5216         local_res
5217 }
5218 #[no_mangle]
5219 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
5220 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
5221         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5222 }
5223 #[no_mangle]
5224 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5225         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
5226 }
5227 ///\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 
5228 #[must_use]
5229 #[no_mangle]
5230 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 {
5231         let mut ret = unsafe { &*this_arg.inner }.end_blocknum();
5232         ret
5233 }
5234
5235 #[no_mangle]
5236 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
5237 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
5238         let res = crate::c_types::deserialize_obj(ser);
5239         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() };
5240         local_res
5241 }
5242 #[no_mangle]
5243 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
5244 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
5245         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5246 }
5247 #[no_mangle]
5248 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5249         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
5250 }
5251 #[no_mangle]
5252 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
5253 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
5254         let res = crate::c_types::deserialize_obj(ser);
5255         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() };
5256         local_res
5257 }
5258 #[no_mangle]
5259 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
5260 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
5261         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5262 }
5263 #[no_mangle]
5264 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5265         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
5266 }
5267 #[no_mangle]
5268 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
5269 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
5270         let res = crate::c_types::deserialize_obj(ser);
5271         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() };
5272         local_res
5273 }
5274 #[no_mangle]
5275 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
5276 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
5277         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5278 }
5279 #[no_mangle]
5280 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5281         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
5282 }