Merge pull request #788 from TheBlueMatt/2020-02-concrete-bindings
[rust-lightning] / 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 && !self.inner.is_null() {
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 self.inner.is_null() { 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 && !self.inner.is_null() {
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 impl Clone for Init {
117         fn clone(&self) -> Self {
118                 Self {
119                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
120                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
121                         is_owned: true,
122                 }
123         }
124 }
125 #[allow(unused)]
126 /// Used only if an object of this type is returned as a trait impl by a method
127 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
128         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
129 }
130 #[no_mangle]
131 pub extern "C" fn Init_clone(orig: &Init) -> Init {
132         orig.clone()
133 }
134
135 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
136 type nativeErrorMessage = nativeErrorMessageImport;
137
138 /// An error message to be sent or received from a peer
139 #[must_use]
140 #[repr(C)]
141 pub struct ErrorMessage {
142         /// Nearly everywhere, inner must be non-null, however in places where
143         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
144         pub inner: *mut nativeErrorMessage,
145         pub is_owned: bool,
146 }
147
148 impl Drop for ErrorMessage {
149         fn drop(&mut self) {
150                 if self.is_owned && !self.inner.is_null() {
151                         let _ = unsafe { Box::from_raw(self.inner) };
152                 }
153         }
154 }
155 #[no_mangle]
156 pub extern "C" fn ErrorMessage_free(this_ptr: ErrorMessage) { }
157 #[allow(unused)]
158 /// Used only if an object of this type is returned as a trait impl by a method
159 extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
160         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
161 }
162 #[allow(unused)]
163 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
164 impl ErrorMessage {
165         pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
166                 assert!(self.is_owned);
167                 let ret = self.inner;
168                 self.inner = std::ptr::null_mut();
169                 ret
170         }
171 }
172 impl Clone for ErrorMessage {
173         fn clone(&self) -> Self {
174                 Self {
175                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
176                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
177                         is_owned: true,
178                 }
179         }
180 }
181 #[allow(unused)]
182 /// Used only if an object of this type is returned as a trait impl by a method
183 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
184         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
185 }
186 #[no_mangle]
187 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
188         orig.clone()
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
227 use lightning::ln::msgs::Ping as nativePingImport;
228 type nativePing = nativePingImport;
229
230 /// A ping message to be sent or received from a peer
231 #[must_use]
232 #[repr(C)]
233 pub struct Ping {
234         /// Nearly everywhere, inner must be non-null, however in places where
235         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
236         pub inner: *mut nativePing,
237         pub is_owned: bool,
238 }
239
240 impl Drop for Ping {
241         fn drop(&mut self) {
242                 if self.is_owned && !self.inner.is_null() {
243                         let _ = unsafe { Box::from_raw(self.inner) };
244                 }
245         }
246 }
247 #[no_mangle]
248 pub extern "C" fn Ping_free(this_ptr: Ping) { }
249 #[allow(unused)]
250 /// Used only if an object of this type is returned as a trait impl by a method
251 extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
252         unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
253 }
254 #[allow(unused)]
255 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
256 impl Ping {
257         pub(crate) fn take_inner(mut self) -> *mut nativePing {
258                 assert!(self.is_owned);
259                 let ret = self.inner;
260                 self.inner = std::ptr::null_mut();
261                 ret
262         }
263 }
264 impl Clone for Ping {
265         fn clone(&self) -> Self {
266                 Self {
267                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
268                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
269                         is_owned: true,
270                 }
271         }
272 }
273 #[allow(unused)]
274 /// Used only if an object of this type is returned as a trait impl by a method
275 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
276         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
277 }
278 #[no_mangle]
279 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
280         orig.clone()
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
315 use lightning::ln::msgs::Pong as nativePongImport;
316 type nativePong = nativePongImport;
317
318 /// A pong message to be sent or received from a peer
319 #[must_use]
320 #[repr(C)]
321 pub struct Pong {
322         /// Nearly everywhere, inner must be non-null, however in places where
323         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
324         pub inner: *mut nativePong,
325         pub is_owned: bool,
326 }
327
328 impl Drop for Pong {
329         fn drop(&mut self) {
330                 if self.is_owned && !self.inner.is_null() {
331                         let _ = unsafe { Box::from_raw(self.inner) };
332                 }
333         }
334 }
335 #[no_mangle]
336 pub extern "C" fn Pong_free(this_ptr: Pong) { }
337 #[allow(unused)]
338 /// Used only if an object of this type is returned as a trait impl by a method
339 extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
340         unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
341 }
342 #[allow(unused)]
343 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
344 impl Pong {
345         pub(crate) fn take_inner(mut self) -> *mut nativePong {
346                 assert!(self.is_owned);
347                 let ret = self.inner;
348                 self.inner = std::ptr::null_mut();
349                 ret
350         }
351 }
352 impl Clone for Pong {
353         fn clone(&self) -> Self {
354                 Self {
355                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
356                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
357                         is_owned: true,
358                 }
359         }
360 }
361 #[allow(unused)]
362 /// Used only if an object of this type is returned as a trait impl by a method
363 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
364         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
365 }
366 #[no_mangle]
367 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
368         orig.clone()
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
391 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
392 type nativeOpenChannel = nativeOpenChannelImport;
393
394 /// An open_channel message to be sent or received from a peer
395 #[must_use]
396 #[repr(C)]
397 pub struct OpenChannel {
398         /// Nearly everywhere, inner must be non-null, however in places where
399         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
400         pub inner: *mut nativeOpenChannel,
401         pub is_owned: bool,
402 }
403
404 impl Drop for OpenChannel {
405         fn drop(&mut self) {
406                 if self.is_owned && !self.inner.is_null() {
407                         let _ = unsafe { Box::from_raw(self.inner) };
408                 }
409         }
410 }
411 #[no_mangle]
412 pub extern "C" fn OpenChannel_free(this_ptr: OpenChannel) { }
413 #[allow(unused)]
414 /// Used only if an object of this type is returned as a trait impl by a method
415 extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
416         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
417 }
418 #[allow(unused)]
419 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
420 impl OpenChannel {
421         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
422                 assert!(self.is_owned);
423                 let ret = self.inner;
424                 self.inner = std::ptr::null_mut();
425                 ret
426         }
427 }
428 impl Clone for OpenChannel {
429         fn clone(&self) -> Self {
430                 Self {
431                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
432                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
433                         is_owned: true,
434                 }
435         }
436 }
437 #[allow(unused)]
438 /// Used only if an object of this type is returned as a trait impl by a method
439 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
440         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
441 }
442 #[no_mangle]
443 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
444         orig.clone()
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
645 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
646 type nativeAcceptChannel = nativeAcceptChannelImport;
647
648 /// An accept_channel message to be sent or received from a peer
649 #[must_use]
650 #[repr(C)]
651 pub struct AcceptChannel {
652         /// Nearly everywhere, inner must be non-null, however in places where
653         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
654         pub inner: *mut nativeAcceptChannel,
655         pub is_owned: bool,
656 }
657
658 impl Drop for AcceptChannel {
659         fn drop(&mut self) {
660                 if self.is_owned && !self.inner.is_null() {
661                         let _ = unsafe { Box::from_raw(self.inner) };
662                 }
663         }
664 }
665 #[no_mangle]
666 pub extern "C" fn AcceptChannel_free(this_ptr: AcceptChannel) { }
667 #[allow(unused)]
668 /// Used only if an object of this type is returned as a trait impl by a method
669 extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
670         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
671 }
672 #[allow(unused)]
673 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
674 impl AcceptChannel {
675         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
676                 assert!(self.is_owned);
677                 let ret = self.inner;
678                 self.inner = std::ptr::null_mut();
679                 ret
680         }
681 }
682 impl Clone for AcceptChannel {
683         fn clone(&self) -> Self {
684                 Self {
685                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
686                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
687                         is_owned: true,
688                 }
689         }
690 }
691 #[allow(unused)]
692 /// Used only if an object of this type is returned as a trait impl by a method
693 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
694         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
695 }
696 #[no_mangle]
697 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
698         orig.clone()
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
855 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
856 type nativeFundingCreated = nativeFundingCreatedImport;
857
858 /// A funding_created message to be sent or received from a peer
859 #[must_use]
860 #[repr(C)]
861 pub struct FundingCreated {
862         /// Nearly everywhere, inner must be non-null, however in places where
863         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
864         pub inner: *mut nativeFundingCreated,
865         pub is_owned: bool,
866 }
867
868 impl Drop for FundingCreated {
869         fn drop(&mut self) {
870                 if self.is_owned && !self.inner.is_null() {
871                         let _ = unsafe { Box::from_raw(self.inner) };
872                 }
873         }
874 }
875 #[no_mangle]
876 pub extern "C" fn FundingCreated_free(this_ptr: FundingCreated) { }
877 #[allow(unused)]
878 /// Used only if an object of this type is returned as a trait impl by a method
879 extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
880         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
881 }
882 #[allow(unused)]
883 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
884 impl FundingCreated {
885         pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
886                 assert!(self.is_owned);
887                 let ret = self.inner;
888                 self.inner = std::ptr::null_mut();
889                 ret
890         }
891 }
892 impl Clone for FundingCreated {
893         fn clone(&self) -> Self {
894                 Self {
895                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
896                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
897                         is_owned: true,
898                 }
899         }
900 }
901 #[allow(unused)]
902 /// Used only if an object of this type is returned as a trait impl by a method
903 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
904         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
905 }
906 #[no_mangle]
907 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
908         orig.clone()
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
965 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
966 type nativeFundingSigned = nativeFundingSignedImport;
967
968 /// A funding_signed message to be sent or received from a peer
969 #[must_use]
970 #[repr(C)]
971 pub struct FundingSigned {
972         /// Nearly everywhere, inner must be non-null, however in places where
973         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
974         pub inner: *mut nativeFundingSigned,
975         pub is_owned: bool,
976 }
977
978 impl Drop for FundingSigned {
979         fn drop(&mut self) {
980                 if self.is_owned && !self.inner.is_null() {
981                         let _ = unsafe { Box::from_raw(self.inner) };
982                 }
983         }
984 }
985 #[no_mangle]
986 pub extern "C" fn FundingSigned_free(this_ptr: FundingSigned) { }
987 #[allow(unused)]
988 /// Used only if an object of this type is returned as a trait impl by a method
989 extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
990         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
991 }
992 #[allow(unused)]
993 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
994 impl FundingSigned {
995         pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
996                 assert!(self.is_owned);
997                 let ret = self.inner;
998                 self.inner = std::ptr::null_mut();
999                 ret
1000         }
1001 }
1002 impl Clone for FundingSigned {
1003         fn clone(&self) -> Self {
1004                 Self {
1005                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1006                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1007                         is_owned: true,
1008                 }
1009         }
1010 }
1011 #[allow(unused)]
1012 /// Used only if an object of this type is returned as a trait impl by a method
1013 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1014         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1015 }
1016 #[no_mangle]
1017 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1018         orig.clone()
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
1051 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
1052 type nativeFundingLocked = nativeFundingLockedImport;
1053
1054 /// A funding_locked message to be sent or received from a peer
1055 #[must_use]
1056 #[repr(C)]
1057 pub struct FundingLocked {
1058         /// Nearly everywhere, inner must be non-null, however in places where
1059         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1060         pub inner: *mut nativeFundingLocked,
1061         pub is_owned: bool,
1062 }
1063
1064 impl Drop for FundingLocked {
1065         fn drop(&mut self) {
1066                 if self.is_owned && !self.inner.is_null() {
1067                         let _ = unsafe { Box::from_raw(self.inner) };
1068                 }
1069         }
1070 }
1071 #[no_mangle]
1072 pub extern "C" fn FundingLocked_free(this_ptr: FundingLocked) { }
1073 #[allow(unused)]
1074 /// Used only if an object of this type is returned as a trait impl by a method
1075 extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
1076         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
1077 }
1078 #[allow(unused)]
1079 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1080 impl FundingLocked {
1081         pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
1082                 assert!(self.is_owned);
1083                 let ret = self.inner;
1084                 self.inner = std::ptr::null_mut();
1085                 ret
1086         }
1087 }
1088 impl Clone for FundingLocked {
1089         fn clone(&self) -> Self {
1090                 Self {
1091                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1092                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1093                         is_owned: true,
1094                 }
1095         }
1096 }
1097 #[allow(unused)]
1098 /// Used only if an object of this type is returned as a trait impl by a method
1099 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1100         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1101 }
1102 #[no_mangle]
1103 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1104         orig.clone()
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
1137 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1138 type nativeShutdown = nativeShutdownImport;
1139
1140 /// A shutdown message to be sent or received from a peer
1141 #[must_use]
1142 #[repr(C)]
1143 pub struct Shutdown {
1144         /// Nearly everywhere, inner must be non-null, however in places where
1145         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1146         pub inner: *mut nativeShutdown,
1147         pub is_owned: bool,
1148 }
1149
1150 impl Drop for Shutdown {
1151         fn drop(&mut self) {
1152                 if self.is_owned && !self.inner.is_null() {
1153                         let _ = unsafe { Box::from_raw(self.inner) };
1154                 }
1155         }
1156 }
1157 #[no_mangle]
1158 pub extern "C" fn Shutdown_free(this_ptr: Shutdown) { }
1159 #[allow(unused)]
1160 /// Used only if an object of this type is returned as a trait impl by a method
1161 extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1162         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1163 }
1164 #[allow(unused)]
1165 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1166 impl Shutdown {
1167         pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1168                 assert!(self.is_owned);
1169                 let ret = self.inner;
1170                 self.inner = std::ptr::null_mut();
1171                 ret
1172         }
1173 }
1174 impl Clone for Shutdown {
1175         fn clone(&self) -> Self {
1176                 Self {
1177                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1178                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1179                         is_owned: true,
1180                 }
1181         }
1182 }
1183 #[allow(unused)]
1184 /// Used only if an object of this type is returned as a trait impl by a method
1185 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1186         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1187 }
1188 #[no_mangle]
1189 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1190         orig.clone()
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
1225 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1226 type nativeClosingSigned = nativeClosingSignedImport;
1227
1228 /// A closing_signed message to be sent or received from a peer
1229 #[must_use]
1230 #[repr(C)]
1231 pub struct ClosingSigned {
1232         /// Nearly everywhere, inner must be non-null, however in places where
1233         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1234         pub inner: *mut nativeClosingSigned,
1235         pub is_owned: bool,
1236 }
1237
1238 impl Drop for ClosingSigned {
1239         fn drop(&mut self) {
1240                 if self.is_owned && !self.inner.is_null() {
1241                         let _ = unsafe { Box::from_raw(self.inner) };
1242                 }
1243         }
1244 }
1245 #[no_mangle]
1246 pub extern "C" fn ClosingSigned_free(this_ptr: ClosingSigned) { }
1247 #[allow(unused)]
1248 /// Used only if an object of this type is returned as a trait impl by a method
1249 extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1250         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1251 }
1252 #[allow(unused)]
1253 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1254 impl ClosingSigned {
1255         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1256                 assert!(self.is_owned);
1257                 let ret = self.inner;
1258                 self.inner = std::ptr::null_mut();
1259                 ret
1260         }
1261 }
1262 impl Clone for ClosingSigned {
1263         fn clone(&self) -> Self {
1264                 Self {
1265                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1266                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1267                         is_owned: true,
1268                 }
1269         }
1270 }
1271 #[allow(unused)]
1272 /// Used only if an object of this type is returned as a trait impl by a method
1273 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1274         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1275 }
1276 #[no_mangle]
1277 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1278         orig.clone()
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
1323 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1324 type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1325
1326 /// An update_add_htlc message to be sent or received from a peer
1327 #[must_use]
1328 #[repr(C)]
1329 pub struct UpdateAddHTLC {
1330         /// Nearly everywhere, inner must be non-null, however in places where
1331         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1332         pub inner: *mut nativeUpdateAddHTLC,
1333         pub is_owned: bool,
1334 }
1335
1336 impl Drop for UpdateAddHTLC {
1337         fn drop(&mut self) {
1338                 if self.is_owned && !self.inner.is_null() {
1339                         let _ = unsafe { Box::from_raw(self.inner) };
1340                 }
1341         }
1342 }
1343 #[no_mangle]
1344 pub extern "C" fn UpdateAddHTLC_free(this_ptr: UpdateAddHTLC) { }
1345 #[allow(unused)]
1346 /// Used only if an object of this type is returned as a trait impl by a method
1347 extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1348         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1349 }
1350 #[allow(unused)]
1351 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1352 impl UpdateAddHTLC {
1353         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1354                 assert!(self.is_owned);
1355                 let ret = self.inner;
1356                 self.inner = std::ptr::null_mut();
1357                 ret
1358         }
1359 }
1360 impl Clone for UpdateAddHTLC {
1361         fn clone(&self) -> Self {
1362                 Self {
1363                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1364                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1365                         is_owned: true,
1366                 }
1367         }
1368 }
1369 #[allow(unused)]
1370 /// Used only if an object of this type is returned as a trait impl by a method
1371 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1372         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1373 }
1374 #[no_mangle]
1375 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1376         orig.clone()
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
1434 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1435 type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1436
1437 /// An update_fulfill_htlc message to be sent or received from a peer
1438 #[must_use]
1439 #[repr(C)]
1440 pub struct UpdateFulfillHTLC {
1441         /// Nearly everywhere, inner must be non-null, however in places where
1442         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1443         pub inner: *mut nativeUpdateFulfillHTLC,
1444         pub is_owned: bool,
1445 }
1446
1447 impl Drop for UpdateFulfillHTLC {
1448         fn drop(&mut self) {
1449                 if self.is_owned && !self.inner.is_null() {
1450                         let _ = unsafe { Box::from_raw(self.inner) };
1451                 }
1452         }
1453 }
1454 #[no_mangle]
1455 pub extern "C" fn UpdateFulfillHTLC_free(this_ptr: UpdateFulfillHTLC) { }
1456 #[allow(unused)]
1457 /// Used only if an object of this type is returned as a trait impl by a method
1458 extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1459         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1460 }
1461 #[allow(unused)]
1462 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1463 impl UpdateFulfillHTLC {
1464         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1465                 assert!(self.is_owned);
1466                 let ret = self.inner;
1467                 self.inner = std::ptr::null_mut();
1468                 ret
1469         }
1470 }
1471 impl Clone for UpdateFulfillHTLC {
1472         fn clone(&self) -> Self {
1473                 Self {
1474                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1475                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1476                         is_owned: true,
1477                 }
1478         }
1479 }
1480 #[allow(unused)]
1481 /// Used only if an object of this type is returned as a trait impl by a method
1482 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1483         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1484 }
1485 #[no_mangle]
1486 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1487         orig.clone()
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
1532 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1533 type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1534
1535 /// An update_fail_htlc message to be sent or received from a peer
1536 #[must_use]
1537 #[repr(C)]
1538 pub struct UpdateFailHTLC {
1539         /// Nearly everywhere, inner must be non-null, however in places where
1540         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1541         pub inner: *mut nativeUpdateFailHTLC,
1542         pub is_owned: bool,
1543 }
1544
1545 impl Drop for UpdateFailHTLC {
1546         fn drop(&mut self) {
1547                 if self.is_owned && !self.inner.is_null() {
1548                         let _ = unsafe { Box::from_raw(self.inner) };
1549                 }
1550         }
1551 }
1552 #[no_mangle]
1553 pub extern "C" fn UpdateFailHTLC_free(this_ptr: UpdateFailHTLC) { }
1554 #[allow(unused)]
1555 /// Used only if an object of this type is returned as a trait impl by a method
1556 extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1557         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1558 }
1559 #[allow(unused)]
1560 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1561 impl UpdateFailHTLC {
1562         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
1563                 assert!(self.is_owned);
1564                 let ret = self.inner;
1565                 self.inner = std::ptr::null_mut();
1566                 ret
1567         }
1568 }
1569 impl Clone for UpdateFailHTLC {
1570         fn clone(&self) -> Self {
1571                 Self {
1572                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1573                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1574                         is_owned: true,
1575                 }
1576         }
1577 }
1578 #[allow(unused)]
1579 /// Used only if an object of this type is returned as a trait impl by a method
1580 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1581         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
1582 }
1583 #[no_mangle]
1584 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
1585         orig.clone()
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
1610 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
1611 type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
1612
1613 /// An update_fail_malformed_htlc message to be sent or received from a peer
1614 #[must_use]
1615 #[repr(C)]
1616 pub struct UpdateFailMalformedHTLC {
1617         /// Nearly everywhere, inner must be non-null, however in places where
1618         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1619         pub inner: *mut nativeUpdateFailMalformedHTLC,
1620         pub is_owned: bool,
1621 }
1622
1623 impl Drop for UpdateFailMalformedHTLC {
1624         fn drop(&mut self) {
1625                 if self.is_owned && !self.inner.is_null() {
1626                         let _ = unsafe { Box::from_raw(self.inner) };
1627                 }
1628         }
1629 }
1630 #[no_mangle]
1631 pub extern "C" fn UpdateFailMalformedHTLC_free(this_ptr: UpdateFailMalformedHTLC) { }
1632 #[allow(unused)]
1633 /// Used only if an object of this type is returned as a trait impl by a method
1634 extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
1635         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
1636 }
1637 #[allow(unused)]
1638 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1639 impl UpdateFailMalformedHTLC {
1640         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
1641                 assert!(self.is_owned);
1642                 let ret = self.inner;
1643                 self.inner = std::ptr::null_mut();
1644                 ret
1645         }
1646 }
1647 impl Clone for UpdateFailMalformedHTLC {
1648         fn clone(&self) -> Self {
1649                 Self {
1650                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1651                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1652                         is_owned: true,
1653                 }
1654         }
1655 }
1656 #[allow(unused)]
1657 /// Used only if an object of this type is returned as a trait impl by a method
1658 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1659         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
1660 }
1661 #[no_mangle]
1662 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
1663         orig.clone()
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
1699 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
1700 type nativeCommitmentSigned = nativeCommitmentSignedImport;
1701
1702 /// A commitment_signed message to be sent or received from a peer
1703 #[must_use]
1704 #[repr(C)]
1705 pub struct CommitmentSigned {
1706         /// Nearly everywhere, inner must be non-null, however in places where
1707         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1708         pub inner: *mut nativeCommitmentSigned,
1709         pub is_owned: bool,
1710 }
1711
1712 impl Drop for CommitmentSigned {
1713         fn drop(&mut self) {
1714                 if self.is_owned && !self.inner.is_null() {
1715                         let _ = unsafe { Box::from_raw(self.inner) };
1716                 }
1717         }
1718 }
1719 #[no_mangle]
1720 pub extern "C" fn CommitmentSigned_free(this_ptr: CommitmentSigned) { }
1721 #[allow(unused)]
1722 /// Used only if an object of this type is returned as a trait impl by a method
1723 extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
1724         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
1725 }
1726 #[allow(unused)]
1727 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1728 impl CommitmentSigned {
1729         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
1730                 assert!(self.is_owned);
1731                 let ret = self.inner;
1732                 self.inner = std::ptr::null_mut();
1733                 ret
1734         }
1735 }
1736 impl Clone for CommitmentSigned {
1737         fn clone(&self) -> Self {
1738                 Self {
1739                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1740                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1741                         is_owned: true,
1742                 }
1743         }
1744 }
1745 #[allow(unused)]
1746 /// Used only if an object of this type is returned as a trait impl by a method
1747 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1748         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
1749 }
1750 #[no_mangle]
1751 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
1752         orig.clone()
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
1793 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
1794 type nativeRevokeAndACK = nativeRevokeAndACKImport;
1795
1796 /// A revoke_and_ack message to be sent or received from a peer
1797 #[must_use]
1798 #[repr(C)]
1799 pub struct RevokeAndACK {
1800         /// Nearly everywhere, inner must be non-null, however in places where
1801         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1802         pub inner: *mut nativeRevokeAndACK,
1803         pub is_owned: bool,
1804 }
1805
1806 impl Drop for RevokeAndACK {
1807         fn drop(&mut self) {
1808                 if self.is_owned && !self.inner.is_null() {
1809                         let _ = unsafe { Box::from_raw(self.inner) };
1810                 }
1811         }
1812 }
1813 #[no_mangle]
1814 pub extern "C" fn RevokeAndACK_free(this_ptr: RevokeAndACK) { }
1815 #[allow(unused)]
1816 /// Used only if an object of this type is returned as a trait impl by a method
1817 extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
1818         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
1819 }
1820 #[allow(unused)]
1821 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1822 impl RevokeAndACK {
1823         pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
1824                 assert!(self.is_owned);
1825                 let ret = self.inner;
1826                 self.inner = std::ptr::null_mut();
1827                 ret
1828         }
1829 }
1830 impl Clone for RevokeAndACK {
1831         fn clone(&self) -> Self {
1832                 Self {
1833                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1834                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1835                         is_owned: true,
1836                 }
1837         }
1838 }
1839 #[allow(unused)]
1840 /// Used only if an object of this type is returned as a trait impl by a method
1841 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
1842         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
1843 }
1844 #[no_mangle]
1845 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
1846         orig.clone()
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
1891 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
1892 type nativeUpdateFee = nativeUpdateFeeImport;
1893
1894 /// An update_fee message to be sent or received from a peer
1895 #[must_use]
1896 #[repr(C)]
1897 pub struct UpdateFee {
1898         /// Nearly everywhere, inner must be non-null, however in places where
1899         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1900         pub inner: *mut nativeUpdateFee,
1901         pub is_owned: bool,
1902 }
1903
1904 impl Drop for UpdateFee {
1905         fn drop(&mut self) {
1906                 if self.is_owned && !self.inner.is_null() {
1907                         let _ = unsafe { Box::from_raw(self.inner) };
1908                 }
1909         }
1910 }
1911 #[no_mangle]
1912 pub extern "C" fn UpdateFee_free(this_ptr: UpdateFee) { }
1913 #[allow(unused)]
1914 /// Used only if an object of this type is returned as a trait impl by a method
1915 extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
1916         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
1917 }
1918 #[allow(unused)]
1919 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1920 impl UpdateFee {
1921         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
1922                 assert!(self.is_owned);
1923                 let ret = self.inner;
1924                 self.inner = std::ptr::null_mut();
1925                 ret
1926         }
1927 }
1928 impl Clone for UpdateFee {
1929         fn clone(&self) -> Self {
1930                 Self {
1931                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1932                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1933                         is_owned: true,
1934                 }
1935         }
1936 }
1937 #[allow(unused)]
1938 /// Used only if an object of this type is returned as a trait impl by a method
1939 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
1940         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
1941 }
1942 #[no_mangle]
1943 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
1944         orig.clone()
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
1977 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
1978 type nativeDataLossProtect = nativeDataLossProtectImport;
1979
1980 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
1981 /// This is used to convince the recipient that the channel is at a certain commitment
1982 /// number even if they lost that data due to a local failure.  Of course, the peer may lie
1983 /// and even later commitments may have been revoked.
1984 #[must_use]
1985 #[repr(C)]
1986 pub struct DataLossProtect {
1987         /// Nearly everywhere, inner must be non-null, however in places where
1988         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1989         pub inner: *mut nativeDataLossProtect,
1990         pub is_owned: bool,
1991 }
1992
1993 impl Drop for DataLossProtect {
1994         fn drop(&mut self) {
1995                 if self.is_owned && !self.inner.is_null() {
1996                         let _ = unsafe { Box::from_raw(self.inner) };
1997                 }
1998         }
1999 }
2000 #[no_mangle]
2001 pub extern "C" fn DataLossProtect_free(this_ptr: DataLossProtect) { }
2002 #[allow(unused)]
2003 /// Used only if an object of this type is returned as a trait impl by a method
2004 extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2005         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2006 }
2007 #[allow(unused)]
2008 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2009 impl DataLossProtect {
2010         pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2011                 assert!(self.is_owned);
2012                 let ret = self.inner;
2013                 self.inner = std::ptr::null_mut();
2014                 ret
2015         }
2016 }
2017 impl Clone for DataLossProtect {
2018         fn clone(&self) -> Self {
2019                 Self {
2020                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2021                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2022                         is_owned: true,
2023                 }
2024         }
2025 }
2026 #[allow(unused)]
2027 /// Used only if an object of this type is returned as a trait impl by a method
2028 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2029         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2030 }
2031 #[no_mangle]
2032 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2033         orig.clone()
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
2068 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2069 type nativeChannelReestablish = nativeChannelReestablishImport;
2070
2071 /// A channel_reestablish message to be sent or received from a peer
2072 #[must_use]
2073 #[repr(C)]
2074 pub struct ChannelReestablish {
2075         /// Nearly everywhere, inner must be non-null, however in places where
2076         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2077         pub inner: *mut nativeChannelReestablish,
2078         pub is_owned: bool,
2079 }
2080
2081 impl Drop for ChannelReestablish {
2082         fn drop(&mut self) {
2083                 if self.is_owned && !self.inner.is_null() {
2084                         let _ = unsafe { Box::from_raw(self.inner) };
2085                 }
2086         }
2087 }
2088 #[no_mangle]
2089 pub extern "C" fn ChannelReestablish_free(this_ptr: ChannelReestablish) { }
2090 #[allow(unused)]
2091 /// Used only if an object of this type is returned as a trait impl by a method
2092 extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2093         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2094 }
2095 #[allow(unused)]
2096 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2097 impl ChannelReestablish {
2098         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2099                 assert!(self.is_owned);
2100                 let ret = self.inner;
2101                 self.inner = std::ptr::null_mut();
2102                 ret
2103         }
2104 }
2105 impl Clone for ChannelReestablish {
2106         fn clone(&self) -> Self {
2107                 Self {
2108                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2109                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2110                         is_owned: true,
2111                 }
2112         }
2113 }
2114 #[allow(unused)]
2115 /// Used only if an object of this type is returned as a trait impl by a method
2116 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2117         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2118 }
2119 #[no_mangle]
2120 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2121         orig.clone()
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
2157 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2158 type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2159
2160 /// An announcement_signatures message to be sent or received from a peer
2161 #[must_use]
2162 #[repr(C)]
2163 pub struct AnnouncementSignatures {
2164         /// Nearly everywhere, inner must be non-null, however in places where
2165         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2166         pub inner: *mut nativeAnnouncementSignatures,
2167         pub is_owned: bool,
2168 }
2169
2170 impl Drop for AnnouncementSignatures {
2171         fn drop(&mut self) {
2172                 if self.is_owned && !self.inner.is_null() {
2173                         let _ = unsafe { Box::from_raw(self.inner) };
2174                 }
2175         }
2176 }
2177 #[no_mangle]
2178 pub extern "C" fn AnnouncementSignatures_free(this_ptr: AnnouncementSignatures) { }
2179 #[allow(unused)]
2180 /// Used only if an object of this type is returned as a trait impl by a method
2181 extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2182         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2183 }
2184 #[allow(unused)]
2185 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2186 impl AnnouncementSignatures {
2187         pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2188                 assert!(self.is_owned);
2189                 let ret = self.inner;
2190                 self.inner = std::ptr::null_mut();
2191                 ret
2192         }
2193 }
2194 impl Clone for AnnouncementSignatures {
2195         fn clone(&self) -> Self {
2196                 Self {
2197                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2198                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2199                         is_owned: true,
2200                 }
2201         }
2202 }
2203 #[allow(unused)]
2204 /// Used only if an object of this type is returned as a trait impl by a method
2205 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2206         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2207 }
2208 #[no_mangle]
2209 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2210         orig.clone()
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 /// An address which can be used to connect to a remote peer
2267 #[must_use]
2268 #[derive(Clone)]
2269 #[repr(C)]
2270 pub enum NetAddress {
2271         /// An IPv4 address/port on which the peer is listening.
2272         IPv4 {
2273                 addr: crate::c_types::FourBytes,
2274                 port: u16,
2275         },
2276         /// An IPv6 address/port on which the peer is listening.
2277         IPv6 {
2278                 addr: crate::c_types::SixteenBytes,
2279                 port: u16,
2280         },
2281         /// An old-style Tor onion address/port on which the peer is listening.
2282         OnionV2 {
2283                 addr: crate::c_types::TenBytes,
2284                 port: u16,
2285         },
2286         /// A new-style Tor onion address/port on which the peer is listening.
2287         /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2288         /// wrap as base32 and append \".onion\".
2289         OnionV3 {
2290                 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2291                 checksum: u16,
2292                 version: u8,
2293                 port: u16,
2294         },
2295 }
2296 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2297 impl NetAddress {
2298         #[allow(unused)]
2299         pub(crate) fn to_native(&self) -> nativeNetAddress {
2300                 match self {
2301                         NetAddress::IPv4 {ref addr, ref port, } => {
2302                                 let mut addr_nonref = (*addr).clone();
2303                                 let mut port_nonref = (*port).clone();
2304                                 nativeNetAddress::IPv4 {
2305                                         addr: addr_nonref.data,
2306                                         port: port_nonref,
2307                                 }
2308                         },
2309                         NetAddress::IPv6 {ref addr, ref port, } => {
2310                                 let mut addr_nonref = (*addr).clone();
2311                                 let mut port_nonref = (*port).clone();
2312                                 nativeNetAddress::IPv6 {
2313                                         addr: addr_nonref.data,
2314                                         port: port_nonref,
2315                                 }
2316                         },
2317                         NetAddress::OnionV2 {ref addr, ref port, } => {
2318                                 let mut addr_nonref = (*addr).clone();
2319                                 let mut port_nonref = (*port).clone();
2320                                 nativeNetAddress::OnionV2 {
2321                                         addr: addr_nonref.data,
2322                                         port: port_nonref,
2323                                 }
2324                         },
2325                         NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2326                                 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2327                                 let mut checksum_nonref = (*checksum).clone();
2328                                 let mut version_nonref = (*version).clone();
2329                                 let mut port_nonref = (*port).clone();
2330                                 nativeNetAddress::OnionV3 {
2331                                         ed25519_pubkey: ed25519_pubkey_nonref.data,
2332                                         checksum: checksum_nonref,
2333                                         version: version_nonref,
2334                                         port: port_nonref,
2335                                 }
2336                         },
2337                 }
2338         }
2339         #[allow(unused)]
2340         pub(crate) fn into_native(self) -> nativeNetAddress {
2341                 match self {
2342                         NetAddress::IPv4 {mut addr, mut port, } => {
2343                                 nativeNetAddress::IPv4 {
2344                                         addr: addr.data,
2345                                         port: port,
2346                                 }
2347                         },
2348                         NetAddress::IPv6 {mut addr, mut port, } => {
2349                                 nativeNetAddress::IPv6 {
2350                                         addr: addr.data,
2351                                         port: port,
2352                                 }
2353                         },
2354                         NetAddress::OnionV2 {mut addr, mut port, } => {
2355                                 nativeNetAddress::OnionV2 {
2356                                         addr: addr.data,
2357                                         port: port,
2358                                 }
2359                         },
2360                         NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2361                                 nativeNetAddress::OnionV3 {
2362                                         ed25519_pubkey: ed25519_pubkey.data,
2363                                         checksum: checksum,
2364                                         version: version,
2365                                         port: port,
2366                                 }
2367                         },
2368                 }
2369         }
2370         #[allow(unused)]
2371         pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2372                 match native {
2373                         nativeNetAddress::IPv4 {ref addr, ref port, } => {
2374                                 let mut addr_nonref = (*addr).clone();
2375                                 let mut port_nonref = (*port).clone();
2376                                 NetAddress::IPv4 {
2377                                         addr: crate::c_types::FourBytes { data: addr_nonref },
2378                                         port: port_nonref,
2379                                 }
2380                         },
2381                         nativeNetAddress::IPv6 {ref addr, ref port, } => {
2382                                 let mut addr_nonref = (*addr).clone();
2383                                 let mut port_nonref = (*port).clone();
2384                                 NetAddress::IPv6 {
2385                                         addr: crate::c_types::SixteenBytes { data: addr_nonref },
2386                                         port: port_nonref,
2387                                 }
2388                         },
2389                         nativeNetAddress::OnionV2 {ref addr, ref port, } => {
2390                                 let mut addr_nonref = (*addr).clone();
2391                                 let mut port_nonref = (*port).clone();
2392                                 NetAddress::OnionV2 {
2393                                         addr: crate::c_types::TenBytes { data: addr_nonref },
2394                                         port: port_nonref,
2395                                 }
2396                         },
2397                         nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2398                                 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2399                                 let mut checksum_nonref = (*checksum).clone();
2400                                 let mut version_nonref = (*version).clone();
2401                                 let mut port_nonref = (*port).clone();
2402                                 NetAddress::OnionV3 {
2403                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2404                                         checksum: checksum_nonref,
2405                                         version: version_nonref,
2406                                         port: port_nonref,
2407                                 }
2408                         },
2409                 }
2410         }
2411         #[allow(unused)]
2412         pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2413                 match native {
2414                         nativeNetAddress::IPv4 {mut addr, mut port, } => {
2415                                 NetAddress::IPv4 {
2416                                         addr: crate::c_types::FourBytes { data: addr },
2417                                         port: port,
2418                                 }
2419                         },
2420                         nativeNetAddress::IPv6 {mut addr, mut port, } => {
2421                                 NetAddress::IPv6 {
2422                                         addr: crate::c_types::SixteenBytes { data: addr },
2423                                         port: port,
2424                                 }
2425                         },
2426                         nativeNetAddress::OnionV2 {mut addr, mut port, } => {
2427                                 NetAddress::OnionV2 {
2428                                         addr: crate::c_types::TenBytes { data: addr },
2429                                         port: port,
2430                                 }
2431                         },
2432                         nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2433                                 NetAddress::OnionV3 {
2434                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2435                                         checksum: checksum,
2436                                         version: version,
2437                                         port: port,
2438                                 }
2439                         },
2440                 }
2441         }
2442 }
2443 #[no_mangle]
2444 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2445 #[no_mangle]
2446 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
2447         orig.clone()
2448 }
2449 #[no_mangle]
2450 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2451         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2452 }
2453 #[no_mangle]
2454 pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ {
2455         let res = crate::c_types::deserialize_obj(ser);
2456         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() };
2457         local_res
2458 }
2459
2460 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2461 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2462
2463 /// The unsigned part of a node_announcement
2464 #[must_use]
2465 #[repr(C)]
2466 pub struct UnsignedNodeAnnouncement {
2467         /// Nearly everywhere, inner must be non-null, however in places where
2468         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2469         pub inner: *mut nativeUnsignedNodeAnnouncement,
2470         pub is_owned: bool,
2471 }
2472
2473 impl Drop for UnsignedNodeAnnouncement {
2474         fn drop(&mut self) {
2475                 if self.is_owned && !self.inner.is_null() {
2476                         let _ = unsafe { Box::from_raw(self.inner) };
2477                 }
2478         }
2479 }
2480 #[no_mangle]
2481 pub extern "C" fn UnsignedNodeAnnouncement_free(this_ptr: UnsignedNodeAnnouncement) { }
2482 #[allow(unused)]
2483 /// Used only if an object of this type is returned as a trait impl by a method
2484 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
2485         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
2486 }
2487 #[allow(unused)]
2488 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2489 impl UnsignedNodeAnnouncement {
2490         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
2491                 assert!(self.is_owned);
2492                 let ret = self.inner;
2493                 self.inner = std::ptr::null_mut();
2494                 ret
2495         }
2496 }
2497 impl Clone for UnsignedNodeAnnouncement {
2498         fn clone(&self) -> Self {
2499                 Self {
2500                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2501                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2502                         is_owned: true,
2503                 }
2504         }
2505 }
2506 #[allow(unused)]
2507 /// Used only if an object of this type is returned as a trait impl by a method
2508 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2509         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
2510 }
2511 #[no_mangle]
2512 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
2513         orig.clone()
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
2581 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
2582 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
2583
2584 /// A node_announcement message to be sent or received from a peer
2585 #[must_use]
2586 #[repr(C)]
2587 pub struct NodeAnnouncement {
2588         /// Nearly everywhere, inner must be non-null, however in places where
2589         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2590         pub inner: *mut nativeNodeAnnouncement,
2591         pub is_owned: bool,
2592 }
2593
2594 impl Drop for NodeAnnouncement {
2595         fn drop(&mut self) {
2596                 if self.is_owned && !self.inner.is_null() {
2597                         let _ = unsafe { Box::from_raw(self.inner) };
2598                 }
2599         }
2600 }
2601 #[no_mangle]
2602 pub extern "C" fn NodeAnnouncement_free(this_ptr: NodeAnnouncement) { }
2603 #[allow(unused)]
2604 /// Used only if an object of this type is returned as a trait impl by a method
2605 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
2606         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
2607 }
2608 #[allow(unused)]
2609 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2610 impl NodeAnnouncement {
2611         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
2612                 assert!(self.is_owned);
2613                 let ret = self.inner;
2614                 self.inner = std::ptr::null_mut();
2615                 ret
2616         }
2617 }
2618 impl Clone for NodeAnnouncement {
2619         fn clone(&self) -> Self {
2620                 Self {
2621                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2622                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2623                         is_owned: true,
2624                 }
2625         }
2626 }
2627 #[allow(unused)]
2628 /// Used only if an object of this type is returned as a trait impl by a method
2629 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2630         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
2631 }
2632 #[no_mangle]
2633 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
2634         orig.clone()
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
2667 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
2668 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
2669
2670 /// The unsigned part of a channel_announcement
2671 #[must_use]
2672 #[repr(C)]
2673 pub struct UnsignedChannelAnnouncement {
2674         /// Nearly everywhere, inner must be non-null, however in places where
2675         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2676         pub inner: *mut nativeUnsignedChannelAnnouncement,
2677         pub is_owned: bool,
2678 }
2679
2680 impl Drop for UnsignedChannelAnnouncement {
2681         fn drop(&mut self) {
2682                 if self.is_owned && !self.inner.is_null() {
2683                         let _ = unsafe { Box::from_raw(self.inner) };
2684                 }
2685         }
2686 }
2687 #[no_mangle]
2688 pub extern "C" fn UnsignedChannelAnnouncement_free(this_ptr: UnsignedChannelAnnouncement) { }
2689 #[allow(unused)]
2690 /// Used only if an object of this type is returned as a trait impl by a method
2691 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2692         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
2693 }
2694 #[allow(unused)]
2695 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2696 impl UnsignedChannelAnnouncement {
2697         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
2698                 assert!(self.is_owned);
2699                 let ret = self.inner;
2700                 self.inner = std::ptr::null_mut();
2701                 ret
2702         }
2703 }
2704 impl Clone for UnsignedChannelAnnouncement {
2705         fn clone(&self) -> Self {
2706                 Self {
2707                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2708                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2709                         is_owned: true,
2710                 }
2711         }
2712 }
2713 #[allow(unused)]
2714 /// Used only if an object of this type is returned as a trait impl by a method
2715 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2716         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
2717 }
2718 #[no_mangle]
2719 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
2720         orig.clone()
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
2800 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
2801 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
2802
2803 /// A channel_announcement message to be sent or received from a peer
2804 #[must_use]
2805 #[repr(C)]
2806 pub struct ChannelAnnouncement {
2807         /// Nearly everywhere, inner must be non-null, however in places where
2808         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2809         pub inner: *mut nativeChannelAnnouncement,
2810         pub is_owned: bool,
2811 }
2812
2813 impl Drop for ChannelAnnouncement {
2814         fn drop(&mut self) {
2815                 if self.is_owned && !self.inner.is_null() {
2816                         let _ = unsafe { Box::from_raw(self.inner) };
2817                 }
2818         }
2819 }
2820 #[no_mangle]
2821 pub extern "C" fn ChannelAnnouncement_free(this_ptr: ChannelAnnouncement) { }
2822 #[allow(unused)]
2823 /// Used only if an object of this type is returned as a trait impl by a method
2824 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2825         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
2826 }
2827 #[allow(unused)]
2828 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2829 impl ChannelAnnouncement {
2830         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
2831                 assert!(self.is_owned);
2832                 let ret = self.inner;
2833                 self.inner = std::ptr::null_mut();
2834                 ret
2835         }
2836 }
2837 impl Clone for ChannelAnnouncement {
2838         fn clone(&self) -> Self {
2839                 Self {
2840                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2841                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2842                         is_owned: true,
2843                 }
2844         }
2845 }
2846 #[allow(unused)]
2847 /// Used only if an object of this type is returned as a trait impl by a method
2848 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2849         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
2850 }
2851 #[no_mangle]
2852 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
2853         orig.clone()
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
2922 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
2923 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
2924
2925 /// The unsigned part of a channel_update
2926 #[must_use]
2927 #[repr(C)]
2928 pub struct UnsignedChannelUpdate {
2929         /// Nearly everywhere, inner must be non-null, however in places where
2930         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2931         pub inner: *mut nativeUnsignedChannelUpdate,
2932         pub is_owned: bool,
2933 }
2934
2935 impl Drop for UnsignedChannelUpdate {
2936         fn drop(&mut self) {
2937                 if self.is_owned && !self.inner.is_null() {
2938                         let _ = unsafe { Box::from_raw(self.inner) };
2939                 }
2940         }
2941 }
2942 #[no_mangle]
2943 pub extern "C" fn UnsignedChannelUpdate_free(this_ptr: UnsignedChannelUpdate) { }
2944 #[allow(unused)]
2945 /// Used only if an object of this type is returned as a trait impl by a method
2946 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
2947         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
2948 }
2949 #[allow(unused)]
2950 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2951 impl UnsignedChannelUpdate {
2952         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
2953                 assert!(self.is_owned);
2954                 let ret = self.inner;
2955                 self.inner = std::ptr::null_mut();
2956                 ret
2957         }
2958 }
2959 impl Clone for UnsignedChannelUpdate {
2960         fn clone(&self) -> Self {
2961                 Self {
2962                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2963                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2964                         is_owned: true,
2965                 }
2966         }
2967 }
2968 #[allow(unused)]
2969 /// Used only if an object of this type is returned as a trait impl by a method
2970 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2971         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
2972 }
2973 #[no_mangle]
2974 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
2975         orig.clone()
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
3066 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3067 type nativeChannelUpdate = nativeChannelUpdateImport;
3068
3069 /// A channel_update message to be sent or received from a peer
3070 #[must_use]
3071 #[repr(C)]
3072 pub struct ChannelUpdate {
3073         /// Nearly everywhere, inner must be non-null, however in places where
3074         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3075         pub inner: *mut nativeChannelUpdate,
3076         pub is_owned: bool,
3077 }
3078
3079 impl Drop for ChannelUpdate {
3080         fn drop(&mut self) {
3081                 if self.is_owned && !self.inner.is_null() {
3082                         let _ = unsafe { Box::from_raw(self.inner) };
3083                 }
3084         }
3085 }
3086 #[no_mangle]
3087 pub extern "C" fn ChannelUpdate_free(this_ptr: ChannelUpdate) { }
3088 #[allow(unused)]
3089 /// Used only if an object of this type is returned as a trait impl by a method
3090 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3091         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3092 }
3093 #[allow(unused)]
3094 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3095 impl ChannelUpdate {
3096         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3097                 assert!(self.is_owned);
3098                 let ret = self.inner;
3099                 self.inner = std::ptr::null_mut();
3100                 ret
3101         }
3102 }
3103 impl Clone for ChannelUpdate {
3104         fn clone(&self) -> Self {
3105                 Self {
3106                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3107                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3108                         is_owned: true,
3109                 }
3110         }
3111 }
3112 #[allow(unused)]
3113 /// Used only if an object of this type is returned as a trait impl by a method
3114 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3115         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3116 }
3117 #[no_mangle]
3118 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3119         orig.clone()
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
3152 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3153 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3154
3155 /// A query_channel_range message is used to query a peer for channel
3156 /// UTXOs in a range of blocks. The recipient of a query makes a best
3157 /// effort to reply to the query using one or more reply_channel_range
3158 /// messages.
3159 #[must_use]
3160 #[repr(C)]
3161 pub struct QueryChannelRange {
3162         /// Nearly everywhere, inner must be non-null, however in places where
3163         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3164         pub inner: *mut nativeQueryChannelRange,
3165         pub is_owned: bool,
3166 }
3167
3168 impl Drop for QueryChannelRange {
3169         fn drop(&mut self) {
3170                 if self.is_owned && !self.inner.is_null() {
3171                         let _ = unsafe { Box::from_raw(self.inner) };
3172                 }
3173         }
3174 }
3175 #[no_mangle]
3176 pub extern "C" fn QueryChannelRange_free(this_ptr: QueryChannelRange) { }
3177 #[allow(unused)]
3178 /// Used only if an object of this type is returned as a trait impl by a method
3179 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3180         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3181 }
3182 #[allow(unused)]
3183 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3184 impl QueryChannelRange {
3185         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3186                 assert!(self.is_owned);
3187                 let ret = self.inner;
3188                 self.inner = std::ptr::null_mut();
3189                 ret
3190         }
3191 }
3192 impl Clone for QueryChannelRange {
3193         fn clone(&self) -> Self {
3194                 Self {
3195                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3196                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3197                         is_owned: true,
3198                 }
3199         }
3200 }
3201 #[allow(unused)]
3202 /// Used only if an object of this type is returned as a trait impl by a method
3203 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3204         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3205 }
3206 #[no_mangle]
3207 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3208         orig.clone()
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
3253 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3254 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3255
3256 /// A reply_channel_range message is a reply to a query_channel_range
3257 /// message. Multiple reply_channel_range messages can be sent in reply
3258 /// to a single query_channel_range message. The query recipient makes a
3259 /// best effort to respond based on their local network view which may
3260 /// not be a perfect view of the network. The short_channel_ids in the
3261 /// reply are encoded. We only support encoding_type=0 uncompressed
3262 /// serialization and do not support encoding_type=1 zlib serialization.
3263 #[must_use]
3264 #[repr(C)]
3265 pub struct ReplyChannelRange {
3266         /// Nearly everywhere, inner must be non-null, however in places where
3267         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3268         pub inner: *mut nativeReplyChannelRange,
3269         pub is_owned: bool,
3270 }
3271
3272 impl Drop for ReplyChannelRange {
3273         fn drop(&mut self) {
3274                 if self.is_owned && !self.inner.is_null() {
3275                         let _ = unsafe { Box::from_raw(self.inner) };
3276                 }
3277         }
3278 }
3279 #[no_mangle]
3280 pub extern "C" fn ReplyChannelRange_free(this_ptr: ReplyChannelRange) { }
3281 #[allow(unused)]
3282 /// Used only if an object of this type is returned as a trait impl by a method
3283 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3284         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3285 }
3286 #[allow(unused)]
3287 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3288 impl ReplyChannelRange {
3289         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3290                 assert!(self.is_owned);
3291                 let ret = self.inner;
3292                 self.inner = std::ptr::null_mut();
3293                 ret
3294         }
3295 }
3296 impl Clone for ReplyChannelRange {
3297         fn clone(&self) -> Self {
3298                 Self {
3299                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3300                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3301                         is_owned: true,
3302                 }
3303         }
3304 }
3305 #[allow(unused)]
3306 /// Used only if an object of this type is returned as a trait impl by a method
3307 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3308         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
3309 }
3310 #[no_mangle]
3311 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
3312         orig.clone()
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
3377 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
3378 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
3379
3380 /// A query_short_channel_ids message is used to query a peer for
3381 /// routing gossip messages related to one or more short_channel_ids.
3382 /// The query recipient will reply with the latest, if available,
3383 /// channel_announcement, channel_update and node_announcement messages
3384 /// it maintains for the requested short_channel_ids followed by a
3385 /// reply_short_channel_ids_end message. The short_channel_ids sent in
3386 /// this query are encoded. We only support encoding_type=0 uncompressed
3387 /// serialization and do not support encoding_type=1 zlib serialization.
3388 #[must_use]
3389 #[repr(C)]
3390 pub struct QueryShortChannelIds {
3391         /// Nearly everywhere, inner must be non-null, however in places where
3392         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3393         pub inner: *mut nativeQueryShortChannelIds,
3394         pub is_owned: bool,
3395 }
3396
3397 impl Drop for QueryShortChannelIds {
3398         fn drop(&mut self) {
3399                 if self.is_owned && !self.inner.is_null() {
3400                         let _ = unsafe { Box::from_raw(self.inner) };
3401                 }
3402         }
3403 }
3404 #[no_mangle]
3405 pub extern "C" fn QueryShortChannelIds_free(this_ptr: QueryShortChannelIds) { }
3406 #[allow(unused)]
3407 /// Used only if an object of this type is returned as a trait impl by a method
3408 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
3409         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
3410 }
3411 #[allow(unused)]
3412 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3413 impl QueryShortChannelIds {
3414         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
3415                 assert!(self.is_owned);
3416                 let ret = self.inner;
3417                 self.inner = std::ptr::null_mut();
3418                 ret
3419         }
3420 }
3421 impl Clone for QueryShortChannelIds {
3422         fn clone(&self) -> Self {
3423                 Self {
3424                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3425                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3426                         is_owned: true,
3427                 }
3428         }
3429 }
3430 #[allow(unused)]
3431 /// Used only if an object of this type is returned as a trait impl by a method
3432 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
3433         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
3434 }
3435 #[no_mangle]
3436 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
3437         orig.clone()
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
3466 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
3467 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
3468
3469 /// A reply_short_channel_ids_end message is sent as a reply to a
3470 /// query_short_channel_ids message. The query recipient makes a best
3471 /// effort to respond based on their local network view which may not be
3472 /// a perfect view of the network.
3473 #[must_use]
3474 #[repr(C)]
3475 pub struct ReplyShortChannelIdsEnd {
3476         /// Nearly everywhere, inner must be non-null, however in places where
3477         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3478         pub inner: *mut nativeReplyShortChannelIdsEnd,
3479         pub is_owned: bool,
3480 }
3481
3482 impl Drop for ReplyShortChannelIdsEnd {
3483         fn drop(&mut self) {
3484                 if self.is_owned && !self.inner.is_null() {
3485                         let _ = unsafe { Box::from_raw(self.inner) };
3486                 }
3487         }
3488 }
3489 #[no_mangle]
3490 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_ptr: ReplyShortChannelIdsEnd) { }
3491 #[allow(unused)]
3492 /// Used only if an object of this type is returned as a trait impl by a method
3493 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
3494         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
3495 }
3496 #[allow(unused)]
3497 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3498 impl ReplyShortChannelIdsEnd {
3499         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
3500                 assert!(self.is_owned);
3501                 let ret = self.inner;
3502                 self.inner = std::ptr::null_mut();
3503                 ret
3504         }
3505 }
3506 impl Clone for ReplyShortChannelIdsEnd {
3507         fn clone(&self) -> Self {
3508                 Self {
3509                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3510                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3511                         is_owned: true,
3512                 }
3513         }
3514 }
3515 #[allow(unused)]
3516 /// Used only if an object of this type is returned as a trait impl by a method
3517 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
3518         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
3519 }
3520 #[no_mangle]
3521 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
3522         orig.clone()
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
3557 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
3558 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
3559
3560 /// A gossip_timestamp_filter message is used by a node to request
3561 /// gossip relay for messages in the requested time range when the
3562 /// gossip_queries feature has been negotiated.
3563 #[must_use]
3564 #[repr(C)]
3565 pub struct GossipTimestampFilter {
3566         /// Nearly everywhere, inner must be non-null, however in places where
3567         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3568         pub inner: *mut nativeGossipTimestampFilter,
3569         pub is_owned: bool,
3570 }
3571
3572 impl Drop for GossipTimestampFilter {
3573         fn drop(&mut self) {
3574                 if self.is_owned && !self.inner.is_null() {
3575                         let _ = unsafe { Box::from_raw(self.inner) };
3576                 }
3577         }
3578 }
3579 #[no_mangle]
3580 pub extern "C" fn GossipTimestampFilter_free(this_ptr: GossipTimestampFilter) { }
3581 #[allow(unused)]
3582 /// Used only if an object of this type is returned as a trait impl by a method
3583 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
3584         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
3585 }
3586 #[allow(unused)]
3587 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3588 impl GossipTimestampFilter {
3589         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
3590                 assert!(self.is_owned);
3591                 let ret = self.inner;
3592                 self.inner = std::ptr::null_mut();
3593                 ret
3594         }
3595 }
3596 impl Clone for GossipTimestampFilter {
3597         fn clone(&self) -> Self {
3598                 Self {
3599                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3600                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3601                         is_owned: true,
3602                 }
3603         }
3604 }
3605 #[allow(unused)]
3606 /// Used only if an object of this type is returned as a trait impl by a method
3607 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
3608         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
3609 }
3610 #[no_mangle]
3611 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
3612         orig.clone()
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 /// Used to put an error message in a LightningError
3657 #[must_use]
3658 #[derive(Clone)]
3659 #[repr(C)]
3660 pub enum ErrorAction {
3661         /// The peer took some action which made us think they were useless. Disconnect them.
3662         DisconnectPeer {
3663                 msg: crate::ln::msgs::ErrorMessage,
3664         },
3665         /// The peer did something harmless that we weren't able to process, just log and ignore
3666         IgnoreError,
3667         /// The peer did something incorrect. Tell them.
3668         SendErrorMessage {
3669                 msg: crate::ln::msgs::ErrorMessage,
3670         },
3671 }
3672 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
3673 impl ErrorAction {
3674         #[allow(unused)]
3675         pub(crate) fn to_native(&self) -> nativeErrorAction {
3676                 match self {
3677                         ErrorAction::DisconnectPeer {ref msg, } => {
3678                                 let mut msg_nonref = (*msg).clone();
3679                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
3680                                 nativeErrorAction::DisconnectPeer {
3681                                         msg: local_msg_nonref,
3682                                 }
3683                         },
3684                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3685                         ErrorAction::SendErrorMessage {ref msg, } => {
3686                                 let mut msg_nonref = (*msg).clone();
3687                                 nativeErrorAction::SendErrorMessage {
3688                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3689                                 }
3690                         },
3691                 }
3692         }
3693         #[allow(unused)]
3694         pub(crate) fn into_native(self) -> nativeErrorAction {
3695                 match self {
3696                         ErrorAction::DisconnectPeer {mut msg, } => {
3697                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
3698                                 nativeErrorAction::DisconnectPeer {
3699                                         msg: local_msg,
3700                                 }
3701                         },
3702                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3703                         ErrorAction::SendErrorMessage {mut msg, } => {
3704                                 nativeErrorAction::SendErrorMessage {
3705                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3706                                 }
3707                         },
3708                 }
3709         }
3710         #[allow(unused)]
3711         pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
3712                 match native {
3713                         nativeErrorAction::DisconnectPeer {ref msg, } => {
3714                                 let mut msg_nonref = (*msg).clone();
3715                                 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 };
3716                                 ErrorAction::DisconnectPeer {
3717                                         msg: local_msg_nonref,
3718                                 }
3719                         },
3720                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3721                         nativeErrorAction::SendErrorMessage {ref msg, } => {
3722                                 let mut msg_nonref = (*msg).clone();
3723                                 ErrorAction::SendErrorMessage {
3724                                         msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3725                                 }
3726                         },
3727                 }
3728         }
3729         #[allow(unused)]
3730         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
3731                 match native {
3732                         nativeErrorAction::DisconnectPeer {mut msg, } => {
3733                                 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 };
3734                                 ErrorAction::DisconnectPeer {
3735                                         msg: local_msg,
3736                                 }
3737                         },
3738                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3739                         nativeErrorAction::SendErrorMessage {mut msg, } => {
3740                                 ErrorAction::SendErrorMessage {
3741                                         msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3742                                 }
3743                         },
3744                 }
3745         }
3746 }
3747 #[no_mangle]
3748 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
3749 #[no_mangle]
3750 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
3751         orig.clone()
3752 }
3753
3754 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
3755 type nativeLightningError = nativeLightningErrorImport;
3756
3757 /// An Err type for failure to process messages.
3758 #[must_use]
3759 #[repr(C)]
3760 pub struct LightningError {
3761         /// Nearly everywhere, inner must be non-null, however in places where
3762         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3763         pub inner: *mut nativeLightningError,
3764         pub is_owned: bool,
3765 }
3766
3767 impl Drop for LightningError {
3768         fn drop(&mut self) {
3769                 if self.is_owned && !self.inner.is_null() {
3770                         let _ = unsafe { Box::from_raw(self.inner) };
3771                 }
3772         }
3773 }
3774 #[no_mangle]
3775 pub extern "C" fn LightningError_free(this_ptr: LightningError) { }
3776 #[allow(unused)]
3777 /// Used only if an object of this type is returned as a trait impl by a method
3778 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
3779         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
3780 }
3781 #[allow(unused)]
3782 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3783 impl LightningError {
3784         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
3785                 assert!(self.is_owned);
3786                 let ret = self.inner;
3787                 self.inner = std::ptr::null_mut();
3788                 ret
3789         }
3790 }
3791 impl Clone for LightningError {
3792         fn clone(&self) -> Self {
3793                 Self {
3794                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3795                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3796                         is_owned: true,
3797                 }
3798         }
3799 }
3800 #[allow(unused)]
3801 /// Used only if an object of this type is returned as a trait impl by a method
3802 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
3803         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
3804 }
3805 #[no_mangle]
3806 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
3807         orig.clone()
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
3840 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
3841 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
3842
3843 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
3844 /// transaction updates if they were pending.
3845 #[must_use]
3846 #[repr(C)]
3847 pub struct CommitmentUpdate {
3848         /// Nearly everywhere, inner must be non-null, however in places where
3849         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3850         pub inner: *mut nativeCommitmentUpdate,
3851         pub is_owned: bool,
3852 }
3853
3854 impl Drop for CommitmentUpdate {
3855         fn drop(&mut self) {
3856                 if self.is_owned && !self.inner.is_null() {
3857                         let _ = unsafe { Box::from_raw(self.inner) };
3858                 }
3859         }
3860 }
3861 #[no_mangle]
3862 pub extern "C" fn CommitmentUpdate_free(this_ptr: CommitmentUpdate) { }
3863 #[allow(unused)]
3864 /// Used only if an object of this type is returned as a trait impl by a method
3865 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
3866         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
3867 }
3868 #[allow(unused)]
3869 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3870 impl CommitmentUpdate {
3871         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
3872                 assert!(self.is_owned);
3873                 let ret = self.inner;
3874                 self.inner = std::ptr::null_mut();
3875                 ret
3876         }
3877 }
3878 impl Clone for CommitmentUpdate {
3879         fn clone(&self) -> Self {
3880                 Self {
3881                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3882                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3883                         is_owned: true,
3884                 }
3885         }
3886 }
3887 #[allow(unused)]
3888 /// Used only if an object of this type is returned as a trait impl by a method
3889 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3890         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
3891 }
3892 #[no_mangle]
3893 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
3894         orig.clone()
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 /// The information we received from a peer along the route of a payment we originated. This is
3962 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
3963 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
3964 #[must_use]
3965 #[derive(Clone)]
3966 #[repr(C)]
3967 pub enum HTLCFailChannelUpdate {
3968         /// We received an error which included a full ChannelUpdate message.
3969         ChannelUpdateMessage {
3970                 msg: crate::ln::msgs::ChannelUpdate,
3971         },
3972         /// We received an error which indicated only that a channel has been closed
3973         ChannelClosed {
3974                 short_channel_id: u64,
3975                 is_permanent: bool,
3976         },
3977         /// We received an error which indicated only that a node has failed
3978         NodeFailure {
3979                 node_id: crate::c_types::PublicKey,
3980                 is_permanent: bool,
3981         },
3982 }
3983 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
3984 impl HTLCFailChannelUpdate {
3985         #[allow(unused)]
3986         pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
3987                 match self {
3988                         HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3989                                 let mut msg_nonref = (*msg).clone();
3990                                 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3991                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3992                                 }
3993                         },
3994                         HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3995                                 let mut short_channel_id_nonref = (*short_channel_id).clone();
3996                                 let mut is_permanent_nonref = (*is_permanent).clone();
3997                                 nativeHTLCFailChannelUpdate::ChannelClosed {
3998                                         short_channel_id: short_channel_id_nonref,
3999                                         is_permanent: is_permanent_nonref,
4000                                 }
4001                         },
4002                         HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4003                                 let mut node_id_nonref = (*node_id).clone();
4004                                 let mut is_permanent_nonref = (*is_permanent).clone();
4005                                 nativeHTLCFailChannelUpdate::NodeFailure {
4006                                         node_id: node_id_nonref.into_rust(),
4007                                         is_permanent: is_permanent_nonref,
4008                                 }
4009                         },
4010                 }
4011         }
4012         #[allow(unused)]
4013         pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
4014                 match self {
4015                         HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4016                                 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
4017                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
4018                                 }
4019                         },
4020                         HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4021                                 nativeHTLCFailChannelUpdate::ChannelClosed {
4022                                         short_channel_id: short_channel_id,
4023                                         is_permanent: is_permanent,
4024                                 }
4025                         },
4026                         HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4027                                 nativeHTLCFailChannelUpdate::NodeFailure {
4028                                         node_id: node_id.into_rust(),
4029                                         is_permanent: is_permanent,
4030                                 }
4031                         },
4032                 }
4033         }
4034         #[allow(unused)]
4035         pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
4036                 match native {
4037                         nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
4038                                 let mut msg_nonref = (*msg).clone();
4039                                 HTLCFailChannelUpdate::ChannelUpdateMessage {
4040                                         msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
4041                                 }
4042                         },
4043                         nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
4044                                 let mut short_channel_id_nonref = (*short_channel_id).clone();
4045                                 let mut is_permanent_nonref = (*is_permanent).clone();
4046                                 HTLCFailChannelUpdate::ChannelClosed {
4047                                         short_channel_id: short_channel_id_nonref,
4048                                         is_permanent: is_permanent_nonref,
4049                                 }
4050                         },
4051                         nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4052                                 let mut node_id_nonref = (*node_id).clone();
4053                                 let mut is_permanent_nonref = (*is_permanent).clone();
4054                                 HTLCFailChannelUpdate::NodeFailure {
4055                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
4056                                         is_permanent: is_permanent_nonref,
4057                                 }
4058                         },
4059                 }
4060         }
4061         #[allow(unused)]
4062         pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
4063                 match native {
4064                         nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4065                                 HTLCFailChannelUpdate::ChannelUpdateMessage {
4066                                         msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
4067                                 }
4068                         },
4069                         nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4070                                 HTLCFailChannelUpdate::ChannelClosed {
4071                                         short_channel_id: short_channel_id,
4072                                         is_permanent: is_permanent,
4073                                 }
4074                         },
4075                         nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4076                                 HTLCFailChannelUpdate::NodeFailure {
4077                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
4078                                         is_permanent: is_permanent,
4079                                 }
4080                         },
4081                 }
4082         }
4083 }
4084 #[no_mangle]
4085 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
4086 #[no_mangle]
4087 pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate {
4088         orig.clone()
4089 }
4090 /// A trait to describe an object which can receive channel messages.
4091 ///
4092 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4093 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4094 #[repr(C)]
4095 pub struct ChannelMessageHandler {
4096         pub this_arg: *mut c_void,
4097         /// Handle an incoming open_channel message from the given peer.
4098         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),
4099         /// Handle an incoming accept_channel message from the given peer.
4100         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),
4101         /// Handle an incoming funding_created message from the given peer.
4102         pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated),
4103         /// Handle an incoming funding_signed message from the given peer.
4104         pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned),
4105         /// Handle an incoming funding_locked message from the given peer.
4106         pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked),
4107         /// Handle an incoming shutdown message from the given peer.
4108         pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown),
4109         /// Handle an incoming closing_signed message from the given peer.
4110         pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned),
4111         /// Handle an incoming update_add_htlc message from the given peer.
4112         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),
4113         /// Handle an incoming update_fulfill_htlc message from the given peer.
4114         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),
4115         /// Handle an incoming update_fail_htlc message from the given peer.
4116         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),
4117         /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4118         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),
4119         /// Handle an incoming commitment_signed message from the given peer.
4120         pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned),
4121         /// Handle an incoming revoke_and_ack message from the given peer.
4122         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),
4123         /// Handle an incoming update_fee message from the given peer.
4124         pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee),
4125         /// Handle an incoming announcement_signatures message from the given peer.
4126         pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures),
4127         /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4128         /// is believed to be possible in the future (eg they're sending us messages we don't
4129         /// understand or indicate they require unknown feature bits), no_connection_possible is set
4130         /// and any outstanding channels should be failed.
4131         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4132         /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4133         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Init),
4134         /// Handle an incoming channel_reestablish message from the given peer.
4135         pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish),
4136         /// Handle an incoming error message from the given peer.
4137         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage),
4138         pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
4139         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4140 }
4141 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4142         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4143                 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
4144         }
4145 }
4146 unsafe impl Send for ChannelMessageHandler {}
4147 unsafe impl Sync for ChannelMessageHandler {}
4148
4149 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4150 impl rustChannelMessageHandler for ChannelMessageHandler {
4151         fn handle_open_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::OpenChannel) {
4152                 (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 })
4153         }
4154         fn handle_accept_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::AcceptChannel) {
4155                 (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 })
4156         }
4157         fn handle_funding_created(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingCreated) {
4158                 (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 })
4159         }
4160         fn handle_funding_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingSigned) {
4161                 (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 })
4162         }
4163         fn handle_funding_locked(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingLocked) {
4164                 (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 })
4165         }
4166         fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Shutdown) {
4167                 (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::Shutdown { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4168         }
4169         fn handle_closing_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ClosingSigned) {
4170                 (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 })
4171         }
4172         fn handle_update_add_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateAddHTLC) {
4173                 (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 })
4174         }
4175         fn handle_update_fulfill_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4176                 (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 })
4177         }
4178         fn handle_update_fail_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailHTLC) {
4179                 (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 })
4180         }
4181         fn handle_update_fail_malformed_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4182                 (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 })
4183         }
4184         fn handle_commitment_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::CommitmentSigned) {
4185                 (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 })
4186         }
4187         fn handle_revoke_and_ack(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::RevokeAndACK) {
4188                 (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 })
4189         }
4190         fn handle_update_fee(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFee) {
4191                 (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 })
4192         }
4193         fn handle_announcement_signatures(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::AnnouncementSignatures) {
4194                 (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 })
4195         }
4196         fn peer_disconnected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, no_connection_possible: bool) {
4197                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4198         }
4199         fn peer_connected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Init) {
4200                 (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 })
4201         }
4202         fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) {
4203                 (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 })
4204         }
4205         fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) {
4206                 (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 })
4207         }
4208 }
4209
4210 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4211 // directly as a Deref trait in higher-level structs:
4212 impl std::ops::Deref for ChannelMessageHandler {
4213         type Target = Self;
4214         fn deref(&self) -> &Self {
4215                 self
4216         }
4217 }
4218 /// Calls the free function if one is set
4219 #[no_mangle]
4220 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4221 impl Drop for ChannelMessageHandler {
4222         fn drop(&mut self) {
4223                 if let Some(f) = self.free {
4224                         f(self.this_arg);
4225                 }
4226         }
4227 }
4228 /// A trait to describe an object which can receive routing messages.
4229 ///
4230 /// # Implementor DoS Warnings
4231 ///
4232 /// For `gossip_queries` messages there are potential DoS vectors when handling
4233 /// inbound queries. Implementors using an on-disk network graph should be aware of
4234 /// repeated disk I/O for queries accessing different parts of the network graph.
4235 #[repr(C)]
4236 pub struct RoutingMessageHandler {
4237         pub this_arg: *mut c_void,
4238         /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4239         /// false or returning an Err otherwise.
4240         #[must_use]
4241         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4242         /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4243         /// or returning an Err otherwise.
4244         #[must_use]
4245         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4246         /// Handle an incoming channel_update message, returning true if it should be forwarded on,
4247         /// false or returning an Err otherwise.
4248         #[must_use]
4249         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4250         /// Handle some updates to the route graph that we learned due to an outbound failed payment.
4251         pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate),
4252         /// Gets a subset of the channel announcements and updates required to dump our routing table
4253         /// to a remote node, starting at the short_channel_id indicated by starting_point and
4254         /// including the batch_amount entries immediately higher in numerical value than starting_point.
4255         #[must_use]
4256         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,
4257         /// Gets a subset of the node announcements required to dump our routing table to a remote node,
4258         /// starting at the node *after* the provided publickey and including batch_amount entries
4259         /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
4260         /// If None is provided for starting_point, we start at the first node.
4261         #[must_use]
4262         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,
4263         /// Called when a connection is established with a peer. This can be used to
4264         /// perform routing table synchronization using a strategy defined by the
4265         /// implementor.
4266         pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::ln::msgs::Init),
4267         /// Handles the reply of a query we initiated to learn about channels
4268         /// for a given range of blocks. We can expect to receive one or more
4269         /// replies to a single query.
4270         #[must_use]
4271         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,
4272         /// Handles the reply of a query we initiated asking for routing gossip
4273         /// messages for a list of channels. We should receive this message when
4274         /// a node has completed its best effort to send us the pertaining routing
4275         /// gossip messages.
4276         #[must_use]
4277         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,
4278         /// Handles when a peer asks us to send a list of short_channel_ids
4279         /// for the requested range of blocks.
4280         #[must_use]
4281         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,
4282         /// Handles when a peer asks us to send routing gossip messages for a
4283         /// list of short_channel_ids.
4284         #[must_use]
4285         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,
4286         pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
4287         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4288 }
4289 unsafe impl Send for RoutingMessageHandler {}
4290 unsafe impl Sync for RoutingMessageHandler {}
4291 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
4292         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4293                 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
4294         }
4295 }
4296
4297 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
4298 impl rustRoutingMessageHandler for RoutingMessageHandler {
4299         fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4300                 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::ln::msgs::NodeAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4301                 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()) } })};
4302                 local_ret
4303         }
4304         fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4305                 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4306                 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()) } })};
4307                 local_ret
4308         }
4309         fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
4310                 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4311                 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()) } })};
4312                 local_ret
4313         }
4314         fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
4315                 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::ln::msgs::HTLCFailChannelUpdate::from_native(&update))
4316         }
4317         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>)> {
4318                 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
4319                 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 }); };
4320                 local_ret
4321         }
4322         fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
4323                 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())) } };
4324                 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
4325                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4326                 local_ret
4327         }
4328         fn sync_routing_table(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, init: &lightning::ln::msgs::Init) {
4329                 (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 })
4330         }
4331         fn handle_reply_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
4332                 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 });
4333                 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()) } })};
4334                 local_ret
4335         }
4336         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> {
4337                 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 });
4338                 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()) } })};
4339                 local_ret
4340         }
4341         fn handle_query_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
4342                 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 });
4343                 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()) } })};
4344                 local_ret
4345         }
4346         fn handle_query_short_channel_ids(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
4347                 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 });
4348                 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()) } })};
4349                 local_ret
4350         }
4351 }
4352
4353 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4354 // directly as a Deref trait in higher-level structs:
4355 impl std::ops::Deref for RoutingMessageHandler {
4356         type Target = Self;
4357         fn deref(&self) -> &Self {
4358                 self
4359         }
4360 }
4361 /// Calls the free function if one is set
4362 #[no_mangle]
4363 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
4364 impl Drop for RoutingMessageHandler {
4365         fn drop(&mut self) {
4366                 if let Some(f) = self.free {
4367                         f(self.this_arg);
4368                 }
4369         }
4370 }
4371 #[no_mangle]
4372 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
4373         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4374 }
4375 #[no_mangle]
4376 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4377         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
4378 }
4379 #[no_mangle]
4380 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> AcceptChannel {
4381         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4382                 AcceptChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4383         } else {
4384                 AcceptChannel { inner: std::ptr::null_mut(), is_owned: true }
4385         }
4386 }
4387 #[no_mangle]
4388 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
4389         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4390 }
4391 #[no_mangle]
4392 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4393         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
4394 }
4395 #[no_mangle]
4396 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> AnnouncementSignatures {
4397         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4398                 AnnouncementSignatures { inner: Box::into_raw(Box::new(res)), is_owned: true }
4399         } else {
4400                 AnnouncementSignatures { inner: std::ptr::null_mut(), is_owned: true }
4401         }
4402 }
4403 #[no_mangle]
4404 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> 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 ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4409         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
4410 }
4411 #[no_mangle]
4412 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
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::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() };
4415         local_res
4416 }
4417 #[no_mangle]
4418 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
4419         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4420 }
4421 #[no_mangle]
4422 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4423         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
4424 }
4425 #[no_mangle]
4426 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> ClosingSigned {
4427         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4428                 ClosingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4429         } else {
4430                 ClosingSigned { inner: std::ptr::null_mut(), is_owned: true }
4431         }
4432 }
4433 #[no_mangle]
4434 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
4435         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4436 }
4437 #[no_mangle]
4438 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4439         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
4440 }
4441 #[no_mangle]
4442 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> CommitmentSigned {
4443         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4444                 CommitmentSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4445         } else {
4446                 CommitmentSigned { inner: std::ptr::null_mut(), is_owned: true }
4447         }
4448 }
4449 #[no_mangle]
4450 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
4451         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4452 }
4453 #[no_mangle]
4454 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4455         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
4456 }
4457 #[no_mangle]
4458 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> FundingCreated {
4459         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4460                 FundingCreated { inner: Box::into_raw(Box::new(res)), is_owned: true }
4461         } else {
4462                 FundingCreated { inner: std::ptr::null_mut(), is_owned: true }
4463         }
4464 }
4465 #[no_mangle]
4466 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
4467         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4468 }
4469 #[no_mangle]
4470 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4471         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
4472 }
4473 #[no_mangle]
4474 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> FundingSigned {
4475         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4476                 FundingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4477         } else {
4478                 FundingSigned { inner: std::ptr::null_mut(), is_owned: true }
4479         }
4480 }
4481 #[no_mangle]
4482 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
4483         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4484 }
4485 #[no_mangle]
4486 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4487         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
4488 }
4489 #[no_mangle]
4490 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> FundingLocked {
4491         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4492                 FundingLocked { inner: Box::into_raw(Box::new(res)), is_owned: true }
4493         } else {
4494                 FundingLocked { inner: std::ptr::null_mut(), is_owned: true }
4495         }
4496 }
4497 #[no_mangle]
4498 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
4499         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4500 }
4501 #[no_mangle]
4502 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4503         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
4504 }
4505 #[no_mangle]
4506 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
4507         let res = crate::c_types::deserialize_obj(ser);
4508         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() };
4509         local_res
4510 }
4511 #[no_mangle]
4512 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
4513         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4514 }
4515 #[no_mangle]
4516 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4517         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
4518 }
4519 #[no_mangle]
4520 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> OpenChannel {
4521         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4522                 OpenChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4523         } else {
4524                 OpenChannel { inner: std::ptr::null_mut(), is_owned: true }
4525         }
4526 }
4527 #[no_mangle]
4528 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
4529         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4530 }
4531 #[no_mangle]
4532 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4533         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
4534 }
4535 #[no_mangle]
4536 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> RevokeAndACK {
4537         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4538                 RevokeAndACK { inner: Box::into_raw(Box::new(res)), is_owned: true }
4539         } else {
4540                 RevokeAndACK { inner: std::ptr::null_mut(), is_owned: true }
4541         }
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 { &(*(*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) -> Shutdown {
4553         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4554                 Shutdown { inner: Box::into_raw(Box::new(res)), is_owned: true }
4555         } else {
4556                 Shutdown { inner: std::ptr::null_mut(), is_owned: true }
4557         }
4558 }
4559 #[no_mangle]
4560 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
4561         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4562 }
4563 #[no_mangle]
4564 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4565         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
4566 }
4567 #[no_mangle]
4568 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailHTLC {
4569         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4570                 UpdateFailHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4571         } else {
4572                 UpdateFailHTLC { inner: std::ptr::null_mut(), is_owned: true }
4573         }
4574 }
4575 #[no_mangle]
4576 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
4577         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4578 }
4579 #[no_mangle]
4580 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4581         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
4582 }
4583 #[no_mangle]
4584 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailMalformedHTLC {
4585         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4586                 UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4587         } else {
4588                 UpdateFailMalformedHTLC { inner: std::ptr::null_mut(), is_owned: true }
4589         }
4590 }
4591 #[no_mangle]
4592 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
4593         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4594 }
4595 #[no_mangle]
4596 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4597         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
4598 }
4599 #[no_mangle]
4600 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> UpdateFee {
4601         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4602                 UpdateFee { inner: Box::into_raw(Box::new(res)), is_owned: true }
4603         } else {
4604                 UpdateFee { inner: std::ptr::null_mut(), is_owned: true }
4605         }
4606 }
4607 #[no_mangle]
4608 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
4609         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4610 }
4611 #[no_mangle]
4612 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4613         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
4614 }
4615 #[no_mangle]
4616 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> UpdateFulfillHTLC {
4617         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4618                 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4619         } else {
4620                 UpdateFulfillHTLC { inner: std::ptr::null_mut(), is_owned: true }
4621         }
4622 }
4623 #[no_mangle]
4624 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
4625         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4626 }
4627 #[no_mangle]
4628 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4629         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
4630 }
4631 #[no_mangle]
4632 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> UpdateAddHTLC {
4633         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4634                 UpdateAddHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4635         } else {
4636                 UpdateAddHTLC { inner: std::ptr::null_mut(), is_owned: true }
4637         }
4638 }
4639 #[no_mangle]
4640 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
4641         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4642 }
4643 #[no_mangle]
4644 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4645         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
4646 }
4647 #[no_mangle]
4648 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
4649         let res = crate::c_types::deserialize_obj(ser);
4650         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() };
4651         local_res
4652 }
4653 #[no_mangle]
4654 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
4655         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4656 }
4657 #[no_mangle]
4658 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4659         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
4660 }
4661 #[no_mangle]
4662 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
4663         let res = crate::c_types::deserialize_obj(ser);
4664         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() };
4665         local_res
4666 }
4667 #[no_mangle]
4668 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4669         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4670 }
4671 #[no_mangle]
4672 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4673         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
4674 }
4675 #[no_mangle]
4676 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
4677         let res = crate::c_types::deserialize_obj(ser);
4678         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() };
4679         local_res
4680 }
4681 #[no_mangle]
4682 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4683         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4684 }
4685 #[no_mangle]
4686 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4687         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
4688 }
4689 #[no_mangle]
4690 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> ChannelAnnouncement {
4691         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4692                 ChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4693         } else {
4694                 ChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4695         }
4696 }
4697 #[no_mangle]
4698 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> 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 UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4703         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
4704 }
4705 #[no_mangle]
4706 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
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::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() };
4709         local_res
4710 }
4711 #[no_mangle]
4712 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4713         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4714 }
4715 #[no_mangle]
4716 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4717         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
4718 }
4719 #[no_mangle]
4720 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> ChannelUpdate {
4721         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4722                 ChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
4723         } else {
4724                 ChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
4725         }
4726 }
4727 #[no_mangle]
4728 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
4729         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4730 }
4731 #[no_mangle]
4732 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4733         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
4734 }
4735 #[no_mangle]
4736 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
4737         let res = crate::c_types::deserialize_obj(ser);
4738         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() };
4739         local_res
4740 }
4741 #[no_mangle]
4742 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4743         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4744 }
4745 #[no_mangle]
4746 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4747         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
4748 }
4749 #[no_mangle]
4750 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
4751         let res = crate::c_types::deserialize_obj(ser);
4752         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() };
4753         local_res
4754 }
4755 #[no_mangle]
4756 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4757         crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4758 }
4759 #[no_mangle]
4760 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4761         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
4762 }
4763 #[no_mangle]
4764 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> NodeAnnouncement {
4765         if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4766                 NodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4767         } else {
4768                 NodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4769         }
4770 }
4771 #[no_mangle]
4772 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
4773         let res = crate::c_types::deserialize_obj(ser);
4774         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() };
4775         local_res
4776 }
4777 #[no_mangle]
4778 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
4779         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4780 }
4781 #[no_mangle]
4782 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4783         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
4784 }
4785 #[no_mangle]
4786 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
4787         let res = crate::c_types::deserialize_obj(ser);
4788         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() };
4789         local_res
4790 }
4791 #[no_mangle]
4792 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
4793         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4794 }
4795 #[no_mangle]
4796 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4797         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
4798 }
4799 #[no_mangle]
4800 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
4801         let res = crate::c_types::deserialize_obj(ser);
4802         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() };
4803         local_res
4804 }
4805 #[no_mangle]
4806 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
4807         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4808 }
4809 #[no_mangle]
4810 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4811         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
4812 }
4813 #[no_mangle]
4814 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
4815         let res = crate::c_types::deserialize_obj(ser);
4816         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() };
4817         local_res
4818 }
4819 #[no_mangle]
4820 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
4821         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4822 }
4823 #[no_mangle]
4824 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4825         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
4826 }
4827 #[no_mangle]
4828 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
4829         let res = crate::c_types::deserialize_obj(ser);
4830         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() };
4831         local_res
4832 }
4833 #[no_mangle]
4834 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
4835         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4836 }
4837 #[no_mangle]
4838 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4839         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
4840 }