Commit latest auto-generated C bindings based on 0.0.100
[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::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1349 type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1350
1351 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1352 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1353 /// to use.
1354 #[must_use]
1355 #[repr(C)]
1356 pub struct ClosingSignedFeeRange {
1357         /// A pointer to the opaque Rust object.
1358
1359         /// Nearly everywhere, inner must be non-null, however in places where
1360         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1361         pub inner: *mut nativeClosingSignedFeeRange,
1362         /// Indicates that this is the only struct which contains the same pointer.
1363
1364         /// Rust functions which take ownership of an object provided via an argument require
1365         /// this to be true and invalidate the object pointed to by inner.
1366         pub is_owned: bool,
1367 }
1368
1369 impl Drop for ClosingSignedFeeRange {
1370         fn drop(&mut self) {
1371                 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1372                         let _ = unsafe { Box::from_raw(self.inner) };
1373                 }
1374         }
1375 }
1376 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1377 #[no_mangle]
1378 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1379 #[allow(unused)]
1380 /// Used only if an object of this type is returned as a trait impl by a method
1381 extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1382         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange); }
1383 }
1384 #[allow(unused)]
1385 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1386 impl ClosingSignedFeeRange {
1387         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1388                 assert!(self.is_owned);
1389                 let ret = self.inner;
1390                 self.inner = std::ptr::null_mut();
1391                 ret
1392         }
1393 }
1394 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1395 /// transaction.
1396 #[no_mangle]
1397 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1398         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_fee_satoshis;
1399         *inner_val
1400 }
1401 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1402 /// transaction.
1403 #[no_mangle]
1404 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1405         unsafe { &mut *this_ptr.inner }.min_fee_satoshis = val;
1406 }
1407 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1408 /// transaction.
1409 #[no_mangle]
1410 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1411         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_fee_satoshis;
1412         *inner_val
1413 }
1414 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1415 /// transaction.
1416 #[no_mangle]
1417 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1418         unsafe { &mut *this_ptr.inner }.max_fee_satoshis = val;
1419 }
1420 /// Constructs a new ClosingSignedFeeRange given each field
1421 #[must_use]
1422 #[no_mangle]
1423 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1424         ClosingSignedFeeRange { inner: Box::into_raw(Box::new(nativeClosingSignedFeeRange {
1425                 min_fee_satoshis: min_fee_satoshis_arg,
1426                 max_fee_satoshis: max_fee_satoshis_arg,
1427         })), is_owned: true }
1428 }
1429 impl Clone for ClosingSignedFeeRange {
1430         fn clone(&self) -> Self {
1431                 Self {
1432                         inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { std::ptr::null_mut() } else {
1433                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1434                         is_owned: true,
1435                 }
1436         }
1437 }
1438 #[allow(unused)]
1439 /// Used only if an object of this type is returned as a trait impl by a method
1440 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1441         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1442 }
1443 #[no_mangle]
1444 /// Creates a copy of the ClosingSignedFeeRange
1445 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1446         orig.clone()
1447 }
1448
1449 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1450 type nativeClosingSigned = nativeClosingSignedImport;
1451
1452 /// A closing_signed message to be sent or received from a peer
1453 #[must_use]
1454 #[repr(C)]
1455 pub struct ClosingSigned {
1456         /// A pointer to the opaque Rust object.
1457
1458         /// Nearly everywhere, inner must be non-null, however in places where
1459         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1460         pub inner: *mut nativeClosingSigned,
1461         /// Indicates that this is the only struct which contains the same pointer.
1462
1463         /// Rust functions which take ownership of an object provided via an argument require
1464         /// this to be true and invalidate the object pointed to by inner.
1465         pub is_owned: bool,
1466 }
1467
1468 impl Drop for ClosingSigned {
1469         fn drop(&mut self) {
1470                 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1471                         let _ = unsafe { Box::from_raw(self.inner) };
1472                 }
1473         }
1474 }
1475 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1476 #[no_mangle]
1477 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1478 #[allow(unused)]
1479 /// Used only if an object of this type is returned as a trait impl by a method
1480 extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1481         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1482 }
1483 #[allow(unused)]
1484 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1485 impl ClosingSigned {
1486         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1487                 assert!(self.is_owned);
1488                 let ret = self.inner;
1489                 self.inner = std::ptr::null_mut();
1490                 ret
1491         }
1492 }
1493 /// The channel ID
1494 #[no_mangle]
1495 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1496         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1497         inner_val
1498 }
1499 /// The channel ID
1500 #[no_mangle]
1501 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1502         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1503 }
1504 /// The proposed total fee for the closing transaction
1505 #[no_mangle]
1506 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1507         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_satoshis;
1508         *inner_val
1509 }
1510 /// The proposed total fee for the closing transaction
1511 #[no_mangle]
1512 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1513         unsafe { &mut *this_ptr.inner }.fee_satoshis = val;
1514 }
1515 /// A signature on the closing transaction
1516 #[no_mangle]
1517 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1518         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1519         crate::c_types::Signature::from_rust(&inner_val)
1520 }
1521 /// A signature on the closing transaction
1522 #[no_mangle]
1523 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1524         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1525 }
1526 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1527 /// nodes.
1528 ///
1529 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1530 #[no_mangle]
1531 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
1532         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_range;
1533         let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1534         local_inner_val
1535 }
1536 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1537 /// nodes.
1538 ///
1539 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1540 #[no_mangle]
1541 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
1542         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1543         unsafe { &mut *this_ptr.inner }.fee_range = local_val;
1544 }
1545 /// Constructs a new ClosingSigned given each field
1546 #[must_use]
1547 #[no_mangle]
1548 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::Signature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
1549         let mut local_fee_range_arg = if fee_range_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(fee_range_arg.take_inner()) } }) };
1550         ClosingSigned { inner: Box::into_raw(Box::new(nativeClosingSigned {
1551                 channel_id: channel_id_arg.data,
1552                 fee_satoshis: fee_satoshis_arg,
1553                 signature: signature_arg.into_rust(),
1554                 fee_range: local_fee_range_arg,
1555         })), is_owned: true }
1556 }
1557 impl Clone for ClosingSigned {
1558         fn clone(&self) -> Self {
1559                 Self {
1560                         inner: if <*mut nativeClosingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
1561                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1562                         is_owned: true,
1563                 }
1564         }
1565 }
1566 #[allow(unused)]
1567 /// Used only if an object of this type is returned as a trait impl by a method
1568 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1569         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1570 }
1571 #[no_mangle]
1572 /// Creates a copy of the ClosingSigned
1573 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1574         orig.clone()
1575 }
1576
1577 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1578 type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1579
1580 /// An update_add_htlc message to be sent or received from a peer
1581 #[must_use]
1582 #[repr(C)]
1583 pub struct UpdateAddHTLC {
1584         /// A pointer to the opaque Rust object.
1585
1586         /// Nearly everywhere, inner must be non-null, however in places where
1587         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1588         pub inner: *mut nativeUpdateAddHTLC,
1589         /// Indicates that this is the only struct which contains the same pointer.
1590
1591         /// Rust functions which take ownership of an object provided via an argument require
1592         /// this to be true and invalidate the object pointed to by inner.
1593         pub is_owned: bool,
1594 }
1595
1596 impl Drop for UpdateAddHTLC {
1597         fn drop(&mut self) {
1598                 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
1599                         let _ = unsafe { Box::from_raw(self.inner) };
1600                 }
1601         }
1602 }
1603 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
1604 #[no_mangle]
1605 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
1606 #[allow(unused)]
1607 /// Used only if an object of this type is returned as a trait impl by a method
1608 extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1609         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1610 }
1611 #[allow(unused)]
1612 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1613 impl UpdateAddHTLC {
1614         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1615                 assert!(self.is_owned);
1616                 let ret = self.inner;
1617                 self.inner = std::ptr::null_mut();
1618                 ret
1619         }
1620 }
1621 /// The channel ID
1622 #[no_mangle]
1623 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1624         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1625         inner_val
1626 }
1627 /// The channel ID
1628 #[no_mangle]
1629 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1630         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1631 }
1632 /// The HTLC ID
1633 #[no_mangle]
1634 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1635         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1636         *inner_val
1637 }
1638 /// The HTLC ID
1639 #[no_mangle]
1640 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1641         unsafe { &mut *this_ptr.inner }.htlc_id = val;
1642 }
1643 /// The HTLC value in milli-satoshi
1644 #[no_mangle]
1645 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1646         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat;
1647         *inner_val
1648 }
1649 /// The HTLC value in milli-satoshi
1650 #[no_mangle]
1651 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1652         unsafe { &mut *this_ptr.inner }.amount_msat = val;
1653 }
1654 /// The payment hash, the pre-image of which controls HTLC redemption
1655 #[no_mangle]
1656 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1657         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash;
1658         &inner_val.0
1659 }
1660 /// The payment hash, the pre-image of which controls HTLC redemption
1661 #[no_mangle]
1662 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1663         unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::PaymentHash(val.data);
1664 }
1665 /// The expiry height of the HTLC
1666 #[no_mangle]
1667 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1668         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry;
1669         *inner_val
1670 }
1671 /// The expiry height of the HTLC
1672 #[no_mangle]
1673 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1674         unsafe { &mut *this_ptr.inner }.cltv_expiry = val;
1675 }
1676 impl Clone for UpdateAddHTLC {
1677         fn clone(&self) -> Self {
1678                 Self {
1679                         inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1680                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1681                         is_owned: true,
1682                 }
1683         }
1684 }
1685 #[allow(unused)]
1686 /// Used only if an object of this type is returned as a trait impl by a method
1687 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1688         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1689 }
1690 #[no_mangle]
1691 /// Creates a copy of the UpdateAddHTLC
1692 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1693         orig.clone()
1694 }
1695
1696 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1697 type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1698
1699 /// An update_fulfill_htlc message to be sent or received from a peer
1700 #[must_use]
1701 #[repr(C)]
1702 pub struct UpdateFulfillHTLC {
1703         /// A pointer to the opaque Rust object.
1704
1705         /// Nearly everywhere, inner must be non-null, however in places where
1706         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1707         pub inner: *mut nativeUpdateFulfillHTLC,
1708         /// Indicates that this is the only struct which contains the same pointer.
1709
1710         /// Rust functions which take ownership of an object provided via an argument require
1711         /// this to be true and invalidate the object pointed to by inner.
1712         pub is_owned: bool,
1713 }
1714
1715 impl Drop for UpdateFulfillHTLC {
1716         fn drop(&mut self) {
1717                 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
1718                         let _ = unsafe { Box::from_raw(self.inner) };
1719                 }
1720         }
1721 }
1722 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
1723 #[no_mangle]
1724 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
1725 #[allow(unused)]
1726 /// Used only if an object of this type is returned as a trait impl by a method
1727 extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1728         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1729 }
1730 #[allow(unused)]
1731 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1732 impl UpdateFulfillHTLC {
1733         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1734                 assert!(self.is_owned);
1735                 let ret = self.inner;
1736                 self.inner = std::ptr::null_mut();
1737                 ret
1738         }
1739 }
1740 /// The channel ID
1741 #[no_mangle]
1742 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1743         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1744         inner_val
1745 }
1746 /// The channel ID
1747 #[no_mangle]
1748 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1749         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1750 }
1751 /// The HTLC ID
1752 #[no_mangle]
1753 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1754         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1755         *inner_val
1756 }
1757 /// The HTLC ID
1758 #[no_mangle]
1759 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1760         unsafe { &mut *this_ptr.inner }.htlc_id = val;
1761 }
1762 /// The pre-image of the payment hash, allowing HTLC redemption
1763 #[no_mangle]
1764 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1765         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_preimage;
1766         &inner_val.0
1767 }
1768 /// The pre-image of the payment hash, allowing HTLC redemption
1769 #[no_mangle]
1770 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1771         unsafe { &mut *this_ptr.inner }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
1772 }
1773 /// Constructs a new UpdateFulfillHTLC given each field
1774 #[must_use]
1775 #[no_mangle]
1776 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 {
1777         UpdateFulfillHTLC { inner: Box::into_raw(Box::new(nativeUpdateFulfillHTLC {
1778                 channel_id: channel_id_arg.data,
1779                 htlc_id: htlc_id_arg,
1780                 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
1781         })), is_owned: true }
1782 }
1783 impl Clone for UpdateFulfillHTLC {
1784         fn clone(&self) -> Self {
1785                 Self {
1786                         inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1787                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1788                         is_owned: true,
1789                 }
1790         }
1791 }
1792 #[allow(unused)]
1793 /// Used only if an object of this type is returned as a trait impl by a method
1794 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1795         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1796 }
1797 #[no_mangle]
1798 /// Creates a copy of the UpdateFulfillHTLC
1799 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1800         orig.clone()
1801 }
1802
1803 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1804 type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1805
1806 /// An update_fail_htlc message to be sent or received from a peer
1807 #[must_use]
1808 #[repr(C)]
1809 pub struct UpdateFailHTLC {
1810         /// A pointer to the opaque Rust object.
1811
1812         /// Nearly everywhere, inner must be non-null, however in places where
1813         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1814         pub inner: *mut nativeUpdateFailHTLC,
1815         /// Indicates that this is the only struct which contains the same pointer.
1816
1817         /// Rust functions which take ownership of an object provided via an argument require
1818         /// this to be true and invalidate the object pointed to by inner.
1819         pub is_owned: bool,
1820 }
1821
1822 impl Drop for UpdateFailHTLC {
1823         fn drop(&mut self) {
1824                 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
1825                         let _ = unsafe { Box::from_raw(self.inner) };
1826                 }
1827         }
1828 }
1829 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
1830 #[no_mangle]
1831 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
1832 #[allow(unused)]
1833 /// Used only if an object of this type is returned as a trait impl by a method
1834 extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1835         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1836 }
1837 #[allow(unused)]
1838 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1839 impl UpdateFailHTLC {
1840         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
1841                 assert!(self.is_owned);
1842                 let ret = self.inner;
1843                 self.inner = std::ptr::null_mut();
1844                 ret
1845         }
1846 }
1847 /// The channel ID
1848 #[no_mangle]
1849 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1850         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1851         inner_val
1852 }
1853 /// The channel ID
1854 #[no_mangle]
1855 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1856         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1857 }
1858 /// The HTLC ID
1859 #[no_mangle]
1860 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1861         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1862         *inner_val
1863 }
1864 /// The HTLC ID
1865 #[no_mangle]
1866 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1867         unsafe { &mut *this_ptr.inner }.htlc_id = val;
1868 }
1869 impl Clone for UpdateFailHTLC {
1870         fn clone(&self) -> Self {
1871                 Self {
1872                         inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1873                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1874                         is_owned: true,
1875                 }
1876         }
1877 }
1878 #[allow(unused)]
1879 /// Used only if an object of this type is returned as a trait impl by a method
1880 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1881         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
1882 }
1883 #[no_mangle]
1884 /// Creates a copy of the UpdateFailHTLC
1885 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
1886         orig.clone()
1887 }
1888
1889 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
1890 type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
1891
1892 /// An update_fail_malformed_htlc message to be sent or received from a peer
1893 #[must_use]
1894 #[repr(C)]
1895 pub struct UpdateFailMalformedHTLC {
1896         /// A pointer to the opaque Rust object.
1897
1898         /// Nearly everywhere, inner must be non-null, however in places where
1899         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1900         pub inner: *mut nativeUpdateFailMalformedHTLC,
1901         /// Indicates that this is the only struct which contains the same pointer.
1902
1903         /// Rust functions which take ownership of an object provided via an argument require
1904         /// this to be true and invalidate the object pointed to by inner.
1905         pub is_owned: bool,
1906 }
1907
1908 impl Drop for UpdateFailMalformedHTLC {
1909         fn drop(&mut self) {
1910                 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
1911                         let _ = unsafe { Box::from_raw(self.inner) };
1912                 }
1913         }
1914 }
1915 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
1916 #[no_mangle]
1917 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
1918 #[allow(unused)]
1919 /// Used only if an object of this type is returned as a trait impl by a method
1920 extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
1921         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
1922 }
1923 #[allow(unused)]
1924 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1925 impl UpdateFailMalformedHTLC {
1926         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
1927                 assert!(self.is_owned);
1928                 let ret = self.inner;
1929                 self.inner = std::ptr::null_mut();
1930                 ret
1931         }
1932 }
1933 /// The channel ID
1934 #[no_mangle]
1935 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
1936         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1937         inner_val
1938 }
1939 /// The channel ID
1940 #[no_mangle]
1941 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1942         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1943 }
1944 /// The HTLC ID
1945 #[no_mangle]
1946 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
1947         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1948         *inner_val
1949 }
1950 /// The HTLC ID
1951 #[no_mangle]
1952 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
1953         unsafe { &mut *this_ptr.inner }.htlc_id = val;
1954 }
1955 /// The failure code
1956 #[no_mangle]
1957 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
1958         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.failure_code;
1959         *inner_val
1960 }
1961 /// The failure code
1962 #[no_mangle]
1963 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
1964         unsafe { &mut *this_ptr.inner }.failure_code = val;
1965 }
1966 impl Clone for UpdateFailMalformedHTLC {
1967         fn clone(&self) -> Self {
1968                 Self {
1969                         inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1970                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1971                         is_owned: true,
1972                 }
1973         }
1974 }
1975 #[allow(unused)]
1976 /// Used only if an object of this type is returned as a trait impl by a method
1977 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1978         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
1979 }
1980 #[no_mangle]
1981 /// Creates a copy of the UpdateFailMalformedHTLC
1982 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
1983         orig.clone()
1984 }
1985
1986 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
1987 type nativeCommitmentSigned = nativeCommitmentSignedImport;
1988
1989 /// A commitment_signed message to be sent or received from a peer
1990 #[must_use]
1991 #[repr(C)]
1992 pub struct CommitmentSigned {
1993         /// A pointer to the opaque Rust object.
1994
1995         /// Nearly everywhere, inner must be non-null, however in places where
1996         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1997         pub inner: *mut nativeCommitmentSigned,
1998         /// Indicates that this is the only struct which contains the same pointer.
1999
2000         /// Rust functions which take ownership of an object provided via an argument require
2001         /// this to be true and invalidate the object pointed to by inner.
2002         pub is_owned: bool,
2003 }
2004
2005 impl Drop for CommitmentSigned {
2006         fn drop(&mut self) {
2007                 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2008                         let _ = unsafe { Box::from_raw(self.inner) };
2009                 }
2010         }
2011 }
2012 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2013 #[no_mangle]
2014 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2015 #[allow(unused)]
2016 /// Used only if an object of this type is returned as a trait impl by a method
2017 extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2018         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
2019 }
2020 #[allow(unused)]
2021 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2022 impl CommitmentSigned {
2023         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2024                 assert!(self.is_owned);
2025                 let ret = self.inner;
2026                 self.inner = std::ptr::null_mut();
2027                 ret
2028         }
2029 }
2030 /// The channel ID
2031 #[no_mangle]
2032 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2033         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2034         inner_val
2035 }
2036 /// The channel ID
2037 #[no_mangle]
2038 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2039         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2040 }
2041 /// A signature on the commitment transaction
2042 #[no_mangle]
2043 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2044         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2045         crate::c_types::Signature::from_rust(&inner_val)
2046 }
2047 /// A signature on the commitment transaction
2048 #[no_mangle]
2049 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2050         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2051 }
2052 /// Signatures on the HTLC transactions
2053 #[no_mangle]
2054 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2055         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2056         unsafe { &mut *this_ptr.inner }.htlc_signatures = local_val;
2057 }
2058 /// Constructs a new CommitmentSigned given each field
2059 #[must_use]
2060 #[no_mangle]
2061 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 {
2062         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() }); };
2063         CommitmentSigned { inner: Box::into_raw(Box::new(nativeCommitmentSigned {
2064                 channel_id: channel_id_arg.data,
2065                 signature: signature_arg.into_rust(),
2066                 htlc_signatures: local_htlc_signatures_arg,
2067         })), is_owned: true }
2068 }
2069 impl Clone for CommitmentSigned {
2070         fn clone(&self) -> Self {
2071                 Self {
2072                         inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
2073                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2074                         is_owned: true,
2075                 }
2076         }
2077 }
2078 #[allow(unused)]
2079 /// Used only if an object of this type is returned as a trait impl by a method
2080 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2081         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2082 }
2083 #[no_mangle]
2084 /// Creates a copy of the CommitmentSigned
2085 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2086         orig.clone()
2087 }
2088
2089 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2090 type nativeRevokeAndACK = nativeRevokeAndACKImport;
2091
2092 /// A revoke_and_ack message to be sent or received from a peer
2093 #[must_use]
2094 #[repr(C)]
2095 pub struct RevokeAndACK {
2096         /// A pointer to the opaque Rust object.
2097
2098         /// Nearly everywhere, inner must be non-null, however in places where
2099         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2100         pub inner: *mut nativeRevokeAndACK,
2101         /// Indicates that this is the only struct which contains the same pointer.
2102
2103         /// Rust functions which take ownership of an object provided via an argument require
2104         /// this to be true and invalidate the object pointed to by inner.
2105         pub is_owned: bool,
2106 }
2107
2108 impl Drop for RevokeAndACK {
2109         fn drop(&mut self) {
2110                 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2111                         let _ = unsafe { Box::from_raw(self.inner) };
2112                 }
2113         }
2114 }
2115 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2116 #[no_mangle]
2117 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2118 #[allow(unused)]
2119 /// Used only if an object of this type is returned as a trait impl by a method
2120 extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2121         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
2122 }
2123 #[allow(unused)]
2124 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2125 impl RevokeAndACK {
2126         pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2127                 assert!(self.is_owned);
2128                 let ret = self.inner;
2129                 self.inner = std::ptr::null_mut();
2130                 ret
2131         }
2132 }
2133 /// The channel ID
2134 #[no_mangle]
2135 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2136         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2137         inner_val
2138 }
2139 /// The channel ID
2140 #[no_mangle]
2141 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2142         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2143 }
2144 /// The secret corresponding to the per-commitment point
2145 #[no_mangle]
2146 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2147         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_secret;
2148         inner_val
2149 }
2150 /// The secret corresponding to the per-commitment point
2151 #[no_mangle]
2152 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2153         unsafe { &mut *this_ptr.inner }.per_commitment_secret = val.data;
2154 }
2155 /// The next sender-broadcast commitment transaction's per-commitment point
2156 #[no_mangle]
2157 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2158         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
2159         crate::c_types::PublicKey::from_rust(&inner_val)
2160 }
2161 /// The next sender-broadcast commitment transaction's per-commitment point
2162 #[no_mangle]
2163 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2164         unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
2165 }
2166 /// Constructs a new RevokeAndACK given each field
2167 #[must_use]
2168 #[no_mangle]
2169 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 {
2170         RevokeAndACK { inner: Box::into_raw(Box::new(nativeRevokeAndACK {
2171                 channel_id: channel_id_arg.data,
2172                 per_commitment_secret: per_commitment_secret_arg.data,
2173                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2174         })), is_owned: true }
2175 }
2176 impl Clone for RevokeAndACK {
2177         fn clone(&self) -> Self {
2178                 Self {
2179                         inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { std::ptr::null_mut() } else {
2180                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2181                         is_owned: true,
2182                 }
2183         }
2184 }
2185 #[allow(unused)]
2186 /// Used only if an object of this type is returned as a trait impl by a method
2187 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2188         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2189 }
2190 #[no_mangle]
2191 /// Creates a copy of the RevokeAndACK
2192 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2193         orig.clone()
2194 }
2195
2196 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2197 type nativeUpdateFee = nativeUpdateFeeImport;
2198
2199 /// An update_fee message to be sent or received from a peer
2200 #[must_use]
2201 #[repr(C)]
2202 pub struct UpdateFee {
2203         /// A pointer to the opaque Rust object.
2204
2205         /// Nearly everywhere, inner must be non-null, however in places where
2206         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2207         pub inner: *mut nativeUpdateFee,
2208         /// Indicates that this is the only struct which contains the same pointer.
2209
2210         /// Rust functions which take ownership of an object provided via an argument require
2211         /// this to be true and invalidate the object pointed to by inner.
2212         pub is_owned: bool,
2213 }
2214
2215 impl Drop for UpdateFee {
2216         fn drop(&mut self) {
2217                 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2218                         let _ = unsafe { Box::from_raw(self.inner) };
2219                 }
2220         }
2221 }
2222 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2223 #[no_mangle]
2224 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2225 #[allow(unused)]
2226 /// Used only if an object of this type is returned as a trait impl by a method
2227 extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2228         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
2229 }
2230 #[allow(unused)]
2231 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2232 impl UpdateFee {
2233         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2234                 assert!(self.is_owned);
2235                 let ret = self.inner;
2236                 self.inner = std::ptr::null_mut();
2237                 ret
2238         }
2239 }
2240 /// The channel ID
2241 #[no_mangle]
2242 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2243         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2244         inner_val
2245 }
2246 /// The channel ID
2247 #[no_mangle]
2248 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2249         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2250 }
2251 /// Fee rate per 1000-weight of the transaction
2252 #[no_mangle]
2253 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2254         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
2255         *inner_val
2256 }
2257 /// Fee rate per 1000-weight of the transaction
2258 #[no_mangle]
2259 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2260         unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
2261 }
2262 /// Constructs a new UpdateFee given each field
2263 #[must_use]
2264 #[no_mangle]
2265 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2266         UpdateFee { inner: Box::into_raw(Box::new(nativeUpdateFee {
2267                 channel_id: channel_id_arg.data,
2268                 feerate_per_kw: feerate_per_kw_arg,
2269         })), is_owned: true }
2270 }
2271 impl Clone for UpdateFee {
2272         fn clone(&self) -> Self {
2273                 Self {
2274                         inner: if <*mut nativeUpdateFee>::is_null(self.inner) { std::ptr::null_mut() } else {
2275                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2276                         is_owned: true,
2277                 }
2278         }
2279 }
2280 #[allow(unused)]
2281 /// Used only if an object of this type is returned as a trait impl by a method
2282 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
2283         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
2284 }
2285 #[no_mangle]
2286 /// Creates a copy of the UpdateFee
2287 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
2288         orig.clone()
2289 }
2290
2291 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
2292 type nativeDataLossProtect = nativeDataLossProtectImport;
2293
2294 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2295 /// This is used to convince the recipient that the channel is at a certain commitment
2296 /// number even if they lost that data due to a local failure.  Of course, the peer may lie
2297 /// and even later commitments may have been revoked.
2298 #[must_use]
2299 #[repr(C)]
2300 pub struct DataLossProtect {
2301         /// A pointer to the opaque Rust object.
2302
2303         /// Nearly everywhere, inner must be non-null, however in places where
2304         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2305         pub inner: *mut nativeDataLossProtect,
2306         /// Indicates that this is the only struct which contains the same pointer.
2307
2308         /// Rust functions which take ownership of an object provided via an argument require
2309         /// this to be true and invalidate the object pointed to by inner.
2310         pub is_owned: bool,
2311 }
2312
2313 impl Drop for DataLossProtect {
2314         fn drop(&mut self) {
2315                 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
2316                         let _ = unsafe { Box::from_raw(self.inner) };
2317                 }
2318         }
2319 }
2320 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
2321 #[no_mangle]
2322 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
2323 #[allow(unused)]
2324 /// Used only if an object of this type is returned as a trait impl by a method
2325 extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2326         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2327 }
2328 #[allow(unused)]
2329 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2330 impl DataLossProtect {
2331         pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2332                 assert!(self.is_owned);
2333                 let ret = self.inner;
2334                 self.inner = std::ptr::null_mut();
2335                 ret
2336         }
2337 }
2338 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2339 /// belonging to the recipient
2340 #[no_mangle]
2341 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2342         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret;
2343         inner_val
2344 }
2345 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2346 /// belonging to the recipient
2347 #[no_mangle]
2348 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2349         unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret = val.data;
2350 }
2351 /// The sender's per-commitment point for their current commitment transaction
2352 #[no_mangle]
2353 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2354         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point;
2355         crate::c_types::PublicKey::from_rust(&inner_val)
2356 }
2357 /// The sender's per-commitment point for their current commitment transaction
2358 #[no_mangle]
2359 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2360         unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point = val.into_rust();
2361 }
2362 /// Constructs a new DataLossProtect given each field
2363 #[must_use]
2364 #[no_mangle]
2365 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 {
2366         DataLossProtect { inner: Box::into_raw(Box::new(nativeDataLossProtect {
2367                 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2368                 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2369         })), is_owned: true }
2370 }
2371 impl Clone for DataLossProtect {
2372         fn clone(&self) -> Self {
2373                 Self {
2374                         inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { std::ptr::null_mut() } else {
2375                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2376                         is_owned: true,
2377                 }
2378         }
2379 }
2380 #[allow(unused)]
2381 /// Used only if an object of this type is returned as a trait impl by a method
2382 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2383         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2384 }
2385 #[no_mangle]
2386 /// Creates a copy of the DataLossProtect
2387 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2388         orig.clone()
2389 }
2390
2391 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2392 type nativeChannelReestablish = nativeChannelReestablishImport;
2393
2394 /// A channel_reestablish message to be sent or received from a peer
2395 #[must_use]
2396 #[repr(C)]
2397 pub struct ChannelReestablish {
2398         /// A pointer to the opaque Rust object.
2399
2400         /// Nearly everywhere, inner must be non-null, however in places where
2401         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2402         pub inner: *mut nativeChannelReestablish,
2403         /// Indicates that this is the only struct which contains the same pointer.
2404
2405         /// Rust functions which take ownership of an object provided via an argument require
2406         /// this to be true and invalidate the object pointed to by inner.
2407         pub is_owned: bool,
2408 }
2409
2410 impl Drop for ChannelReestablish {
2411         fn drop(&mut self) {
2412                 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
2413                         let _ = unsafe { Box::from_raw(self.inner) };
2414                 }
2415         }
2416 }
2417 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
2418 #[no_mangle]
2419 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
2420 #[allow(unused)]
2421 /// Used only if an object of this type is returned as a trait impl by a method
2422 extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2423         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2424 }
2425 #[allow(unused)]
2426 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2427 impl ChannelReestablish {
2428         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2429                 assert!(self.is_owned);
2430                 let ret = self.inner;
2431                 self.inner = std::ptr::null_mut();
2432                 ret
2433         }
2434 }
2435 /// The channel ID
2436 #[no_mangle]
2437 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2438         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2439         inner_val
2440 }
2441 /// The channel ID
2442 #[no_mangle]
2443 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2444         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2445 }
2446 /// The next commitment number for the sender
2447 #[no_mangle]
2448 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2449         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_local_commitment_number;
2450         *inner_val
2451 }
2452 /// The next commitment number for the sender
2453 #[no_mangle]
2454 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2455         unsafe { &mut *this_ptr.inner }.next_local_commitment_number = val;
2456 }
2457 /// The next commitment number for the recipient
2458 #[no_mangle]
2459 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2460         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_remote_commitment_number;
2461         *inner_val
2462 }
2463 /// The next commitment number for the recipient
2464 #[no_mangle]
2465 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2466         unsafe { &mut *this_ptr.inner }.next_remote_commitment_number = val;
2467 }
2468 impl Clone for ChannelReestablish {
2469         fn clone(&self) -> Self {
2470                 Self {
2471                         inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { std::ptr::null_mut() } else {
2472                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2473                         is_owned: true,
2474                 }
2475         }
2476 }
2477 #[allow(unused)]
2478 /// Used only if an object of this type is returned as a trait impl by a method
2479 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2480         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2481 }
2482 #[no_mangle]
2483 /// Creates a copy of the ChannelReestablish
2484 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2485         orig.clone()
2486 }
2487
2488 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2489 type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2490
2491 /// An announcement_signatures message to be sent or received from a peer
2492 #[must_use]
2493 #[repr(C)]
2494 pub struct AnnouncementSignatures {
2495         /// A pointer to the opaque Rust object.
2496
2497         /// Nearly everywhere, inner must be non-null, however in places where
2498         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2499         pub inner: *mut nativeAnnouncementSignatures,
2500         /// Indicates that this is the only struct which contains the same pointer.
2501
2502         /// Rust functions which take ownership of an object provided via an argument require
2503         /// this to be true and invalidate the object pointed to by inner.
2504         pub is_owned: bool,
2505 }
2506
2507 impl Drop for AnnouncementSignatures {
2508         fn drop(&mut self) {
2509                 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
2510                         let _ = unsafe { Box::from_raw(self.inner) };
2511                 }
2512         }
2513 }
2514 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
2515 #[no_mangle]
2516 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
2517 #[allow(unused)]
2518 /// Used only if an object of this type is returned as a trait impl by a method
2519 extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2520         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2521 }
2522 #[allow(unused)]
2523 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2524 impl AnnouncementSignatures {
2525         pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2526                 assert!(self.is_owned);
2527                 let ret = self.inner;
2528                 self.inner = std::ptr::null_mut();
2529                 ret
2530         }
2531 }
2532 /// The channel ID
2533 #[no_mangle]
2534 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2535         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2536         inner_val
2537 }
2538 /// The channel ID
2539 #[no_mangle]
2540 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2541         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2542 }
2543 /// The short channel ID
2544 #[no_mangle]
2545 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2546         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2547         *inner_val
2548 }
2549 /// The short channel ID
2550 #[no_mangle]
2551 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2552         unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2553 }
2554 /// A signature by the node key
2555 #[no_mangle]
2556 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2557         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature;
2558         crate::c_types::Signature::from_rust(&inner_val)
2559 }
2560 /// A signature by the node key
2561 #[no_mangle]
2562 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2563         unsafe { &mut *this_ptr.inner }.node_signature = val.into_rust();
2564 }
2565 /// A signature by the funding key
2566 #[no_mangle]
2567 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2568         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature;
2569         crate::c_types::Signature::from_rust(&inner_val)
2570 }
2571 /// A signature by the funding key
2572 #[no_mangle]
2573 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2574         unsafe { &mut *this_ptr.inner }.bitcoin_signature = val.into_rust();
2575 }
2576 /// Constructs a new AnnouncementSignatures given each field
2577 #[must_use]
2578 #[no_mangle]
2579 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 {
2580         AnnouncementSignatures { inner: Box::into_raw(Box::new(nativeAnnouncementSignatures {
2581                 channel_id: channel_id_arg.data,
2582                 short_channel_id: short_channel_id_arg,
2583                 node_signature: node_signature_arg.into_rust(),
2584                 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2585         })), is_owned: true }
2586 }
2587 impl Clone for AnnouncementSignatures {
2588         fn clone(&self) -> Self {
2589                 Self {
2590                         inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { std::ptr::null_mut() } else {
2591                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2592                         is_owned: true,
2593                 }
2594         }
2595 }
2596 #[allow(unused)]
2597 /// Used only if an object of this type is returned as a trait impl by a method
2598 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2599         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2600 }
2601 #[no_mangle]
2602 /// Creates a copy of the AnnouncementSignatures
2603 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2604         orig.clone()
2605 }
2606 /// An address which can be used to connect to a remote peer
2607 #[must_use]
2608 #[derive(Clone)]
2609 #[repr(C)]
2610 pub enum NetAddress {
2611         /// An IPv4 address/port on which the peer is listening.
2612         IPv4 {
2613                 /// The 4-byte IPv4 address
2614                 addr: crate::c_types::FourBytes,
2615                 /// The port on which the node is listening
2616                 port: u16,
2617         },
2618         /// An IPv6 address/port on which the peer is listening.
2619         IPv6 {
2620                 /// The 16-byte IPv6 address
2621                 addr: crate::c_types::SixteenBytes,
2622                 /// The port on which the node is listening
2623                 port: u16,
2624         },
2625         /// An old-style Tor onion address/port on which the peer is listening.
2626         OnionV2 {
2627                 /// The bytes (usually encoded in base32 with \".onion\" appended)
2628                 addr: crate::c_types::TenBytes,
2629                 /// The port on which the node is listening
2630                 port: u16,
2631         },
2632         /// A new-style Tor onion address/port on which the peer is listening.
2633         /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2634         /// wrap as base32 and append \".onion\".
2635         OnionV3 {
2636                 /// The ed25519 long-term public key of the peer
2637                 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2638                 /// The checksum of the pubkey and version, as included in the onion address
2639                 checksum: u16,
2640                 /// The version byte, as defined by the Tor Onion v3 spec.
2641                 version: u8,
2642                 /// The port on which the node is listening
2643                 port: u16,
2644         },
2645 }
2646 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2647 impl NetAddress {
2648         #[allow(unused)]
2649         pub(crate) fn to_native(&self) -> nativeNetAddress {
2650                 match self {
2651                         NetAddress::IPv4 {ref addr, ref port, } => {
2652                                 let mut addr_nonref = (*addr).clone();
2653                                 let mut port_nonref = (*port).clone();
2654                                 nativeNetAddress::IPv4 {
2655                                         addr: addr_nonref.data,
2656                                         port: port_nonref,
2657                                 }
2658                         },
2659                         NetAddress::IPv6 {ref addr, ref port, } => {
2660                                 let mut addr_nonref = (*addr).clone();
2661                                 let mut port_nonref = (*port).clone();
2662                                 nativeNetAddress::IPv6 {
2663                                         addr: addr_nonref.data,
2664                                         port: port_nonref,
2665                                 }
2666                         },
2667                         NetAddress::OnionV2 {ref addr, ref port, } => {
2668                                 let mut addr_nonref = (*addr).clone();
2669                                 let mut port_nonref = (*port).clone();
2670                                 nativeNetAddress::OnionV2 {
2671                                         addr: addr_nonref.data,
2672                                         port: port_nonref,
2673                                 }
2674                         },
2675                         NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2676                                 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2677                                 let mut checksum_nonref = (*checksum).clone();
2678                                 let mut version_nonref = (*version).clone();
2679                                 let mut port_nonref = (*port).clone();
2680                                 nativeNetAddress::OnionV3 {
2681                                         ed25519_pubkey: ed25519_pubkey_nonref.data,
2682                                         checksum: checksum_nonref,
2683                                         version: version_nonref,
2684                                         port: port_nonref,
2685                                 }
2686                         },
2687                 }
2688         }
2689         #[allow(unused)]
2690         pub(crate) fn into_native(self) -> nativeNetAddress {
2691                 match self {
2692                         NetAddress::IPv4 {mut addr, mut port, } => {
2693                                 nativeNetAddress::IPv4 {
2694                                         addr: addr.data,
2695                                         port: port,
2696                                 }
2697                         },
2698                         NetAddress::IPv6 {mut addr, mut port, } => {
2699                                 nativeNetAddress::IPv6 {
2700                                         addr: addr.data,
2701                                         port: port,
2702                                 }
2703                         },
2704                         NetAddress::OnionV2 {mut addr, mut port, } => {
2705                                 nativeNetAddress::OnionV2 {
2706                                         addr: addr.data,
2707                                         port: port,
2708                                 }
2709                         },
2710                         NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2711                                 nativeNetAddress::OnionV3 {
2712                                         ed25519_pubkey: ed25519_pubkey.data,
2713                                         checksum: checksum,
2714                                         version: version,
2715                                         port: port,
2716                                 }
2717                         },
2718                 }
2719         }
2720         #[allow(unused)]
2721         pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2722                 match native {
2723                         nativeNetAddress::IPv4 {ref addr, ref port, } => {
2724                                 let mut addr_nonref = (*addr).clone();
2725                                 let mut port_nonref = (*port).clone();
2726                                 NetAddress::IPv4 {
2727                                         addr: crate::c_types::FourBytes { data: addr_nonref },
2728                                         port: port_nonref,
2729                                 }
2730                         },
2731                         nativeNetAddress::IPv6 {ref addr, ref port, } => {
2732                                 let mut addr_nonref = (*addr).clone();
2733                                 let mut port_nonref = (*port).clone();
2734                                 NetAddress::IPv6 {
2735                                         addr: crate::c_types::SixteenBytes { data: addr_nonref },
2736                                         port: port_nonref,
2737                                 }
2738                         },
2739                         nativeNetAddress::OnionV2 {ref addr, ref port, } => {
2740                                 let mut addr_nonref = (*addr).clone();
2741                                 let mut port_nonref = (*port).clone();
2742                                 NetAddress::OnionV2 {
2743                                         addr: crate::c_types::TenBytes { data: addr_nonref },
2744                                         port: port_nonref,
2745                                 }
2746                         },
2747                         nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2748                                 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2749                                 let mut checksum_nonref = (*checksum).clone();
2750                                 let mut version_nonref = (*version).clone();
2751                                 let mut port_nonref = (*port).clone();
2752                                 NetAddress::OnionV3 {
2753                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2754                                         checksum: checksum_nonref,
2755                                         version: version_nonref,
2756                                         port: port_nonref,
2757                                 }
2758                         },
2759                 }
2760         }
2761         #[allow(unused)]
2762         pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2763                 match native {
2764                         nativeNetAddress::IPv4 {mut addr, mut port, } => {
2765                                 NetAddress::IPv4 {
2766                                         addr: crate::c_types::FourBytes { data: addr },
2767                                         port: port,
2768                                 }
2769                         },
2770                         nativeNetAddress::IPv6 {mut addr, mut port, } => {
2771                                 NetAddress::IPv6 {
2772                                         addr: crate::c_types::SixteenBytes { data: addr },
2773                                         port: port,
2774                                 }
2775                         },
2776                         nativeNetAddress::OnionV2 {mut addr, mut port, } => {
2777                                 NetAddress::OnionV2 {
2778                                         addr: crate::c_types::TenBytes { data: addr },
2779                                         port: port,
2780                                 }
2781                         },
2782                         nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2783                                 NetAddress::OnionV3 {
2784                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2785                                         checksum: checksum,
2786                                         version: version,
2787                                         port: port,
2788                                 }
2789                         },
2790                 }
2791         }
2792 }
2793 /// Frees any resources used by the NetAddress
2794 #[no_mangle]
2795 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2796 /// Creates a copy of the NetAddress
2797 #[no_mangle]
2798 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
2799         orig.clone()
2800 }
2801 #[no_mangle]
2802 /// Utility method to constructs a new IPv4-variant NetAddress
2803 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
2804         NetAddress::IPv4 {
2805                 addr,
2806                 port,
2807         }
2808 }
2809 #[no_mangle]
2810 /// Utility method to constructs a new IPv6-variant NetAddress
2811 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
2812         NetAddress::IPv6 {
2813                 addr,
2814                 port,
2815         }
2816 }
2817 #[no_mangle]
2818 /// Utility method to constructs a new OnionV2-variant NetAddress
2819 pub extern "C" fn NetAddress_onion_v2(addr: crate::c_types::TenBytes, port: u16) -> NetAddress {
2820         NetAddress::OnionV2 {
2821                 addr,
2822                 port,
2823         }
2824 }
2825 #[no_mangle]
2826 /// Utility method to constructs a new OnionV3-variant NetAddress
2827 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
2828         NetAddress::OnionV3 {
2829                 ed25519_pubkey,
2830                 checksum,
2831                 version,
2832                 port,
2833         }
2834 }
2835 #[no_mangle]
2836 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
2837 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2838         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2839 }
2840 #[no_mangle]
2841 /// Read a Result from a byte array, created by Result_write
2842 pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ {
2843         let res = crate::c_types::deserialize_obj(ser);
2844         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() };
2845         local_res
2846 }
2847 #[no_mangle]
2848 /// Read a NetAddress from a byte array, created by NetAddress_write
2849 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
2850         let res = crate::c_types::deserialize_obj(ser);
2851         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() };
2852         local_res
2853 }
2854
2855 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2856 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2857
2858 /// The unsigned part of a node_announcement
2859 #[must_use]
2860 #[repr(C)]
2861 pub struct UnsignedNodeAnnouncement {
2862         /// A pointer to the opaque Rust object.
2863
2864         /// Nearly everywhere, inner must be non-null, however in places where
2865         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2866         pub inner: *mut nativeUnsignedNodeAnnouncement,
2867         /// Indicates that this is the only struct which contains the same pointer.
2868
2869         /// Rust functions which take ownership of an object provided via an argument require
2870         /// this to be true and invalidate the object pointed to by inner.
2871         pub is_owned: bool,
2872 }
2873
2874 impl Drop for UnsignedNodeAnnouncement {
2875         fn drop(&mut self) {
2876                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
2877                         let _ = unsafe { Box::from_raw(self.inner) };
2878                 }
2879         }
2880 }
2881 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
2882 #[no_mangle]
2883 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
2884 #[allow(unused)]
2885 /// Used only if an object of this type is returned as a trait impl by a method
2886 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
2887         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
2888 }
2889 #[allow(unused)]
2890 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2891 impl UnsignedNodeAnnouncement {
2892         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
2893                 assert!(self.is_owned);
2894                 let ret = self.inner;
2895                 self.inner = std::ptr::null_mut();
2896                 ret
2897         }
2898 }
2899 /// The advertised features
2900 #[no_mangle]
2901 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
2902         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2903         crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
2904 }
2905 /// The advertised features
2906 #[no_mangle]
2907 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
2908         unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2909 }
2910 /// A strictly monotonic announcement counter, with gaps allowed
2911 #[no_mangle]
2912 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
2913         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2914         *inner_val
2915 }
2916 /// A strictly monotonic announcement counter, with gaps allowed
2917 #[no_mangle]
2918 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
2919         unsafe { &mut *this_ptr.inner }.timestamp = val;
2920 }
2921 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2922 /// to this node).
2923 #[no_mangle]
2924 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
2925         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
2926         crate::c_types::PublicKey::from_rust(&inner_val)
2927 }
2928 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2929 /// to this node).
2930 #[no_mangle]
2931 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
2932         unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
2933 }
2934 /// An RGB color for UI purposes
2935 #[no_mangle]
2936 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
2937         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
2938         inner_val
2939 }
2940 /// An RGB color for UI purposes
2941 #[no_mangle]
2942 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
2943         unsafe { &mut *this_ptr.inner }.rgb = val.data;
2944 }
2945 /// An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
2946 /// of uniqueness.
2947 #[no_mangle]
2948 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
2949         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
2950         inner_val
2951 }
2952 /// An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
2953 /// of uniqueness.
2954 #[no_mangle]
2955 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2956         unsafe { &mut *this_ptr.inner }.alias = val.data;
2957 }
2958 /// List of addresses on which this node is reachable
2959 #[no_mangle]
2960 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
2961         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
2962         unsafe { &mut *this_ptr.inner }.addresses = local_val;
2963 }
2964 impl Clone for UnsignedNodeAnnouncement {
2965         fn clone(&self) -> Self {
2966                 Self {
2967                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
2968                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2969                         is_owned: true,
2970                 }
2971         }
2972 }
2973 #[allow(unused)]
2974 /// Used only if an object of this type is returned as a trait impl by a method
2975 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2976         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
2977 }
2978 #[no_mangle]
2979 /// Creates a copy of the UnsignedNodeAnnouncement
2980 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
2981         orig.clone()
2982 }
2983
2984 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
2985 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
2986
2987 /// A node_announcement message to be sent or received from a peer
2988 #[must_use]
2989 #[repr(C)]
2990 pub struct NodeAnnouncement {
2991         /// A pointer to the opaque Rust object.
2992
2993         /// Nearly everywhere, inner must be non-null, however in places where
2994         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2995         pub inner: *mut nativeNodeAnnouncement,
2996         /// Indicates that this is the only struct which contains the same pointer.
2997
2998         /// Rust functions which take ownership of an object provided via an argument require
2999         /// this to be true and invalidate the object pointed to by inner.
3000         pub is_owned: bool,
3001 }
3002
3003 impl Drop for NodeAnnouncement {
3004         fn drop(&mut self) {
3005                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3006                         let _ = unsafe { Box::from_raw(self.inner) };
3007                 }
3008         }
3009 }
3010 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3011 #[no_mangle]
3012 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3013 #[allow(unused)]
3014 /// Used only if an object of this type is returned as a trait impl by a method
3015 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3016         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3017 }
3018 #[allow(unused)]
3019 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3020 impl NodeAnnouncement {
3021         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3022                 assert!(self.is_owned);
3023                 let ret = self.inner;
3024                 self.inner = std::ptr::null_mut();
3025                 ret
3026         }
3027 }
3028 /// The signature by the node key
3029 #[no_mangle]
3030 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3031         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
3032         crate::c_types::Signature::from_rust(&inner_val)
3033 }
3034 /// The signature by the node key
3035 #[no_mangle]
3036 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3037         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
3038 }
3039 /// The actual content of the announcement
3040 #[no_mangle]
3041 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3042         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
3043         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
3044 }
3045 /// The actual content of the announcement
3046 #[no_mangle]
3047 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3048         unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3049 }
3050 /// Constructs a new NodeAnnouncement given each field
3051 #[must_use]
3052 #[no_mangle]
3053 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3054         NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement {
3055                 signature: signature_arg.into_rust(),
3056                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3057         })), is_owned: true }
3058 }
3059 impl Clone for NodeAnnouncement {
3060         fn clone(&self) -> Self {
3061                 Self {
3062                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3063                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3064                         is_owned: true,
3065                 }
3066         }
3067 }
3068 #[allow(unused)]
3069 /// Used only if an object of this type is returned as a trait impl by a method
3070 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3071         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3072 }
3073 #[no_mangle]
3074 /// Creates a copy of the NodeAnnouncement
3075 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3076         orig.clone()
3077 }
3078
3079 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3080 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3081
3082 /// The unsigned part of a channel_announcement
3083 #[must_use]
3084 #[repr(C)]
3085 pub struct UnsignedChannelAnnouncement {
3086         /// A pointer to the opaque Rust object.
3087
3088         /// Nearly everywhere, inner must be non-null, however in places where
3089         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3090         pub inner: *mut nativeUnsignedChannelAnnouncement,
3091         /// Indicates that this is the only struct which contains the same pointer.
3092
3093         /// Rust functions which take ownership of an object provided via an argument require
3094         /// this to be true and invalidate the object pointed to by inner.
3095         pub is_owned: bool,
3096 }
3097
3098 impl Drop for UnsignedChannelAnnouncement {
3099         fn drop(&mut self) {
3100                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3101                         let _ = unsafe { Box::from_raw(self.inner) };
3102                 }
3103         }
3104 }
3105 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3106 #[no_mangle]
3107 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3108 #[allow(unused)]
3109 /// Used only if an object of this type is returned as a trait impl by a method
3110 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3111         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3112 }
3113 #[allow(unused)]
3114 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3115 impl UnsignedChannelAnnouncement {
3116         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3117                 assert!(self.is_owned);
3118                 let ret = self.inner;
3119                 self.inner = std::ptr::null_mut();
3120                 ret
3121         }
3122 }
3123 /// The advertised channel features
3124 #[no_mangle]
3125 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3126         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
3127         crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
3128 }
3129 /// The advertised channel features
3130 #[no_mangle]
3131 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3132         unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
3133 }
3134 /// The genesis hash of the blockchain where the channel is to be opened
3135 #[no_mangle]
3136 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3137         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3138         inner_val.as_inner()
3139 }
3140 /// The genesis hash of the blockchain where the channel is to be opened
3141 #[no_mangle]
3142 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3143         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3144 }
3145 /// The short channel ID
3146 #[no_mangle]
3147 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3148         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
3149         *inner_val
3150 }
3151 /// The short channel ID
3152 #[no_mangle]
3153 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3154         unsafe { &mut *this_ptr.inner }.short_channel_id = val;
3155 }
3156 /// One of the two node_ids which are endpoints of this channel
3157 #[no_mangle]
3158 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3159         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1;
3160         crate::c_types::PublicKey::from_rust(&inner_val)
3161 }
3162 /// One of the two node_ids which are endpoints of this channel
3163 #[no_mangle]
3164 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3165         unsafe { &mut *this_ptr.inner }.node_id_1 = val.into_rust();
3166 }
3167 /// The other of the two node_ids which are endpoints of this channel
3168 #[no_mangle]
3169 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3170         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2;
3171         crate::c_types::PublicKey::from_rust(&inner_val)
3172 }
3173 /// The other of the two node_ids which are endpoints of this channel
3174 #[no_mangle]
3175 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3176         unsafe { &mut *this_ptr.inner }.node_id_2 = val.into_rust();
3177 }
3178 /// The funding key for the first node
3179 #[no_mangle]
3180 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3181         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1;
3182         crate::c_types::PublicKey::from_rust(&inner_val)
3183 }
3184 /// The funding key for the first node
3185 #[no_mangle]
3186 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3187         unsafe { &mut *this_ptr.inner }.bitcoin_key_1 = val.into_rust();
3188 }
3189 /// The funding key for the second node
3190 #[no_mangle]
3191 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3192         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2;
3193         crate::c_types::PublicKey::from_rust(&inner_val)
3194 }
3195 /// The funding key for the second node
3196 #[no_mangle]
3197 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3198         unsafe { &mut *this_ptr.inner }.bitcoin_key_2 = val.into_rust();
3199 }
3200 impl Clone for UnsignedChannelAnnouncement {
3201         fn clone(&self) -> Self {
3202                 Self {
3203                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3204                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3205                         is_owned: true,
3206                 }
3207         }
3208 }
3209 #[allow(unused)]
3210 /// Used only if an object of this type is returned as a trait impl by a method
3211 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3212         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3213 }
3214 #[no_mangle]
3215 /// Creates a copy of the UnsignedChannelAnnouncement
3216 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3217         orig.clone()
3218 }
3219
3220 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3221 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3222
3223 /// A channel_announcement message to be sent or received from a peer
3224 #[must_use]
3225 #[repr(C)]
3226 pub struct ChannelAnnouncement {
3227         /// A pointer to the opaque Rust object.
3228
3229         /// Nearly everywhere, inner must be non-null, however in places where
3230         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3231         pub inner: *mut nativeChannelAnnouncement,
3232         /// Indicates that this is the only struct which contains the same pointer.
3233
3234         /// Rust functions which take ownership of an object provided via an argument require
3235         /// this to be true and invalidate the object pointed to by inner.
3236         pub is_owned: bool,
3237 }
3238
3239 impl Drop for ChannelAnnouncement {
3240         fn drop(&mut self) {
3241                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3242                         let _ = unsafe { Box::from_raw(self.inner) };
3243                 }
3244         }
3245 }
3246 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3247 #[no_mangle]
3248 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3249 #[allow(unused)]
3250 /// Used only if an object of this type is returned as a trait impl by a method
3251 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3252         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3253 }
3254 #[allow(unused)]
3255 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3256 impl ChannelAnnouncement {
3257         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3258                 assert!(self.is_owned);
3259                 let ret = self.inner;
3260                 self.inner = std::ptr::null_mut();
3261                 ret
3262         }
3263 }
3264 /// Authentication of the announcement by the first public node
3265 #[no_mangle]
3266 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3267         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1;
3268         crate::c_types::Signature::from_rust(&inner_val)
3269 }
3270 /// Authentication of the announcement by the first public node
3271 #[no_mangle]
3272 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3273         unsafe { &mut *this_ptr.inner }.node_signature_1 = val.into_rust();
3274 }
3275 /// Authentication of the announcement by the second public node
3276 #[no_mangle]
3277 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3278         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2;
3279         crate::c_types::Signature::from_rust(&inner_val)
3280 }
3281 /// Authentication of the announcement by the second public node
3282 #[no_mangle]
3283 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3284         unsafe { &mut *this_ptr.inner }.node_signature_2 = val.into_rust();
3285 }
3286 /// Proof of funding UTXO ownership by the first public node
3287 #[no_mangle]
3288 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3289         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1;
3290         crate::c_types::Signature::from_rust(&inner_val)
3291 }
3292 /// Proof of funding UTXO ownership by the first public node
3293 #[no_mangle]
3294 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3295         unsafe { &mut *this_ptr.inner }.bitcoin_signature_1 = val.into_rust();
3296 }
3297 /// Proof of funding UTXO ownership by the second public node
3298 #[no_mangle]
3299 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3300         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2;
3301         crate::c_types::Signature::from_rust(&inner_val)
3302 }
3303 /// Proof of funding UTXO ownership by the second public node
3304 #[no_mangle]
3305 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3306         unsafe { &mut *this_ptr.inner }.bitcoin_signature_2 = val.into_rust();
3307 }
3308 /// The actual announcement
3309 #[no_mangle]
3310 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3311         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
3312         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
3313 }
3314 /// The actual announcement
3315 #[no_mangle]
3316 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3317         unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3318 }
3319 /// Constructs a new ChannelAnnouncement given each field
3320 #[must_use]
3321 #[no_mangle]
3322 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 {
3323         ChannelAnnouncement { inner: Box::into_raw(Box::new(nativeChannelAnnouncement {
3324                 node_signature_1: node_signature_1_arg.into_rust(),
3325                 node_signature_2: node_signature_2_arg.into_rust(),
3326                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3327                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3328                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3329         })), is_owned: true }
3330 }
3331 impl Clone for ChannelAnnouncement {
3332         fn clone(&self) -> Self {
3333                 Self {
3334                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3335                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3336                         is_owned: true,
3337                 }
3338         }
3339 }
3340 #[allow(unused)]
3341 /// Used only if an object of this type is returned as a trait impl by a method
3342 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3343         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3344 }
3345 #[no_mangle]
3346 /// Creates a copy of the ChannelAnnouncement
3347 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3348         orig.clone()
3349 }
3350
3351 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3352 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3353
3354 /// The unsigned part of a channel_update
3355 #[must_use]
3356 #[repr(C)]
3357 pub struct UnsignedChannelUpdate {
3358         /// A pointer to the opaque Rust object.
3359
3360         /// Nearly everywhere, inner must be non-null, however in places where
3361         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3362         pub inner: *mut nativeUnsignedChannelUpdate,
3363         /// Indicates that this is the only struct which contains the same pointer.
3364
3365         /// Rust functions which take ownership of an object provided via an argument require
3366         /// this to be true and invalidate the object pointed to by inner.
3367         pub is_owned: bool,
3368 }
3369
3370 impl Drop for UnsignedChannelUpdate {
3371         fn drop(&mut self) {
3372                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3373                         let _ = unsafe { Box::from_raw(self.inner) };
3374                 }
3375         }
3376 }
3377 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3378 #[no_mangle]
3379 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3380 #[allow(unused)]
3381 /// Used only if an object of this type is returned as a trait impl by a method
3382 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3383         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3384 }
3385 #[allow(unused)]
3386 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3387 impl UnsignedChannelUpdate {
3388         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3389                 assert!(self.is_owned);
3390                 let ret = self.inner;
3391                 self.inner = std::ptr::null_mut();
3392                 ret
3393         }
3394 }
3395 /// The genesis hash of the blockchain where the channel is to be opened
3396 #[no_mangle]
3397 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3398         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3399         inner_val.as_inner()
3400 }
3401 /// The genesis hash of the blockchain where the channel is to be opened
3402 #[no_mangle]
3403 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3404         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3405 }
3406 /// The short channel ID
3407 #[no_mangle]
3408 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3409         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
3410         *inner_val
3411 }
3412 /// The short channel ID
3413 #[no_mangle]
3414 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3415         unsafe { &mut *this_ptr.inner }.short_channel_id = val;
3416 }
3417 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3418 #[no_mangle]
3419 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3420         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
3421         *inner_val
3422 }
3423 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3424 #[no_mangle]
3425 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3426         unsafe { &mut *this_ptr.inner }.timestamp = val;
3427 }
3428 /// Channel flags
3429 #[no_mangle]
3430 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3431         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags;
3432         *inner_val
3433 }
3434 /// Channel flags
3435 #[no_mangle]
3436 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3437         unsafe { &mut *this_ptr.inner }.flags = val;
3438 }
3439 /// The number of blocks such that if:
3440 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3441 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3442 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3443 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3444 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3445 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3446 /// constructing the route.
3447 #[no_mangle]
3448 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3449         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
3450         *inner_val
3451 }
3452 /// The number of blocks such that if:
3453 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3454 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3455 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3456 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3457 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3458 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3459 /// constructing the route.
3460 #[no_mangle]
3461 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3462         unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
3463 }
3464 /// The minimum HTLC size incoming to sender, in milli-satoshi
3465 #[no_mangle]
3466 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3467         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
3468         *inner_val
3469 }
3470 /// The minimum HTLC size incoming to sender, in milli-satoshi
3471 #[no_mangle]
3472 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3473         unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
3474 }
3475 /// The base HTLC fee charged by sender, in milli-satoshi
3476 #[no_mangle]
3477 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3478         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat;
3479         *inner_val
3480 }
3481 /// The base HTLC fee charged by sender, in milli-satoshi
3482 #[no_mangle]
3483 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3484         unsafe { &mut *this_ptr.inner }.fee_base_msat = val;
3485 }
3486 /// The amount to fee multiplier, in micro-satoshi
3487 #[no_mangle]
3488 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3489         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
3490         *inner_val
3491 }
3492 /// The amount to fee multiplier, in micro-satoshi
3493 #[no_mangle]
3494 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3495         unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
3496 }
3497 impl Clone for UnsignedChannelUpdate {
3498         fn clone(&self) -> Self {
3499                 Self {
3500                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3501                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3502                         is_owned: true,
3503                 }
3504         }
3505 }
3506 #[allow(unused)]
3507 /// Used only if an object of this type is returned as a trait impl by a method
3508 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3509         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3510 }
3511 #[no_mangle]
3512 /// Creates a copy of the UnsignedChannelUpdate
3513 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3514         orig.clone()
3515 }
3516
3517 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3518 type nativeChannelUpdate = nativeChannelUpdateImport;
3519
3520 /// A channel_update message to be sent or received from a peer
3521 #[must_use]
3522 #[repr(C)]
3523 pub struct ChannelUpdate {
3524         /// A pointer to the opaque Rust object.
3525
3526         /// Nearly everywhere, inner must be non-null, however in places where
3527         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3528         pub inner: *mut nativeChannelUpdate,
3529         /// Indicates that this is the only struct which contains the same pointer.
3530
3531         /// Rust functions which take ownership of an object provided via an argument require
3532         /// this to be true and invalidate the object pointed to by inner.
3533         pub is_owned: bool,
3534 }
3535
3536 impl Drop for ChannelUpdate {
3537         fn drop(&mut self) {
3538                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
3539                         let _ = unsafe { Box::from_raw(self.inner) };
3540                 }
3541         }
3542 }
3543 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
3544 #[no_mangle]
3545 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
3546 #[allow(unused)]
3547 /// Used only if an object of this type is returned as a trait impl by a method
3548 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3549         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3550 }
3551 #[allow(unused)]
3552 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3553 impl ChannelUpdate {
3554         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3555                 assert!(self.is_owned);
3556                 let ret = self.inner;
3557                 self.inner = std::ptr::null_mut();
3558                 ret
3559         }
3560 }
3561 /// A signature of the channel update
3562 #[no_mangle]
3563 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3564         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
3565         crate::c_types::Signature::from_rust(&inner_val)
3566 }
3567 /// A signature of the channel update
3568 #[no_mangle]
3569 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3570         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
3571 }
3572 /// The actual channel update
3573 #[no_mangle]
3574 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
3575         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
3576         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
3577 }
3578 /// The actual channel update
3579 #[no_mangle]
3580 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
3581         unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3582 }
3583 /// Constructs a new ChannelUpdate given each field
3584 #[must_use]
3585 #[no_mangle]
3586 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3587         ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate {
3588                 signature: signature_arg.into_rust(),
3589                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3590         })), is_owned: true }
3591 }
3592 impl Clone for ChannelUpdate {
3593         fn clone(&self) -> Self {
3594                 Self {
3595                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3596                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3597                         is_owned: true,
3598                 }
3599         }
3600 }
3601 #[allow(unused)]
3602 /// Used only if an object of this type is returned as a trait impl by a method
3603 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3604         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3605 }
3606 #[no_mangle]
3607 /// Creates a copy of the ChannelUpdate
3608 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3609         orig.clone()
3610 }
3611
3612 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3613 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3614
3615 /// A query_channel_range message is used to query a peer for channel
3616 /// UTXOs in a range of blocks. The recipient of a query makes a best
3617 /// effort to reply to the query using one or more reply_channel_range
3618 /// messages.
3619 #[must_use]
3620 #[repr(C)]
3621 pub struct QueryChannelRange {
3622         /// A pointer to the opaque Rust object.
3623
3624         /// Nearly everywhere, inner must be non-null, however in places where
3625         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3626         pub inner: *mut nativeQueryChannelRange,
3627         /// Indicates that this is the only struct which contains the same pointer.
3628
3629         /// Rust functions which take ownership of an object provided via an argument require
3630         /// this to be true and invalidate the object pointed to by inner.
3631         pub is_owned: bool,
3632 }
3633
3634 impl Drop for QueryChannelRange {
3635         fn drop(&mut self) {
3636                 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
3637                         let _ = unsafe { Box::from_raw(self.inner) };
3638                 }
3639         }
3640 }
3641 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
3642 #[no_mangle]
3643 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
3644 #[allow(unused)]
3645 /// Used only if an object of this type is returned as a trait impl by a method
3646 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3647         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3648 }
3649 #[allow(unused)]
3650 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3651 impl QueryChannelRange {
3652         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3653                 assert!(self.is_owned);
3654                 let ret = self.inner;
3655                 self.inner = std::ptr::null_mut();
3656                 ret
3657         }
3658 }
3659 /// The genesis hash of the blockchain being queried
3660 #[no_mangle]
3661 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3662         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3663         inner_val.as_inner()
3664 }
3665 /// The genesis hash of the blockchain being queried
3666 #[no_mangle]
3667 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3668         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3669 }
3670 /// The height of the first block for the channel UTXOs being queried
3671 #[no_mangle]
3672 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3673         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3674         *inner_val
3675 }
3676 /// The height of the first block for the channel UTXOs being queried
3677 #[no_mangle]
3678 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3679         unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3680 }
3681 /// The number of blocks to include in the query results
3682 #[no_mangle]
3683 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3684         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3685         *inner_val
3686 }
3687 /// The number of blocks to include in the query results
3688 #[no_mangle]
3689 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3690         unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3691 }
3692 /// Constructs a new QueryChannelRange given each field
3693 #[must_use]
3694 #[no_mangle]
3695 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 {
3696         QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange {
3697                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3698                 first_blocknum: first_blocknum_arg,
3699                 number_of_blocks: number_of_blocks_arg,
3700         })), is_owned: true }
3701 }
3702 impl Clone for QueryChannelRange {
3703         fn clone(&self) -> Self {
3704                 Self {
3705                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
3706                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3707                         is_owned: true,
3708                 }
3709         }
3710 }
3711 #[allow(unused)]
3712 /// Used only if an object of this type is returned as a trait impl by a method
3713 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3714         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3715 }
3716 #[no_mangle]
3717 /// Creates a copy of the QueryChannelRange
3718 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3719         orig.clone()
3720 }
3721
3722 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3723 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3724
3725 /// A reply_channel_range message is a reply to a query_channel_range
3726 /// message. Multiple reply_channel_range messages can be sent in reply
3727 /// to a single query_channel_range message. The query recipient makes a
3728 /// best effort to respond based on their local network view which may
3729 /// not be a perfect view of the network. The short_channel_ids in the
3730 /// reply are encoded. We only support encoding_type=0 uncompressed
3731 /// serialization and do not support encoding_type=1 zlib serialization.
3732 #[must_use]
3733 #[repr(C)]
3734 pub struct ReplyChannelRange {
3735         /// A pointer to the opaque Rust object.
3736
3737         /// Nearly everywhere, inner must be non-null, however in places where
3738         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3739         pub inner: *mut nativeReplyChannelRange,
3740         /// Indicates that this is the only struct which contains the same pointer.
3741
3742         /// Rust functions which take ownership of an object provided via an argument require
3743         /// this to be true and invalidate the object pointed to by inner.
3744         pub is_owned: bool,
3745 }
3746
3747 impl Drop for ReplyChannelRange {
3748         fn drop(&mut self) {
3749                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
3750                         let _ = unsafe { Box::from_raw(self.inner) };
3751                 }
3752         }
3753 }
3754 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
3755 #[no_mangle]
3756 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
3757 #[allow(unused)]
3758 /// Used only if an object of this type is returned as a trait impl by a method
3759 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3760         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3761 }
3762 #[allow(unused)]
3763 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3764 impl ReplyChannelRange {
3765         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3766                 assert!(self.is_owned);
3767                 let ret = self.inner;
3768                 self.inner = std::ptr::null_mut();
3769                 ret
3770         }
3771 }
3772 /// The genesis hash of the blockchain being queried
3773 #[no_mangle]
3774 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3775         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3776         inner_val.as_inner()
3777 }
3778 /// The genesis hash of the blockchain being queried
3779 #[no_mangle]
3780 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3781         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3782 }
3783 /// The height of the first block in the range of the reply
3784 #[no_mangle]
3785 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3786         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3787         *inner_val
3788 }
3789 /// The height of the first block in the range of the reply
3790 #[no_mangle]
3791 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3792         unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3793 }
3794 /// The number of blocks included in the range of the reply
3795 #[no_mangle]
3796 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3797         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3798         *inner_val
3799 }
3800 /// The number of blocks included in the range of the reply
3801 #[no_mangle]
3802 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3803         unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3804 }
3805 /// True when this is the final reply for a query
3806 #[no_mangle]
3807 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
3808         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.sync_complete;
3809         *inner_val
3810 }
3811 /// True when this is the final reply for a query
3812 #[no_mangle]
3813 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
3814         unsafe { &mut *this_ptr.inner }.sync_complete = val;
3815 }
3816 /// The short_channel_ids in the channel range
3817 #[no_mangle]
3818 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
3819         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3820         unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3821 }
3822 /// Constructs a new ReplyChannelRange given each field
3823 #[must_use]
3824 #[no_mangle]
3825 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 {
3826         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 }); };
3827         ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange {
3828                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3829                 first_blocknum: first_blocknum_arg,
3830                 number_of_blocks: number_of_blocks_arg,
3831                 sync_complete: sync_complete_arg,
3832                 short_channel_ids: local_short_channel_ids_arg,
3833         })), is_owned: true }
3834 }
3835 impl Clone for ReplyChannelRange {
3836         fn clone(&self) -> Self {
3837                 Self {
3838                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
3839                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3840                         is_owned: true,
3841                 }
3842         }
3843 }
3844 #[allow(unused)]
3845 /// Used only if an object of this type is returned as a trait impl by a method
3846 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3847         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
3848 }
3849 #[no_mangle]
3850 /// Creates a copy of the ReplyChannelRange
3851 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
3852         orig.clone()
3853 }
3854
3855 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
3856 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
3857
3858 /// A query_short_channel_ids message is used to query a peer for
3859 /// routing gossip messages related to one or more short_channel_ids.
3860 /// The query recipient will reply with the latest, if available,
3861 /// channel_announcement, channel_update and node_announcement messages
3862 /// it maintains for the requested short_channel_ids followed by a
3863 /// reply_short_channel_ids_end message. The short_channel_ids sent in
3864 /// this query are encoded. We only support encoding_type=0 uncompressed
3865 /// serialization and do not support encoding_type=1 zlib serialization.
3866 #[must_use]
3867 #[repr(C)]
3868 pub struct QueryShortChannelIds {
3869         /// A pointer to the opaque Rust object.
3870
3871         /// Nearly everywhere, inner must be non-null, however in places where
3872         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3873         pub inner: *mut nativeQueryShortChannelIds,
3874         /// Indicates that this is the only struct which contains the same pointer.
3875
3876         /// Rust functions which take ownership of an object provided via an argument require
3877         /// this to be true and invalidate the object pointed to by inner.
3878         pub is_owned: bool,
3879 }
3880
3881 impl Drop for QueryShortChannelIds {
3882         fn drop(&mut self) {
3883                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
3884                         let _ = unsafe { Box::from_raw(self.inner) };
3885                 }
3886         }
3887 }
3888 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
3889 #[no_mangle]
3890 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
3891 #[allow(unused)]
3892 /// Used only if an object of this type is returned as a trait impl by a method
3893 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
3894         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
3895 }
3896 #[allow(unused)]
3897 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3898 impl QueryShortChannelIds {
3899         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
3900                 assert!(self.is_owned);
3901                 let ret = self.inner;
3902                 self.inner = std::ptr::null_mut();
3903                 ret
3904         }
3905 }
3906 /// The genesis hash of the blockchain being queried
3907 #[no_mangle]
3908 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
3909         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3910         inner_val.as_inner()
3911 }
3912 /// The genesis hash of the blockchain being queried
3913 #[no_mangle]
3914 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
3915         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3916 }
3917 /// The short_channel_ids that are being queried
3918 #[no_mangle]
3919 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
3920         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3921         unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3922 }
3923 /// Constructs a new QueryShortChannelIds given each field
3924 #[must_use]
3925 #[no_mangle]
3926 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 {
3927         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 }); };
3928         QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds {
3929                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3930                 short_channel_ids: local_short_channel_ids_arg,
3931         })), is_owned: true }
3932 }
3933 impl Clone for QueryShortChannelIds {
3934         fn clone(&self) -> Self {
3935                 Self {
3936                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else {
3937                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3938                         is_owned: true,
3939                 }
3940         }
3941 }
3942 #[allow(unused)]
3943 /// Used only if an object of this type is returned as a trait impl by a method
3944 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
3945         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
3946 }
3947 #[no_mangle]
3948 /// Creates a copy of the QueryShortChannelIds
3949 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
3950         orig.clone()
3951 }
3952
3953 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
3954 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
3955
3956 /// A reply_short_channel_ids_end message is sent as a reply to a
3957 /// query_short_channel_ids message. The query recipient makes a best
3958 /// effort to respond based on their local network view which may not be
3959 /// a perfect view of the network.
3960 #[must_use]
3961 #[repr(C)]
3962 pub struct ReplyShortChannelIdsEnd {
3963         /// A pointer to the opaque Rust object.
3964
3965         /// Nearly everywhere, inner must be non-null, however in places where
3966         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3967         pub inner: *mut nativeReplyShortChannelIdsEnd,
3968         /// Indicates that this is the only struct which contains the same pointer.
3969
3970         /// Rust functions which take ownership of an object provided via an argument require
3971         /// this to be true and invalidate the object pointed to by inner.
3972         pub is_owned: bool,
3973 }
3974
3975 impl Drop for ReplyShortChannelIdsEnd {
3976         fn drop(&mut self) {
3977                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
3978                         let _ = unsafe { Box::from_raw(self.inner) };
3979                 }
3980         }
3981 }
3982 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
3983 #[no_mangle]
3984 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
3985 #[allow(unused)]
3986 /// Used only if an object of this type is returned as a trait impl by a method
3987 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
3988         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
3989 }
3990 #[allow(unused)]
3991 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3992 impl ReplyShortChannelIdsEnd {
3993         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
3994                 assert!(self.is_owned);
3995                 let ret = self.inner;
3996                 self.inner = std::ptr::null_mut();
3997                 ret
3998         }
3999 }
4000 /// The genesis hash of the blockchain that was queried
4001 #[no_mangle]
4002 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4003         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
4004         inner_val.as_inner()
4005 }
4006 /// The genesis hash of the blockchain that was queried
4007 #[no_mangle]
4008 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4009         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4010 }
4011 /// Indicates if the query recipient maintains up-to-date channel
4012 /// information for the chain_hash
4013 #[no_mangle]
4014 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4015         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
4016         *inner_val
4017 }
4018 /// Indicates if the query recipient maintains up-to-date channel
4019 /// information for the chain_hash
4020 #[no_mangle]
4021 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4022         unsafe { &mut *this_ptr.inner }.full_information = val;
4023 }
4024 /// Constructs a new ReplyShortChannelIdsEnd given each field
4025 #[must_use]
4026 #[no_mangle]
4027 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4028         ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd {
4029                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4030                 full_information: full_information_arg,
4031         })), is_owned: true }
4032 }
4033 impl Clone for ReplyShortChannelIdsEnd {
4034         fn clone(&self) -> Self {
4035                 Self {
4036                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else {
4037                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
4038                         is_owned: true,
4039                 }
4040         }
4041 }
4042 #[allow(unused)]
4043 /// Used only if an object of this type is returned as a trait impl by a method
4044 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
4045         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
4046 }
4047 #[no_mangle]
4048 /// Creates a copy of the ReplyShortChannelIdsEnd
4049 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
4050         orig.clone()
4051 }
4052
4053 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
4054 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
4055
4056 /// A gossip_timestamp_filter message is used by a node to request
4057 /// gossip relay for messages in the requested time range when the
4058 /// gossip_queries feature has been negotiated.
4059 #[must_use]
4060 #[repr(C)]
4061 pub struct GossipTimestampFilter {
4062         /// A pointer to the opaque Rust object.
4063
4064         /// Nearly everywhere, inner must be non-null, however in places where
4065         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4066         pub inner: *mut nativeGossipTimestampFilter,
4067         /// Indicates that this is the only struct which contains the same pointer.
4068
4069         /// Rust functions which take ownership of an object provided via an argument require
4070         /// this to be true and invalidate the object pointed to by inner.
4071         pub is_owned: bool,
4072 }
4073
4074 impl Drop for GossipTimestampFilter {
4075         fn drop(&mut self) {
4076                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
4077                         let _ = unsafe { Box::from_raw(self.inner) };
4078                 }
4079         }
4080 }
4081 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
4082 #[no_mangle]
4083 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
4084 #[allow(unused)]
4085 /// Used only if an object of this type is returned as a trait impl by a method
4086 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
4087         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
4088 }
4089 #[allow(unused)]
4090 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4091 impl GossipTimestampFilter {
4092         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
4093                 assert!(self.is_owned);
4094                 let ret = self.inner;
4095                 self.inner = std::ptr::null_mut();
4096                 ret
4097         }
4098 }
4099 /// The genesis hash of the blockchain for channel and node information
4100 #[no_mangle]
4101 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
4102         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
4103         inner_val.as_inner()
4104 }
4105 /// The genesis hash of the blockchain for channel and node information
4106 #[no_mangle]
4107 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
4108         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4109 }
4110 /// The starting unix timestamp
4111 #[no_mangle]
4112 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
4113         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp;
4114         *inner_val
4115 }
4116 /// The starting unix timestamp
4117 #[no_mangle]
4118 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4119         unsafe { &mut *this_ptr.inner }.first_timestamp = val;
4120 }
4121 /// The range of information in seconds
4122 #[no_mangle]
4123 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
4124         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range;
4125         *inner_val
4126 }
4127 /// The range of information in seconds
4128 #[no_mangle]
4129 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4130         unsafe { &mut *this_ptr.inner }.timestamp_range = val;
4131 }
4132 /// Constructs a new GossipTimestampFilter given each field
4133 #[must_use]
4134 #[no_mangle]
4135 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 {
4136         GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter {
4137                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4138                 first_timestamp: first_timestamp_arg,
4139                 timestamp_range: timestamp_range_arg,
4140         })), is_owned: true }
4141 }
4142 impl Clone for GossipTimestampFilter {
4143         fn clone(&self) -> Self {
4144                 Self {
4145                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else {
4146                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
4147                         is_owned: true,
4148                 }
4149         }
4150 }
4151 #[allow(unused)]
4152 /// Used only if an object of this type is returned as a trait impl by a method
4153 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
4154         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
4155 }
4156 #[no_mangle]
4157 /// Creates a copy of the GossipTimestampFilter
4158 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4159         orig.clone()
4160 }
4161 /// Used to put an error message in a LightningError
4162 #[must_use]
4163 #[derive(Clone)]
4164 #[repr(C)]
4165 pub enum ErrorAction {
4166         /// The peer took some action which made us think they were useless. Disconnect them.
4167         DisconnectPeer {
4168                 /// An error message which we should make an effort to send before we disconnect.
4169                 ///
4170                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4171                 msg: crate::lightning::ln::msgs::ErrorMessage,
4172         },
4173         /// The peer did something harmless that we weren't able to process, just log and ignore
4174         IgnoreError,
4175         /// The peer did something harmless that we weren't able to meaningfully process.
4176         /// If the error is logged, log it at the given level.
4177         IgnoreAndLog(crate::lightning::util::logger::Level),
4178         /// The peer did something incorrect. Tell them.
4179         SendErrorMessage {
4180                 /// The message to send.
4181                 msg: crate::lightning::ln::msgs::ErrorMessage,
4182         },
4183 }
4184 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
4185 impl ErrorAction {
4186         #[allow(unused)]
4187         pub(crate) fn to_native(&self) -> nativeErrorAction {
4188                 match self {
4189                         ErrorAction::DisconnectPeer {ref msg, } => {
4190                                 let mut msg_nonref = (*msg).clone();
4191                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4192                                 nativeErrorAction::DisconnectPeer {
4193                                         msg: local_msg_nonref,
4194                                 }
4195                         },
4196                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4197                         ErrorAction::IgnoreAndLog (ref a, ) => {
4198                                 let mut a_nonref = (*a).clone();
4199                                 nativeErrorAction::IgnoreAndLog (
4200                                         a_nonref.into_native(),
4201                                 )
4202                         },
4203                         ErrorAction::SendErrorMessage {ref msg, } => {
4204                                 let mut msg_nonref = (*msg).clone();
4205                                 nativeErrorAction::SendErrorMessage {
4206                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4207                                 }
4208                         },
4209                 }
4210         }
4211         #[allow(unused)]
4212         pub(crate) fn into_native(self) -> nativeErrorAction {
4213                 match self {
4214                         ErrorAction::DisconnectPeer {mut msg, } => {
4215                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4216                                 nativeErrorAction::DisconnectPeer {
4217                                         msg: local_msg,
4218                                 }
4219                         },
4220                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4221                         ErrorAction::IgnoreAndLog (mut a, ) => {
4222                                 nativeErrorAction::IgnoreAndLog (
4223                                         a.into_native(),
4224                                 )
4225                         },
4226                         ErrorAction::SendErrorMessage {mut msg, } => {
4227                                 nativeErrorAction::SendErrorMessage {
4228                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
4229                                 }
4230                         },
4231                 }
4232         }
4233         #[allow(unused)]
4234         pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4235                 match native {
4236                         nativeErrorAction::DisconnectPeer {ref msg, } => {
4237                                 let mut msg_nonref = (*msg).clone();
4238                                 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 };
4239                                 ErrorAction::DisconnectPeer {
4240                                         msg: local_msg_nonref,
4241                                 }
4242                         },
4243                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4244                         nativeErrorAction::IgnoreAndLog (ref a, ) => {
4245                                 let mut a_nonref = (*a).clone();
4246                                 ErrorAction::IgnoreAndLog (
4247                                         crate::lightning::util::logger::Level::native_into(a_nonref),
4248                                 )
4249                         },
4250                         nativeErrorAction::SendErrorMessage {ref msg, } => {
4251                                 let mut msg_nonref = (*msg).clone();
4252                                 ErrorAction::SendErrorMessage {
4253                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
4254                                 }
4255                         },
4256                 }
4257         }
4258         #[allow(unused)]
4259         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4260                 match native {
4261                         nativeErrorAction::DisconnectPeer {mut msg, } => {
4262                                 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 };
4263                                 ErrorAction::DisconnectPeer {
4264                                         msg: local_msg,
4265                                 }
4266                         },
4267                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4268                         nativeErrorAction::IgnoreAndLog (mut a, ) => {
4269                                 ErrorAction::IgnoreAndLog (
4270                                         crate::lightning::util::logger::Level::native_into(a),
4271                                 )
4272                         },
4273                         nativeErrorAction::SendErrorMessage {mut msg, } => {
4274                                 ErrorAction::SendErrorMessage {
4275                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
4276                                 }
4277                         },
4278                 }
4279         }
4280 }
4281 /// Frees any resources used by the ErrorAction
4282 #[no_mangle]
4283 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4284 /// Creates a copy of the ErrorAction
4285 #[no_mangle]
4286 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4287         orig.clone()
4288 }
4289 #[no_mangle]
4290 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
4291 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4292         ErrorAction::DisconnectPeer {
4293                 msg,
4294         }
4295 }
4296 #[no_mangle]
4297 /// Utility method to constructs a new IgnoreError-variant ErrorAction
4298 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
4299         ErrorAction::IgnoreError}
4300 #[no_mangle]
4301 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
4302 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
4303         ErrorAction::IgnoreAndLog(a, )
4304 }
4305 #[no_mangle]
4306 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
4307 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4308         ErrorAction::SendErrorMessage {
4309                 msg,
4310         }
4311 }
4312
4313 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4314 type nativeLightningError = nativeLightningErrorImport;
4315
4316 /// An Err type for failure to process messages.
4317 #[must_use]
4318 #[repr(C)]
4319 pub struct LightningError {
4320         /// A pointer to the opaque Rust object.
4321
4322         /// Nearly everywhere, inner must be non-null, however in places where
4323         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4324         pub inner: *mut nativeLightningError,
4325         /// Indicates that this is the only struct which contains the same pointer.
4326
4327         /// Rust functions which take ownership of an object provided via an argument require
4328         /// this to be true and invalidate the object pointed to by inner.
4329         pub is_owned: bool,
4330 }
4331
4332 impl Drop for LightningError {
4333         fn drop(&mut self) {
4334                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4335                         let _ = unsafe { Box::from_raw(self.inner) };
4336                 }
4337         }
4338 }
4339 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
4340 #[no_mangle]
4341 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
4342 #[allow(unused)]
4343 /// Used only if an object of this type is returned as a trait impl by a method
4344 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
4345         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
4346 }
4347 #[allow(unused)]
4348 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4349 impl LightningError {
4350         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
4351                 assert!(self.is_owned);
4352                 let ret = self.inner;
4353                 self.inner = std::ptr::null_mut();
4354                 ret
4355         }
4356 }
4357 /// A human-readable message describing the error
4358 #[no_mangle]
4359 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
4360         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
4361         inner_val.as_str().into()
4362 }
4363 /// A human-readable message describing the error
4364 #[no_mangle]
4365 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
4366         unsafe { &mut *this_ptr.inner }.err = val.into_string();
4367 }
4368 /// The action which should be taken against the offending peer.
4369 #[no_mangle]
4370 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
4371         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
4372         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
4373 }
4374 /// The action which should be taken against the offending peer.
4375 #[no_mangle]
4376 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
4377         unsafe { &mut *this_ptr.inner }.action = val.into_native();
4378 }
4379 /// Constructs a new LightningError given each field
4380 #[must_use]
4381 #[no_mangle]
4382 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
4383         LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
4384                 err: err_arg.into_string(),
4385                 action: action_arg.into_native(),
4386         })), is_owned: true }
4387 }
4388 impl Clone for LightningError {
4389         fn clone(&self) -> Self {
4390                 Self {
4391                         inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else {
4392                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
4393                         is_owned: true,
4394                 }
4395         }
4396 }
4397 #[allow(unused)]
4398 /// Used only if an object of this type is returned as a trait impl by a method
4399 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
4400         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
4401 }
4402 #[no_mangle]
4403 /// Creates a copy of the LightningError
4404 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
4405         orig.clone()
4406 }
4407
4408 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
4409 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
4410
4411 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
4412 /// transaction updates if they were pending.
4413 #[must_use]
4414 #[repr(C)]
4415 pub struct CommitmentUpdate {
4416         /// A pointer to the opaque Rust object.
4417
4418         /// Nearly everywhere, inner must be non-null, however in places where
4419         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4420         pub inner: *mut nativeCommitmentUpdate,
4421         /// Indicates that this is the only struct which contains the same pointer.
4422
4423         /// Rust functions which take ownership of an object provided via an argument require
4424         /// this to be true and invalidate the object pointed to by inner.
4425         pub is_owned: bool,
4426 }
4427
4428 impl Drop for CommitmentUpdate {
4429         fn drop(&mut self) {
4430                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
4431                         let _ = unsafe { Box::from_raw(self.inner) };
4432                 }
4433         }
4434 }
4435 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
4436 #[no_mangle]
4437 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
4438 #[allow(unused)]
4439 /// Used only if an object of this type is returned as a trait impl by a method
4440 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
4441         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
4442 }
4443 #[allow(unused)]
4444 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4445 impl CommitmentUpdate {
4446         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
4447                 assert!(self.is_owned);
4448                 let ret = self.inner;
4449                 self.inner = std::ptr::null_mut();
4450                 ret
4451         }
4452 }
4453 /// update_add_htlc messages which should be sent
4454 #[no_mangle]
4455 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
4456         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4457         unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
4458 }
4459 /// update_fulfill_htlc messages which should be sent
4460 #[no_mangle]
4461 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
4462         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4463         unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
4464 }
4465 /// update_fail_htlc messages which should be sent
4466 #[no_mangle]
4467 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
4468         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4469         unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
4470 }
4471 /// update_fail_malformed_htlc messages which should be sent
4472 #[no_mangle]
4473 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
4474         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4475         unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val;
4476 }
4477 /// An update_fee message which should be sent
4478 ///
4479 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4480 #[no_mangle]
4481 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
4482         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
4483         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 };
4484         local_inner_val
4485 }
4486 /// An update_fee message which should be sent
4487 ///
4488 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4489 #[no_mangle]
4490 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
4491         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4492         unsafe { &mut *this_ptr.inner }.update_fee = local_val;
4493 }
4494 /// Finally, the commitment_signed message which should be sent
4495 #[no_mangle]
4496 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
4497         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
4498         crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
4499 }
4500 /// Finally, the commitment_signed message which should be sent
4501 #[no_mangle]
4502 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
4503         unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
4504 }
4505 /// Constructs a new CommitmentUpdate given each field
4506 #[must_use]
4507 #[no_mangle]
4508 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 {
4509         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()) } }); };
4510         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()) } }); };
4511         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()) } }); };
4512         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()) } }); };
4513         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()) } }) };
4514         CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
4515                 update_add_htlcs: local_update_add_htlcs_arg,
4516                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
4517                 update_fail_htlcs: local_update_fail_htlcs_arg,
4518                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
4519                 update_fee: local_update_fee_arg,
4520                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
4521         })), is_owned: true }
4522 }
4523 impl Clone for CommitmentUpdate {
4524         fn clone(&self) -> Self {
4525                 Self {
4526                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
4527                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
4528                         is_owned: true,
4529                 }
4530         }
4531 }
4532 #[allow(unused)]
4533 /// Used only if an object of this type is returned as a trait impl by a method
4534 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4535         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
4536 }
4537 #[no_mangle]
4538 /// Creates a copy of the CommitmentUpdate
4539 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
4540         orig.clone()
4541 }
4542 /// The information we received from a peer along the route of a payment we originated. This is
4543 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
4544 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
4545 #[must_use]
4546 #[derive(Clone)]
4547 #[repr(C)]
4548 pub enum HTLCFailChannelUpdate {
4549         /// We received an error which included a full ChannelUpdate message.
4550         ChannelUpdateMessage {
4551                 /// The unwrapped message we received
4552                 msg: crate::lightning::ln::msgs::ChannelUpdate,
4553         },
4554         /// We received an error which indicated only that a channel has been closed
4555         ChannelClosed {
4556                 /// The short_channel_id which has now closed.
4557                 short_channel_id: u64,
4558                 /// when this true, this channel should be permanently removed from the
4559                 /// consideration. Otherwise, this channel can be restored as new channel_update is received
4560                 is_permanent: bool,
4561         },
4562         /// We received an error which indicated only that a node has failed
4563         NodeFailure {
4564                 /// The node_id that has failed.
4565                 node_id: crate::c_types::PublicKey,
4566                 /// when this true, node should be permanently removed from the
4567                 /// consideration. Otherwise, the channels connected to this node can be
4568                 /// restored as new channel_update is received
4569                 is_permanent: bool,
4570         },
4571 }
4572 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
4573 impl HTLCFailChannelUpdate {
4574         #[allow(unused)]
4575         pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
4576                 match self {
4577                         HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
4578                                 let mut msg_nonref = (*msg).clone();
4579                                 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
4580                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4581                                 }
4582                         },
4583                         HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
4584                                 let mut short_channel_id_nonref = (*short_channel_id).clone();
4585                                 let mut is_permanent_nonref = (*is_permanent).clone();
4586                                 nativeHTLCFailChannelUpdate::ChannelClosed {
4587                                         short_channel_id: short_channel_id_nonref,
4588                                         is_permanent: is_permanent_nonref,
4589                                 }
4590                         },
4591                         HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4592                                 let mut node_id_nonref = (*node_id).clone();
4593                                 let mut is_permanent_nonref = (*is_permanent).clone();
4594                                 nativeHTLCFailChannelUpdate::NodeFailure {
4595                                         node_id: node_id_nonref.into_rust(),
4596                                         is_permanent: is_permanent_nonref,
4597                                 }
4598                         },
4599                 }
4600         }
4601         #[allow(unused)]
4602         pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
4603                 match self {
4604                         HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4605                                 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
4606                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
4607                                 }
4608                         },
4609                         HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4610                                 nativeHTLCFailChannelUpdate::ChannelClosed {
4611                                         short_channel_id: short_channel_id,
4612                                         is_permanent: is_permanent,
4613                                 }
4614                         },
4615                         HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4616                                 nativeHTLCFailChannelUpdate::NodeFailure {
4617                                         node_id: node_id.into_rust(),
4618                                         is_permanent: is_permanent,
4619                                 }
4620                         },
4621                 }
4622         }
4623         #[allow(unused)]
4624         pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
4625                 match native {
4626                         nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
4627                                 let mut msg_nonref = (*msg).clone();
4628                                 HTLCFailChannelUpdate::ChannelUpdateMessage {
4629                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
4630                                 }
4631                         },
4632                         nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
4633                                 let mut short_channel_id_nonref = (*short_channel_id).clone();
4634                                 let mut is_permanent_nonref = (*is_permanent).clone();
4635                                 HTLCFailChannelUpdate::ChannelClosed {
4636                                         short_channel_id: short_channel_id_nonref,
4637                                         is_permanent: is_permanent_nonref,
4638                                 }
4639                         },
4640                         nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4641                                 let mut node_id_nonref = (*node_id).clone();
4642                                 let mut is_permanent_nonref = (*is_permanent).clone();
4643                                 HTLCFailChannelUpdate::NodeFailure {
4644                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
4645                                         is_permanent: is_permanent_nonref,
4646                                 }
4647                         },
4648                 }
4649         }
4650         #[allow(unused)]
4651         pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
4652                 match native {
4653                         nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4654                                 HTLCFailChannelUpdate::ChannelUpdateMessage {
4655                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
4656                                 }
4657                         },
4658                         nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4659                                 HTLCFailChannelUpdate::ChannelClosed {
4660                                         short_channel_id: short_channel_id,
4661                                         is_permanent: is_permanent,
4662                                 }
4663                         },
4664                         nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4665                                 HTLCFailChannelUpdate::NodeFailure {
4666                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
4667                                         is_permanent: is_permanent,
4668                                 }
4669                         },
4670                 }
4671         }
4672 }
4673 /// Frees any resources used by the HTLCFailChannelUpdate
4674 #[no_mangle]
4675 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
4676 /// Creates a copy of the HTLCFailChannelUpdate
4677 #[no_mangle]
4678 pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate {
4679         orig.clone()
4680 }
4681 #[no_mangle]
4682 /// Utility method to constructs a new ChannelUpdateMessage-variant HTLCFailChannelUpdate
4683 pub extern "C" fn HTLCFailChannelUpdate_channel_update_message(msg: crate::lightning::ln::msgs::ChannelUpdate) -> HTLCFailChannelUpdate {
4684         HTLCFailChannelUpdate::ChannelUpdateMessage {
4685                 msg,
4686         }
4687 }
4688 #[no_mangle]
4689 /// Utility method to constructs a new ChannelClosed-variant HTLCFailChannelUpdate
4690 pub extern "C" fn HTLCFailChannelUpdate_channel_closed(short_channel_id: u64, is_permanent: bool) -> HTLCFailChannelUpdate {
4691         HTLCFailChannelUpdate::ChannelClosed {
4692                 short_channel_id,
4693                 is_permanent,
4694         }
4695 }
4696 #[no_mangle]
4697 /// Utility method to constructs a new NodeFailure-variant HTLCFailChannelUpdate
4698 pub extern "C" fn HTLCFailChannelUpdate_node_failure(node_id: crate::c_types::PublicKey, is_permanent: bool) -> HTLCFailChannelUpdate {
4699         HTLCFailChannelUpdate::NodeFailure {
4700                 node_id,
4701                 is_permanent,
4702         }
4703 }
4704 /// A trait to describe an object which can receive channel messages.
4705 ///
4706 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4707 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4708 #[repr(C)]
4709 pub struct ChannelMessageHandler {
4710         /// An opaque pointer which is passed to your function implementations as an argument.
4711         /// This has no meaning in the LDK, and can be NULL or any other value.
4712         pub this_arg: *mut c_void,
4713         /// Handle an incoming open_channel message from the given peer.
4714         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),
4715         /// Handle an incoming accept_channel message from the given peer.
4716         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),
4717         /// Handle an incoming funding_created message from the given peer.
4718         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),
4719         /// Handle an incoming funding_signed message from the given peer.
4720         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),
4721         /// Handle an incoming funding_locked message from the given peer.
4722         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),
4723         /// Handle an incoming shutdown message from the given peer.
4724         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),
4725         /// Handle an incoming closing_signed message from the given peer.
4726         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),
4727         /// Handle an incoming update_add_htlc message from the given peer.
4728         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),
4729         /// Handle an incoming update_fulfill_htlc message from the given peer.
4730         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),
4731         /// Handle an incoming update_fail_htlc message from the given peer.
4732         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),
4733         /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4734         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),
4735         /// Handle an incoming commitment_signed message from the given peer.
4736         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),
4737         /// Handle an incoming revoke_and_ack message from the given peer.
4738         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),
4739         /// Handle an incoming update_fee message from the given peer.
4740         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),
4741         /// Handle an incoming announcement_signatures message from the given peer.
4742         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),
4743         /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4744         /// is believed to be possible in the future (eg they're sending us messages we don't
4745         /// understand or indicate they require unknown feature bits), no_connection_possible is set
4746         /// and any outstanding channels should be failed.
4747         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4748         /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4749         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
4750         /// Handle an incoming channel_reestablish message from the given peer.
4751         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),
4752         /// Handle an incoming channel update from the given peer.
4753         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),
4754         /// Handle an incoming error message from the given peer.
4755         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
4756         /// Implementation of MessageSendEventsProvider for this object.
4757         pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
4758         /// Frees any resources associated with this object given its this_arg pointer.
4759         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4760         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4761 }
4762 unsafe impl Send for ChannelMessageHandler {}
4763 unsafe impl Sync for ChannelMessageHandler {}
4764 #[no_mangle]
4765 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
4766         ChannelMessageHandler {
4767                 this_arg: orig.this_arg,
4768                 handle_open_channel: Clone::clone(&orig.handle_open_channel),
4769                 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
4770                 handle_funding_created: Clone::clone(&orig.handle_funding_created),
4771                 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
4772                 handle_funding_locked: Clone::clone(&orig.handle_funding_locked),
4773                 handle_shutdown: Clone::clone(&orig.handle_shutdown),
4774                 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
4775                 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
4776                 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
4777                 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
4778                 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
4779                 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
4780                 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
4781                 handle_update_fee: Clone::clone(&orig.handle_update_fee),
4782                 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
4783                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
4784                 peer_connected: Clone::clone(&orig.peer_connected),
4785                 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
4786                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
4787                 handle_error: Clone::clone(&orig.handle_error),
4788                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
4789                 free: Clone::clone(&orig.free),
4790         }
4791 }
4792 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4793         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4794                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
4795                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4796                 local_ret
4797         }
4798 }
4799
4800 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4801 impl rustChannelMessageHandler for ChannelMessageHandler {
4802         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) {
4803                 (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 })
4804         }
4805         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) {
4806                 (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 })
4807         }
4808         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
4809                 (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 })
4810         }
4811         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
4812                 (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 })
4813         }
4814         fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) {
4815                 (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 })
4816         }
4817         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) {
4818                 (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 })
4819         }
4820         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
4821                 (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 })
4822         }
4823         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
4824                 (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 })
4825         }
4826         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4827                 (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 })
4828         }
4829         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
4830                 (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 })
4831         }
4832         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4833                 (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 })
4834         }
4835         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
4836                 (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 })
4837         }
4838         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
4839                 (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 })
4840         }
4841         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
4842                 (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 })
4843         }
4844         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
4845                 (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 })
4846         }
4847         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) {
4848                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4849         }
4850         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) {
4851                 (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 })
4852         }
4853         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
4854                 (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 })
4855         }
4856         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
4857                 (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 })
4858         }
4859         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
4860                 (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 })
4861         }
4862 }
4863
4864 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4865 // directly as a Deref trait in higher-level structs:
4866 impl std::ops::Deref for ChannelMessageHandler {
4867         type Target = Self;
4868         fn deref(&self) -> &Self {
4869                 self
4870         }
4871 }
4872 /// Calls the free function if one is set
4873 #[no_mangle]
4874 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4875 impl Drop for ChannelMessageHandler {
4876         fn drop(&mut self) {
4877                 if let Some(f) = self.free {
4878                         f(self.this_arg);
4879                 }
4880         }
4881 }
4882 /// A trait to describe an object which can receive routing messages.
4883 ///
4884 /// # Implementor DoS Warnings
4885 ///
4886 /// For `gossip_queries` messages there are potential DoS vectors when handling
4887 /// inbound queries. Implementors using an on-disk network graph should be aware of
4888 /// repeated disk I/O for queries accessing different parts of the network graph.
4889 #[repr(C)]
4890 pub struct RoutingMessageHandler {
4891         /// An opaque pointer which is passed to your function implementations as an argument.
4892         /// This has no meaning in the LDK, and can be NULL or any other value.
4893         pub this_arg: *mut c_void,
4894         /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4895         /// false or returning an Err otherwise.
4896         #[must_use]
4897         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4898         /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4899         /// or returning an Err otherwise.
4900         #[must_use]
4901         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4902         /// Handle an incoming channel_update message, returning true if it should be forwarded on,
4903         /// false or returning an Err otherwise.
4904         #[must_use]
4905         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4906         /// Handle some updates to the route graph that we learned due to an outbound failed payment.
4907         pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate),
4908         /// Gets a subset of the channel announcements and updates required to dump our routing table
4909         /// to a remote node, starting at the short_channel_id indicated by starting_point and
4910         /// including the batch_amount entries immediately higher in numerical value than starting_point.
4911         #[must_use]
4912         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,
4913         /// Gets a subset of the node announcements required to dump our routing table to a remote node,
4914         /// starting at the node *after* the provided publickey and including batch_amount entries
4915         /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
4916         /// If None is provided for starting_point, we start at the first node.
4917         ///
4918         /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
4919         #[must_use]
4920         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,
4921         /// Called when a connection is established with a peer. This can be used to
4922         /// perform routing table synchronization using a strategy defined by the
4923         /// implementor.
4924         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),
4925         /// Handles the reply of a query we initiated to learn about channels
4926         /// for a given range of blocks. We can expect to receive one or more
4927         /// replies to a single query.
4928         #[must_use]
4929         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,
4930         /// Handles the reply of a query we initiated asking for routing gossip
4931         /// messages for a list of channels. We should receive this message when
4932         /// a node has completed its best effort to send us the pertaining routing
4933         /// gossip messages.
4934         #[must_use]
4935         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,
4936         /// Handles when a peer asks us to send a list of short_channel_ids
4937         /// for the requested range of blocks.
4938         #[must_use]
4939         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,
4940         /// Handles when a peer asks us to send routing gossip messages for a
4941         /// list of short_channel_ids.
4942         #[must_use]
4943         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,
4944         /// Implementation of MessageSendEventsProvider for this object.
4945         pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
4946         /// Frees any resources associated with this object given its this_arg pointer.
4947         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4948         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4949 }
4950 unsafe impl Send for RoutingMessageHandler {}
4951 unsafe impl Sync for RoutingMessageHandler {}
4952 #[no_mangle]
4953 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
4954         RoutingMessageHandler {
4955                 this_arg: orig.this_arg,
4956                 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
4957                 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
4958                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
4959                 handle_htlc_fail_channel_update: Clone::clone(&orig.handle_htlc_fail_channel_update),
4960                 get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
4961                 get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
4962                 sync_routing_table: Clone::clone(&orig.sync_routing_table),
4963                 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
4964                 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
4965                 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
4966                 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
4967                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
4968                 free: Clone::clone(&orig.free),
4969         }
4970 }
4971 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
4972         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4973                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
4974                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4975                 local_ret
4976         }
4977 }
4978
4979 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
4980 impl rustRoutingMessageHandler for RoutingMessageHandler {
4981         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4982                 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 });
4983                 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()) } })};
4984                 local_ret
4985         }
4986         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4987                 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 });
4988                 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()) } })};
4989                 local_ret
4990         }
4991         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
4992                 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 });
4993                 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()) } })};
4994                 local_ret
4995         }
4996         fn handle_htlc_fail_channel_update(&self, mut update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
4997                 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::lightning::ln::msgs::HTLCFailChannelUpdate::from_native(update))
4998         }
4999         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>)> {
5000                 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
5001                 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 }); };
5002                 local_ret
5003         }
5004         fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
5005                 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())) } };
5006                 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
5007                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5008                 local_ret
5009         }
5010         fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
5011                 (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 })
5012         }
5013         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> {
5014                 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 });
5015                 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()) } })};
5016                 local_ret
5017         }
5018         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> {
5019                 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 });
5020                 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()) } })};
5021                 local_ret
5022         }
5023         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> {
5024                 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 });
5025                 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()) } })};
5026                 local_ret
5027         }
5028         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> {
5029                 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 });
5030                 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()) } })};
5031                 local_ret
5032         }
5033 }
5034
5035 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5036 // directly as a Deref trait in higher-level structs:
5037 impl std::ops::Deref for RoutingMessageHandler {
5038         type Target = Self;
5039         fn deref(&self) -> &Self {
5040                 self
5041         }
5042 }
5043 /// Calls the free function if one is set
5044 #[no_mangle]
5045 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
5046 impl Drop for RoutingMessageHandler {
5047         fn drop(&mut self) {
5048                 if let Some(f) = self.free {
5049                         f(self.this_arg);
5050                 }
5051         }
5052 }
5053 mod fuzzy_internal_msgs {
5054
5055 use std::str::FromStr;
5056 use std::ffi::c_void;
5057 use bitcoin::hashes::Hash;
5058 use crate::c_types::*;
5059
5060 }
5061 #[no_mangle]
5062 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
5063 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
5064         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5065 }
5066 #[no_mangle]
5067 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5068         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
5069 }
5070 #[no_mangle]
5071 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
5072 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
5073         let res = crate::c_types::deserialize_obj(ser);
5074         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() };
5075         local_res
5076 }
5077 #[no_mangle]
5078 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
5079 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
5080         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5081 }
5082 #[no_mangle]
5083 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5084         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
5085 }
5086 #[no_mangle]
5087 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
5088 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
5089         let res = crate::c_types::deserialize_obj(ser);
5090         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() };
5091         local_res
5092 }
5093 #[no_mangle]
5094 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
5095 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
5096         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5097 }
5098 #[no_mangle]
5099 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5100         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
5101 }
5102 #[no_mangle]
5103 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
5104 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
5105         let res = crate::c_types::deserialize_obj(ser);
5106         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() };
5107         local_res
5108 }
5109 #[no_mangle]
5110 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
5111 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
5112         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5113 }
5114 #[no_mangle]
5115 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5116         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
5117 }
5118 #[no_mangle]
5119 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
5120 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
5121         let res = crate::c_types::deserialize_obj(ser);
5122         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() };
5123         local_res
5124 }
5125 #[no_mangle]
5126 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
5127 pub extern "C" fn ClosingSignedFeeRange_write(obj: &ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
5128         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5129 }
5130 #[no_mangle]
5131 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5132         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
5133 }
5134 #[no_mangle]
5135 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
5136 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
5137         let res = crate::c_types::deserialize_obj(ser);
5138         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSignedFeeRange { 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() };
5139         local_res
5140 }
5141 #[no_mangle]
5142 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
5143 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
5144         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5145 }
5146 #[no_mangle]
5147 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5148         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
5149 }
5150 #[no_mangle]
5151 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
5152 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
5153         let res = crate::c_types::deserialize_obj(ser);
5154         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() };
5155         local_res
5156 }
5157 #[no_mangle]
5158 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
5159 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
5160         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5161 }
5162 #[no_mangle]
5163 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5164         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
5165 }
5166 #[no_mangle]
5167 /// Read a FundingCreated from a byte array, created by FundingCreated_write
5168 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
5169         let res = crate::c_types::deserialize_obj(ser);
5170         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() };
5171         local_res
5172 }
5173 #[no_mangle]
5174 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
5175 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
5176         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5177 }
5178 #[no_mangle]
5179 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5180         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
5181 }
5182 #[no_mangle]
5183 /// Read a FundingSigned from a byte array, created by FundingSigned_write
5184 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
5185         let res = crate::c_types::deserialize_obj(ser);
5186         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() };
5187         local_res
5188 }
5189 #[no_mangle]
5190 /// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read
5191 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
5192         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5193 }
5194 #[no_mangle]
5195 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5196         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
5197 }
5198 #[no_mangle]
5199 /// Read a FundingLocked from a byte array, created by FundingLocked_write
5200 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
5201         let res = crate::c_types::deserialize_obj(ser);
5202         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() };
5203         local_res
5204 }
5205 #[no_mangle]
5206 /// Serialize the Init object into a byte array which can be read by Init_read
5207 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
5208         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5209 }
5210 #[no_mangle]
5211 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5212         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
5213 }
5214 #[no_mangle]
5215 /// Read a Init from a byte array, created by Init_write
5216 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
5217         let res = crate::c_types::deserialize_obj(ser);
5218         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() };
5219         local_res
5220 }
5221 #[no_mangle]
5222 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
5223 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
5224         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5225 }
5226 #[no_mangle]
5227 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5228         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
5229 }
5230 #[no_mangle]
5231 /// Read a OpenChannel from a byte array, created by OpenChannel_write
5232 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
5233         let res = crate::c_types::deserialize_obj(ser);
5234         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() };
5235         local_res
5236 }
5237 #[no_mangle]
5238 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
5239 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
5240         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5241 }
5242 #[no_mangle]
5243 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5244         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
5245 }
5246 #[no_mangle]
5247 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
5248 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
5249         let res = crate::c_types::deserialize_obj(ser);
5250         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() };
5251         local_res
5252 }
5253 #[no_mangle]
5254 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
5255 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
5256         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5257 }
5258 #[no_mangle]
5259 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5260         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
5261 }
5262 #[no_mangle]
5263 /// Read a Shutdown from a byte array, created by Shutdown_write
5264 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
5265         let res = crate::c_types::deserialize_obj(ser);
5266         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() };
5267         local_res
5268 }
5269 #[no_mangle]
5270 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
5271 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
5272         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5273 }
5274 #[no_mangle]
5275 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5276         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
5277 }
5278 #[no_mangle]
5279 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
5280 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
5281         let res = crate::c_types::deserialize_obj(ser);
5282         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() };
5283         local_res
5284 }
5285 #[no_mangle]
5286 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
5287 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
5288         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5289 }
5290 #[no_mangle]
5291 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5292         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
5293 }
5294 #[no_mangle]
5295 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
5296 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
5297         let res = crate::c_types::deserialize_obj(ser);
5298         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() };
5299         local_res
5300 }
5301 #[no_mangle]
5302 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5303 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
5304         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5305 }
5306 #[no_mangle]
5307 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5308         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5309 }
5310 #[no_mangle]
5311 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5312 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
5313         let res = crate::c_types::deserialize_obj(ser);
5314         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() };
5315         local_res
5316 }
5317 #[no_mangle]
5318 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5319 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
5320         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5321 }
5322 #[no_mangle]
5323 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5324         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
5325 }
5326 #[no_mangle]
5327 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
5328 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
5329         let res = crate::c_types::deserialize_obj(ser);
5330         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() };
5331         local_res
5332 }
5333 #[no_mangle]
5334 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
5335 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
5336         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5337 }
5338 #[no_mangle]
5339 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5340         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
5341 }
5342 #[no_mangle]
5343 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
5344 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
5345         let res = crate::c_types::deserialize_obj(ser);
5346         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() };
5347         local_res
5348 }
5349 #[no_mangle]
5350 /// Serialize the Ping object into a byte array which can be read by Ping_read
5351 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
5352         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5353 }
5354 #[no_mangle]
5355 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5356         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
5357 }
5358 #[no_mangle]
5359 /// Read a Ping from a byte array, created by Ping_write
5360 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
5361         let res = crate::c_types::deserialize_obj(ser);
5362         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() };
5363         local_res
5364 }
5365 #[no_mangle]
5366 /// Serialize the Pong object into a byte array which can be read by Pong_read
5367 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
5368         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5369 }
5370 #[no_mangle]
5371 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5372         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
5373 }
5374 #[no_mangle]
5375 /// Read a Pong from a byte array, created by Pong_write
5376 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
5377         let res = crate::c_types::deserialize_obj(ser);
5378         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() };
5379         local_res
5380 }
5381 #[no_mangle]
5382 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
5383 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5384         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5385 }
5386 #[no_mangle]
5387 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5388         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
5389 }
5390 #[no_mangle]
5391 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
5392 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
5393         let res = crate::c_types::deserialize_obj(ser);
5394         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() };
5395         local_res
5396 }
5397 #[no_mangle]
5398 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
5399 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5400         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5401 }
5402 #[no_mangle]
5403 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5404         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
5405 }
5406 #[no_mangle]
5407 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
5408 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
5409         let res = crate::c_types::deserialize_obj(ser);
5410         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() };
5411         local_res
5412 }
5413 #[no_mangle]
5414 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
5415 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5416         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5417 }
5418 #[no_mangle]
5419 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5420         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
5421 }
5422 #[no_mangle]
5423 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
5424 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
5425         let res = crate::c_types::deserialize_obj(ser);
5426         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() };
5427         local_res
5428 }
5429 #[no_mangle]
5430 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
5431 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5432         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5433 }
5434 #[no_mangle]
5435 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5436         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
5437 }
5438 #[no_mangle]
5439 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
5440 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
5441         let res = crate::c_types::deserialize_obj(ser);
5442         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() };
5443         local_res
5444 }
5445 #[no_mangle]
5446 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
5447 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
5448         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5449 }
5450 #[no_mangle]
5451 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5452         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
5453 }
5454 #[no_mangle]
5455 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
5456 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
5457         let res = crate::c_types::deserialize_obj(ser);
5458         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() };
5459         local_res
5460 }
5461 #[no_mangle]
5462 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
5463 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5464         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5465 }
5466 #[no_mangle]
5467 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5468         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
5469 }
5470 #[no_mangle]
5471 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
5472 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
5473         let res = crate::c_types::deserialize_obj(ser);
5474         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() };
5475         local_res
5476 }
5477 #[no_mangle]
5478 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
5479 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5480         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5481 }
5482 #[no_mangle]
5483 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5484         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
5485 }
5486 #[no_mangle]
5487 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
5488 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
5489         let res = crate::c_types::deserialize_obj(ser);
5490         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() };
5491         local_res
5492 }
5493 #[no_mangle]
5494 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
5495 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
5496         let res = crate::c_types::deserialize_obj(ser);
5497         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() };
5498         local_res
5499 }
5500 #[no_mangle]
5501 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
5502 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
5503         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5504 }
5505 #[no_mangle]
5506 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5507         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
5508 }
5509 #[no_mangle]
5510 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
5511 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
5512         let res = crate::c_types::deserialize_obj(ser);
5513         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() };
5514         local_res
5515 }
5516 #[no_mangle]
5517 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
5518 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
5519         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5520 }
5521 #[no_mangle]
5522 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5523         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
5524 }
5525 ///\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 
5526 #[must_use]
5527 #[no_mangle]
5528 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 {
5529         let mut ret = unsafe { &*this_arg.inner }.end_blocknum();
5530         ret
5531 }
5532
5533 #[no_mangle]
5534 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
5535 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
5536         let res = crate::c_types::deserialize_obj(ser);
5537         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() };
5538         local_res
5539 }
5540 #[no_mangle]
5541 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
5542 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
5543         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5544 }
5545 #[no_mangle]
5546 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5547         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
5548 }
5549 #[no_mangle]
5550 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
5551 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
5552         let res = crate::c_types::deserialize_obj(ser);
5553         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() };
5554         local_res
5555 }
5556 #[no_mangle]
5557 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
5558 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
5559         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5560 }
5561 #[no_mangle]
5562 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5563         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
5564 }
5565 #[no_mangle]
5566 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
5567 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
5568         let res = crate::c_types::deserialize_obj(ser);
5569         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() };
5570         local_res
5571 }
5572 #[no_mangle]
5573 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
5574 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
5575         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
5576 }
5577 #[no_mangle]
5578 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5579         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
5580 }