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