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