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