308730f53508a6af72c653557fe7b10470f1309c
[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 /// The channel ID involved in the error
173 #[no_mangle]
174 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
175         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
176         &(*inner_val)
177 }
178 /// The channel ID involved in the error
179 #[no_mangle]
180 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
181         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
182 }
183 /// A possibly human-readable error description.
184 /// The string should be sanitized before it is used (e.g. emitted to logs
185 /// or printed to stdout).  Otherwise, a well crafted error message may trigger a security
186 /// vulnerability in the terminal emulator or the logging subsystem.
187 #[no_mangle]
188 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
189         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.data;
190         (*inner_val).as_str().into()
191 }
192 /// A possibly human-readable error description.
193 /// The string should be sanitized before it is used (e.g. emitted to logs
194 /// or printed to stdout).  Otherwise, a well crafted error message may trigger a security
195 /// vulnerability in the terminal emulator or the logging subsystem.
196 #[no_mangle]
197 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::derived::CVec_u8Z) {
198         unsafe { &mut *this_ptr.inner }.data = String::from_utf8(val.into_rust()).unwrap();
199 }
200 #[must_use]
201 #[no_mangle]
202 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> ErrorMessage {
203         ErrorMessage { inner: Box::into_raw(Box::new(nativeErrorMessage {
204                 channel_id: channel_id_arg.data,
205                 data: String::from_utf8(data_arg.into_rust()).unwrap(),
206         })), is_owned: true }
207 }
208 impl Clone for ErrorMessage {
209         fn clone(&self) -> Self {
210                 Self {
211                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
212                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
213                         is_owned: true,
214                 }
215         }
216 }
217 #[allow(unused)]
218 /// Used only if an object of this type is returned as a trait impl by a method
219 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
220         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
221 }
222 #[no_mangle]
223 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
224         orig.clone()
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 /// The desired response length
265 #[no_mangle]
266 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
267         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.ponglen;
268         (*inner_val)
269 }
270 /// The desired response length
271 #[no_mangle]
272 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
273         unsafe { &mut *this_ptr.inner }.ponglen = val;
274 }
275 /// The ping packet size.
276 /// This field is not sent on the wire. byteslen zeros are sent.
277 #[no_mangle]
278 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
279         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
280         (*inner_val)
281 }
282 /// The ping packet size.
283 /// This field is not sent on the wire. byteslen zeros are sent.
284 #[no_mangle]
285 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
286         unsafe { &mut *this_ptr.inner }.byteslen = val;
287 }
288 #[must_use]
289 #[no_mangle]
290 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
291         Ping { inner: Box::into_raw(Box::new(nativePing {
292                 ponglen: ponglen_arg,
293                 byteslen: byteslen_arg,
294         })), is_owned: true }
295 }
296 impl Clone for Ping {
297         fn clone(&self) -> Self {
298                 Self {
299                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
300                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
301                         is_owned: true,
302                 }
303         }
304 }
305 #[allow(unused)]
306 /// Used only if an object of this type is returned as a trait impl by a method
307 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
308         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
309 }
310 #[no_mangle]
311 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
312         orig.clone()
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 /// The pong packet size.
353 /// This field is not sent on the wire. byteslen zeros are sent.
354 #[no_mangle]
355 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
356         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
357         (*inner_val)
358 }
359 /// The pong packet size.
360 /// This field is not sent on the wire. byteslen zeros are sent.
361 #[no_mangle]
362 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
363         unsafe { &mut *this_ptr.inner }.byteslen = val;
364 }
365 #[must_use]
366 #[no_mangle]
367 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
368         Pong { inner: Box::into_raw(Box::new(nativePong {
369                 byteslen: byteslen_arg,
370         })), is_owned: true }
371 }
372 impl Clone for Pong {
373         fn clone(&self) -> Self {
374                 Self {
375                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
376                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
377                         is_owned: true,
378                 }
379         }
380 }
381 #[allow(unused)]
382 /// Used only if an object of this type is returned as a trait impl by a method
383 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
384         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
385 }
386 #[no_mangle]
387 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
388         orig.clone()
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 /// The genesis hash of the blockchain where the channel is to be opened
429 #[no_mangle]
430 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
431         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
432         (*inner_val).as_inner()
433 }
434 /// The genesis hash of the blockchain where the channel is to be opened
435 #[no_mangle]
436 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
437         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
438 }
439 /// A temporary channel ID, until the funding outpoint is announced
440 #[no_mangle]
441 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
442         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
443         &(*inner_val)
444 }
445 /// A temporary channel ID, until the funding outpoint is announced
446 #[no_mangle]
447 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
448         unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
449 }
450 /// The channel value
451 #[no_mangle]
452 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
453         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_satoshis;
454         (*inner_val)
455 }
456 /// The channel value
457 #[no_mangle]
458 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
459         unsafe { &mut *this_ptr.inner }.funding_satoshis = val;
460 }
461 /// The amount to push to the counterparty as part of the open, in milli-satoshi
462 #[no_mangle]
463 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
464         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.push_msat;
465         (*inner_val)
466 }
467 /// The amount to push to the counterparty as part of the open, in milli-satoshi
468 #[no_mangle]
469 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
470         unsafe { &mut *this_ptr.inner }.push_msat = val;
471 }
472 /// The threshold below which outputs on transactions broadcast by sender will be omitted
473 #[no_mangle]
474 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
475         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
476         (*inner_val)
477 }
478 /// The threshold below which outputs on transactions broadcast by sender will be omitted
479 #[no_mangle]
480 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
481         unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
482 }
483 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
484 #[no_mangle]
485 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
486         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
487         (*inner_val)
488 }
489 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
490 #[no_mangle]
491 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
492         unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
493 }
494 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
495 #[no_mangle]
496 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
497         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
498         (*inner_val)
499 }
500 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
501 #[no_mangle]
502 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
503         unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
504 }
505 /// The minimum HTLC size incoming to sender, in milli-satoshi
506 #[no_mangle]
507 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
508         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
509         (*inner_val)
510 }
511 /// The minimum HTLC size incoming to sender, in milli-satoshi
512 #[no_mangle]
513 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
514         unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
515 }
516 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
517 #[no_mangle]
518 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
519         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
520         (*inner_val)
521 }
522 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
523 #[no_mangle]
524 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
525         unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
526 }
527 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
528 #[no_mangle]
529 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
530         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
531         (*inner_val)
532 }
533 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
534 #[no_mangle]
535 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
536         unsafe { &mut *this_ptr.inner }.to_self_delay = val;
537 }
538 /// The maximum number of inbound HTLCs towards sender
539 #[no_mangle]
540 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
541         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
542         (*inner_val)
543 }
544 /// The maximum number of inbound HTLCs towards sender
545 #[no_mangle]
546 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
547         unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
548 }
549 /// The sender's key controlling the funding transaction
550 #[no_mangle]
551 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
552         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
553         crate::c_types::PublicKey::from_rust(&(*inner_val))
554 }
555 /// The sender's key controlling the funding transaction
556 #[no_mangle]
557 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
558         unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
559 }
560 /// Used to derive a revocation key for transactions broadcast by counterparty
561 #[no_mangle]
562 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
563         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
564         crate::c_types::PublicKey::from_rust(&(*inner_val))
565 }
566 /// Used to derive a revocation key for transactions broadcast by counterparty
567 #[no_mangle]
568 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
569         unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
570 }
571 /// A payment key to sender for transactions broadcast by counterparty
572 #[no_mangle]
573 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
574         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
575         crate::c_types::PublicKey::from_rust(&(*inner_val))
576 }
577 /// A payment key to sender for transactions broadcast by counterparty
578 #[no_mangle]
579 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
580         unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
581 }
582 /// Used to derive a payment key to sender for transactions broadcast by sender
583 #[no_mangle]
584 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
585         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
586         crate::c_types::PublicKey::from_rust(&(*inner_val))
587 }
588 /// Used to derive a payment key to sender for transactions broadcast by sender
589 #[no_mangle]
590 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
591         unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
592 }
593 /// Used to derive an HTLC payment key to sender
594 #[no_mangle]
595 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
596         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
597         crate::c_types::PublicKey::from_rust(&(*inner_val))
598 }
599 /// Used to derive an HTLC payment key to sender
600 #[no_mangle]
601 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
602         unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
603 }
604 /// The first to-be-broadcast-by-sender transaction's per commitment point
605 #[no_mangle]
606 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
607         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
608         crate::c_types::PublicKey::from_rust(&(*inner_val))
609 }
610 /// The first to-be-broadcast-by-sender transaction's per commitment point
611 #[no_mangle]
612 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
613         unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
614 }
615 /// Channel flags
616 #[no_mangle]
617 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
618         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_flags;
619         (*inner_val)
620 }
621 /// Channel flags
622 #[no_mangle]
623 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
624         unsafe { &mut *this_ptr.inner }.channel_flags = val;
625 }
626 impl Clone for OpenChannel {
627         fn clone(&self) -> Self {
628                 Self {
629                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
630                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
631                         is_owned: true,
632                 }
633         }
634 }
635 #[allow(unused)]
636 /// Used only if an object of this type is returned as a trait impl by a method
637 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
638         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
639 }
640 #[no_mangle]
641 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
642         orig.clone()
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 /// A temporary channel ID, until the funding outpoint is announced
683 #[no_mangle]
684 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
685         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
686         &(*inner_val)
687 }
688 /// A temporary channel ID, until the funding outpoint is announced
689 #[no_mangle]
690 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
691         unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
692 }
693 /// The threshold below which outputs on transactions broadcast by sender will be omitted
694 #[no_mangle]
695 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
696         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
697         (*inner_val)
698 }
699 /// The threshold below which outputs on transactions broadcast by sender will be omitted
700 #[no_mangle]
701 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
702         unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
703 }
704 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
705 #[no_mangle]
706 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
707         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
708         (*inner_val)
709 }
710 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
711 #[no_mangle]
712 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
713         unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
714 }
715 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
716 #[no_mangle]
717 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
718         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
719         (*inner_val)
720 }
721 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
722 #[no_mangle]
723 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
724         unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
725 }
726 /// The minimum HTLC size incoming to sender, in milli-satoshi
727 #[no_mangle]
728 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
729         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
730         (*inner_val)
731 }
732 /// The minimum HTLC size incoming to sender, in milli-satoshi
733 #[no_mangle]
734 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
735         unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
736 }
737 /// Minimum depth of the funding transaction before the channel is considered open
738 #[no_mangle]
739 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
740         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth;
741         (*inner_val)
742 }
743 /// Minimum depth of the funding transaction before the channel is considered open
744 #[no_mangle]
745 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
746         unsafe { &mut *this_ptr.inner }.minimum_depth = val;
747 }
748 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
749 #[no_mangle]
750 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
751         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
752         (*inner_val)
753 }
754 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
755 #[no_mangle]
756 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
757         unsafe { &mut *this_ptr.inner }.to_self_delay = val;
758 }
759 /// The maximum number of inbound HTLCs towards sender
760 #[no_mangle]
761 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
762         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
763         (*inner_val)
764 }
765 /// The maximum number of inbound HTLCs towards sender
766 #[no_mangle]
767 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
768         unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
769 }
770 /// The sender's key controlling the funding transaction
771 #[no_mangle]
772 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
773         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
774         crate::c_types::PublicKey::from_rust(&(*inner_val))
775 }
776 /// The sender's key controlling the funding transaction
777 #[no_mangle]
778 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
779         unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
780 }
781 /// Used to derive a revocation key for transactions broadcast by counterparty
782 #[no_mangle]
783 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
784         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
785         crate::c_types::PublicKey::from_rust(&(*inner_val))
786 }
787 /// Used to derive a revocation key for transactions broadcast by counterparty
788 #[no_mangle]
789 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
790         unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
791 }
792 /// A payment key to sender for transactions broadcast by counterparty
793 #[no_mangle]
794 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
795         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
796         crate::c_types::PublicKey::from_rust(&(*inner_val))
797 }
798 /// A payment key to sender for transactions broadcast by counterparty
799 #[no_mangle]
800 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
801         unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
802 }
803 /// Used to derive a payment key to sender for transactions broadcast by sender
804 #[no_mangle]
805 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
806         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
807         crate::c_types::PublicKey::from_rust(&(*inner_val))
808 }
809 /// Used to derive a payment key to sender for transactions broadcast by sender
810 #[no_mangle]
811 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
812         unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
813 }
814 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
815 #[no_mangle]
816 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
817         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
818         crate::c_types::PublicKey::from_rust(&(*inner_val))
819 }
820 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
821 #[no_mangle]
822 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
823         unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
824 }
825 /// The first to-be-broadcast-by-sender transaction's per commitment point
826 #[no_mangle]
827 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
828         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
829         crate::c_types::PublicKey::from_rust(&(*inner_val))
830 }
831 /// The first to-be-broadcast-by-sender transaction's per commitment point
832 #[no_mangle]
833 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
834         unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
835 }
836 impl Clone for AcceptChannel {
837         fn clone(&self) -> Self {
838                 Self {
839                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
840                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
841                         is_owned: true,
842                 }
843         }
844 }
845 #[allow(unused)]
846 /// Used only if an object of this type is returned as a trait impl by a method
847 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
848         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
849 }
850 #[no_mangle]
851 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
852         orig.clone()
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 /// A temporary channel ID, until the funding is established
893 #[no_mangle]
894 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
895         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
896         &(*inner_val)
897 }
898 /// A temporary channel ID, until the funding is established
899 #[no_mangle]
900 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
901         unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
902 }
903 /// The funding transaction ID
904 #[no_mangle]
905 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
906         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_txid;
907         (*inner_val).as_inner()
908 }
909 /// The funding transaction ID
910 #[no_mangle]
911 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
912         unsafe { &mut *this_ptr.inner }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
913 }
914 /// The specific output index funding this channel
915 #[no_mangle]
916 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
917         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_output_index;
918         (*inner_val)
919 }
920 /// The specific output index funding this channel
921 #[no_mangle]
922 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
923         unsafe { &mut *this_ptr.inner }.funding_output_index = val;
924 }
925 /// The signature of the channel initiator (funder) on the funding transaction
926 #[no_mangle]
927 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
928         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
929         crate::c_types::Signature::from_rust(&(*inner_val))
930 }
931 /// The signature of the channel initiator (funder) on the funding transaction
932 #[no_mangle]
933 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
934         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
935 }
936 #[must_use]
937 #[no_mangle]
938 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 {
939         FundingCreated { inner: Box::into_raw(Box::new(nativeFundingCreated {
940                 temporary_channel_id: temporary_channel_id_arg.data,
941                 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
942                 funding_output_index: funding_output_index_arg,
943                 signature: signature_arg.into_rust(),
944         })), is_owned: true }
945 }
946 impl Clone for FundingCreated {
947         fn clone(&self) -> Self {
948                 Self {
949                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
950                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
951                         is_owned: true,
952                 }
953         }
954 }
955 #[allow(unused)]
956 /// Used only if an object of this type is returned as a trait impl by a method
957 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
958         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
959 }
960 #[no_mangle]
961 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
962         orig.clone()
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 /// The channel ID
1003 #[no_mangle]
1004 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1005         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1006         &(*inner_val)
1007 }
1008 /// The channel ID
1009 #[no_mangle]
1010 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1011         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1012 }
1013 /// The signature of the channel acceptor (fundee) on the funding transaction
1014 #[no_mangle]
1015 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1016         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1017         crate::c_types::Signature::from_rust(&(*inner_val))
1018 }
1019 /// The signature of the channel acceptor (fundee) on the funding transaction
1020 #[no_mangle]
1021 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1022         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1023 }
1024 #[must_use]
1025 #[no_mangle]
1026 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1027         FundingSigned { inner: Box::into_raw(Box::new(nativeFundingSigned {
1028                 channel_id: channel_id_arg.data,
1029                 signature: signature_arg.into_rust(),
1030         })), is_owned: true }
1031 }
1032 impl Clone for FundingSigned {
1033         fn clone(&self) -> Self {
1034                 Self {
1035                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1036                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1037                         is_owned: true,
1038                 }
1039         }
1040 }
1041 #[allow(unused)]
1042 /// Used only if an object of this type is returned as a trait impl by a method
1043 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1044         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1045 }
1046 #[no_mangle]
1047 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1048         orig.clone()
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 /// The channel ID
1089 #[no_mangle]
1090 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1091         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1092         &(*inner_val)
1093 }
1094 /// The channel ID
1095 #[no_mangle]
1096 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1097         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1098 }
1099 /// The per-commitment point of the second commitment transaction
1100 #[no_mangle]
1101 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1102         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
1103         crate::c_types::PublicKey::from_rust(&(*inner_val))
1104 }
1105 /// The per-commitment point of the second commitment transaction
1106 #[no_mangle]
1107 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1108         unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
1109 }
1110 #[must_use]
1111 #[no_mangle]
1112 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 {
1113         FundingLocked { inner: Box::into_raw(Box::new(nativeFundingLocked {
1114                 channel_id: channel_id_arg.data,
1115                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1116         })), is_owned: true }
1117 }
1118 impl Clone for FundingLocked {
1119         fn clone(&self) -> Self {
1120                 Self {
1121                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1122                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1123                         is_owned: true,
1124                 }
1125         }
1126 }
1127 #[allow(unused)]
1128 /// Used only if an object of this type is returned as a trait impl by a method
1129 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1130         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1131 }
1132 #[no_mangle]
1133 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1134         orig.clone()
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 /// The channel ID
1175 #[no_mangle]
1176 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1177         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1178         &(*inner_val)
1179 }
1180 /// The channel ID
1181 #[no_mangle]
1182 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1183         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1184 }
1185 /// The destination of this peer's funds on closing.
1186 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1187 #[no_mangle]
1188 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1189         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.scriptpubkey;
1190         crate::c_types::u8slice::from_slice(&(*inner_val)[..])
1191 }
1192 /// The destination of this peer's funds on closing.
1193 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1194 #[no_mangle]
1195 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1196         unsafe { &mut *this_ptr.inner }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1197 }
1198 #[must_use]
1199 #[no_mangle]
1200 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1201         Shutdown { inner: Box::into_raw(Box::new(nativeShutdown {
1202                 channel_id: channel_id_arg.data,
1203                 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1204         })), is_owned: true }
1205 }
1206 impl Clone for Shutdown {
1207         fn clone(&self) -> Self {
1208                 Self {
1209                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1210                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1211                         is_owned: true,
1212                 }
1213         }
1214 }
1215 #[allow(unused)]
1216 /// Used only if an object of this type is returned as a trait impl by a method
1217 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1218         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1219 }
1220 #[no_mangle]
1221 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1222         orig.clone()
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 /// The channel ID
1263 #[no_mangle]
1264 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1265         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1266         &(*inner_val)
1267 }
1268 /// The channel ID
1269 #[no_mangle]
1270 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1271         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1272 }
1273 /// The proposed total fee for the closing transaction
1274 #[no_mangle]
1275 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1276         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_satoshis;
1277         (*inner_val)
1278 }
1279 /// The proposed total fee for the closing transaction
1280 #[no_mangle]
1281 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1282         unsafe { &mut *this_ptr.inner }.fee_satoshis = val;
1283 }
1284 /// A signature on the closing transaction
1285 #[no_mangle]
1286 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1287         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1288         crate::c_types::Signature::from_rust(&(*inner_val))
1289 }
1290 /// A signature on the closing transaction
1291 #[no_mangle]
1292 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1293         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1294 }
1295 #[must_use]
1296 #[no_mangle]
1297 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 {
1298         ClosingSigned { inner: Box::into_raw(Box::new(nativeClosingSigned {
1299                 channel_id: channel_id_arg.data,
1300                 fee_satoshis: fee_satoshis_arg,
1301                 signature: signature_arg.into_rust(),
1302         })), is_owned: true }
1303 }
1304 impl Clone for ClosingSigned {
1305         fn clone(&self) -> Self {
1306                 Self {
1307                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1308                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1309                         is_owned: true,
1310                 }
1311         }
1312 }
1313 #[allow(unused)]
1314 /// Used only if an object of this type is returned as a trait impl by a method
1315 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1316         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1317 }
1318 #[no_mangle]
1319 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1320         orig.clone()
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 /// The channel ID
1361 #[no_mangle]
1362 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1363         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1364         &(*inner_val)
1365 }
1366 /// The channel ID
1367 #[no_mangle]
1368 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1369         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1370 }
1371 /// The HTLC ID
1372 #[no_mangle]
1373 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1374         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1375         (*inner_val)
1376 }
1377 /// The HTLC ID
1378 #[no_mangle]
1379 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1380         unsafe { &mut *this_ptr.inner }.htlc_id = val;
1381 }
1382 /// The HTLC value in milli-satoshi
1383 #[no_mangle]
1384 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1385         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat;
1386         (*inner_val)
1387 }
1388 /// The HTLC value in milli-satoshi
1389 #[no_mangle]
1390 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1391         unsafe { &mut *this_ptr.inner }.amount_msat = val;
1392 }
1393 /// The payment hash, the pre-image of which controls HTLC redemption
1394 #[no_mangle]
1395 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1396         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash;
1397         &(*inner_val).0
1398 }
1399 /// The payment hash, the pre-image of which controls HTLC redemption
1400 #[no_mangle]
1401 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1402         unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::channelmanager::PaymentHash(val.data);
1403 }
1404 /// The expiry height of the HTLC
1405 #[no_mangle]
1406 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1407         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry;
1408         (*inner_val)
1409 }
1410 /// The expiry height of the HTLC
1411 #[no_mangle]
1412 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1413         unsafe { &mut *this_ptr.inner }.cltv_expiry = val;
1414 }
1415 impl Clone for UpdateAddHTLC {
1416         fn clone(&self) -> Self {
1417                 Self {
1418                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1419                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1420                         is_owned: true,
1421                 }
1422         }
1423 }
1424 #[allow(unused)]
1425 /// Used only if an object of this type is returned as a trait impl by a method
1426 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1427         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1428 }
1429 #[no_mangle]
1430 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1431         orig.clone()
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 /// The channel ID
1472 #[no_mangle]
1473 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1474         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1475         &(*inner_val)
1476 }
1477 /// The channel ID
1478 #[no_mangle]
1479 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1480         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1481 }
1482 /// The HTLC ID
1483 #[no_mangle]
1484 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1485         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1486         (*inner_val)
1487 }
1488 /// The HTLC ID
1489 #[no_mangle]
1490 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1491         unsafe { &mut *this_ptr.inner }.htlc_id = val;
1492 }
1493 /// The pre-image of the payment hash, allowing HTLC redemption
1494 #[no_mangle]
1495 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1496         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_preimage;
1497         &(*inner_val).0
1498 }
1499 /// The pre-image of the payment hash, allowing HTLC redemption
1500 #[no_mangle]
1501 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1502         unsafe { &mut *this_ptr.inner }.payment_preimage = ::lightning::ln::channelmanager::PaymentPreimage(val.data);
1503 }
1504 #[must_use]
1505 #[no_mangle]
1506 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 {
1507         UpdateFulfillHTLC { inner: Box::into_raw(Box::new(nativeUpdateFulfillHTLC {
1508                 channel_id: channel_id_arg.data,
1509                 htlc_id: htlc_id_arg,
1510                 payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage_arg.data),
1511         })), is_owned: true }
1512 }
1513 impl Clone for UpdateFulfillHTLC {
1514         fn clone(&self) -> Self {
1515                 Self {
1516                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1517                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1518                         is_owned: true,
1519                 }
1520         }
1521 }
1522 #[allow(unused)]
1523 /// Used only if an object of this type is returned as a trait impl by a method
1524 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1525         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1526 }
1527 #[no_mangle]
1528 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1529         orig.clone()
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 /// The channel ID
1570 #[no_mangle]
1571 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1572         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1573         &(*inner_val)
1574 }
1575 /// The channel ID
1576 #[no_mangle]
1577 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1578         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1579 }
1580 /// The HTLC ID
1581 #[no_mangle]
1582 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1583         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1584         (*inner_val)
1585 }
1586 /// The HTLC ID
1587 #[no_mangle]
1588 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1589         unsafe { &mut *this_ptr.inner }.htlc_id = val;
1590 }
1591 impl Clone for UpdateFailHTLC {
1592         fn clone(&self) -> Self {
1593                 Self {
1594                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1595                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1596                         is_owned: true,
1597                 }
1598         }
1599 }
1600 #[allow(unused)]
1601 /// Used only if an object of this type is returned as a trait impl by a method
1602 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1603         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
1604 }
1605 #[no_mangle]
1606 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
1607         orig.clone()
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 /// The channel ID
1648 #[no_mangle]
1649 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
1650         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1651         &(*inner_val)
1652 }
1653 /// The channel ID
1654 #[no_mangle]
1655 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1656         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1657 }
1658 /// The HTLC ID
1659 #[no_mangle]
1660 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
1661         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1662         (*inner_val)
1663 }
1664 /// The HTLC ID
1665 #[no_mangle]
1666 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
1667         unsafe { &mut *this_ptr.inner }.htlc_id = val;
1668 }
1669 /// The failure code
1670 #[no_mangle]
1671 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
1672         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.failure_code;
1673         (*inner_val)
1674 }
1675 /// The failure code
1676 #[no_mangle]
1677 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
1678         unsafe { &mut *this_ptr.inner }.failure_code = val;
1679 }
1680 impl Clone for UpdateFailMalformedHTLC {
1681         fn clone(&self) -> Self {
1682                 Self {
1683                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1684                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1685                         is_owned: true,
1686                 }
1687         }
1688 }
1689 #[allow(unused)]
1690 /// Used only if an object of this type is returned as a trait impl by a method
1691 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1692         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
1693 }
1694 #[no_mangle]
1695 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
1696         orig.clone()
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 /// The channel ID
1737 #[no_mangle]
1738 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
1739         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1740         &(*inner_val)
1741 }
1742 /// The channel ID
1743 #[no_mangle]
1744 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1745         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1746 }
1747 /// A signature on the commitment transaction
1748 #[no_mangle]
1749 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
1750         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1751         crate::c_types::Signature::from_rust(&(*inner_val))
1752 }
1753 /// A signature on the commitment transaction
1754 #[no_mangle]
1755 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
1756         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1757 }
1758 /// Signatures on the HTLC transactions
1759 #[no_mangle]
1760 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
1761         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
1762         unsafe { &mut *this_ptr.inner }.htlc_signatures = local_val;
1763 }
1764 #[must_use]
1765 #[no_mangle]
1766 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 {
1767         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() }); };
1768         CommitmentSigned { inner: Box::into_raw(Box::new(nativeCommitmentSigned {
1769                 channel_id: channel_id_arg.data,
1770                 signature: signature_arg.into_rust(),
1771                 htlc_signatures: local_htlc_signatures_arg,
1772         })), is_owned: true }
1773 }
1774 impl Clone for CommitmentSigned {
1775         fn clone(&self) -> Self {
1776                 Self {
1777                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1778                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1779                         is_owned: true,
1780                 }
1781         }
1782 }
1783 #[allow(unused)]
1784 /// Used only if an object of this type is returned as a trait impl by a method
1785 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1786         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
1787 }
1788 #[no_mangle]
1789 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
1790         orig.clone()
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 /// The channel ID
1831 #[no_mangle]
1832 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
1833         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1834         &(*inner_val)
1835 }
1836 /// The channel ID
1837 #[no_mangle]
1838 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
1839         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1840 }
1841 /// The secret corresponding to the per-commitment point
1842 #[no_mangle]
1843 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
1844         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_secret;
1845         &(*inner_val)
1846 }
1847 /// The secret corresponding to the per-commitment point
1848 #[no_mangle]
1849 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
1850         unsafe { &mut *this_ptr.inner }.per_commitment_secret = val.data;
1851 }
1852 /// The next sender-broadcast commitment transaction's per-commitment point
1853 #[no_mangle]
1854 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
1855         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
1856         crate::c_types::PublicKey::from_rust(&(*inner_val))
1857 }
1858 /// The next sender-broadcast commitment transaction's per-commitment point
1859 #[no_mangle]
1860 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
1861         unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
1862 }
1863 #[must_use]
1864 #[no_mangle]
1865 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 {
1866         RevokeAndACK { inner: Box::into_raw(Box::new(nativeRevokeAndACK {
1867                 channel_id: channel_id_arg.data,
1868                 per_commitment_secret: per_commitment_secret_arg.data,
1869                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1870         })), is_owned: true }
1871 }
1872 impl Clone for RevokeAndACK {
1873         fn clone(&self) -> Self {
1874                 Self {
1875                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1876                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1877                         is_owned: true,
1878                 }
1879         }
1880 }
1881 #[allow(unused)]
1882 /// Used only if an object of this type is returned as a trait impl by a method
1883 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
1884         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
1885 }
1886 #[no_mangle]
1887 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
1888         orig.clone()
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 /// The channel ID
1929 #[no_mangle]
1930 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
1931         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1932         &(*inner_val)
1933 }
1934 /// The channel ID
1935 #[no_mangle]
1936 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
1937         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1938 }
1939 /// Fee rate per 1000-weight of the transaction
1940 #[no_mangle]
1941 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
1942         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
1943         (*inner_val)
1944 }
1945 /// Fee rate per 1000-weight of the transaction
1946 #[no_mangle]
1947 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
1948         unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
1949 }
1950 #[must_use]
1951 #[no_mangle]
1952 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
1953         UpdateFee { inner: Box::into_raw(Box::new(nativeUpdateFee {
1954                 channel_id: channel_id_arg.data,
1955                 feerate_per_kw: feerate_per_kw_arg,
1956         })), is_owned: true }
1957 }
1958 impl Clone for UpdateFee {
1959         fn clone(&self) -> Self {
1960                 Self {
1961                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1962                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1963                         is_owned: true,
1964                 }
1965         }
1966 }
1967 #[allow(unused)]
1968 /// Used only if an object of this type is returned as a trait impl by a method
1969 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
1970         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
1971 }
1972 #[no_mangle]
1973 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
1974         orig.clone()
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 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2018 /// belonging to the recipient
2019 #[no_mangle]
2020 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2021         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret;
2022         &(*inner_val)
2023 }
2024 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2025 /// belonging to the recipient
2026 #[no_mangle]
2027 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2028         unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret = val.data;
2029 }
2030 /// The sender's per-commitment point for their current commitment transaction
2031 #[no_mangle]
2032 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2033         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point;
2034         crate::c_types::PublicKey::from_rust(&(*inner_val))
2035 }
2036 /// The sender's per-commitment point for their current commitment transaction
2037 #[no_mangle]
2038 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2039         unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point = val.into_rust();
2040 }
2041 #[must_use]
2042 #[no_mangle]
2043 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 {
2044         DataLossProtect { inner: Box::into_raw(Box::new(nativeDataLossProtect {
2045                 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2046                 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2047         })), is_owned: true }
2048 }
2049 impl Clone for DataLossProtect {
2050         fn clone(&self) -> Self {
2051                 Self {
2052                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2053                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2054                         is_owned: true,
2055                 }
2056         }
2057 }
2058 #[allow(unused)]
2059 /// Used only if an object of this type is returned as a trait impl by a method
2060 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2061         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2062 }
2063 #[no_mangle]
2064 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2065         orig.clone()
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 /// The channel ID
2106 #[no_mangle]
2107 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2108         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2109         &(*inner_val)
2110 }
2111 /// The channel ID
2112 #[no_mangle]
2113 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2114         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2115 }
2116 /// The next commitment number for the sender
2117 #[no_mangle]
2118 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2119         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_local_commitment_number;
2120         (*inner_val)
2121 }
2122 /// The next commitment number for the sender
2123 #[no_mangle]
2124 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2125         unsafe { &mut *this_ptr.inner }.next_local_commitment_number = val;
2126 }
2127 /// The next commitment number for the recipient
2128 #[no_mangle]
2129 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2130         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_remote_commitment_number;
2131         (*inner_val)
2132 }
2133 /// The next commitment number for the recipient
2134 #[no_mangle]
2135 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2136         unsafe { &mut *this_ptr.inner }.next_remote_commitment_number = val;
2137 }
2138 impl Clone for ChannelReestablish {
2139         fn clone(&self) -> Self {
2140                 Self {
2141                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2142                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2143                         is_owned: true,
2144                 }
2145         }
2146 }
2147 #[allow(unused)]
2148 /// Used only if an object of this type is returned as a trait impl by a method
2149 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2150         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2151 }
2152 #[no_mangle]
2153 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2154         orig.clone()
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 /// The channel ID
2195 #[no_mangle]
2196 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2197         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2198         &(*inner_val)
2199 }
2200 /// The channel ID
2201 #[no_mangle]
2202 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2203         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2204 }
2205 /// The short channel ID
2206 #[no_mangle]
2207 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2208         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2209         (*inner_val)
2210 }
2211 /// The short channel ID
2212 #[no_mangle]
2213 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2214         unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2215 }
2216 /// A signature by the node key
2217 #[no_mangle]
2218 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2219         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature;
2220         crate::c_types::Signature::from_rust(&(*inner_val))
2221 }
2222 /// A signature by the node key
2223 #[no_mangle]
2224 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2225         unsafe { &mut *this_ptr.inner }.node_signature = val.into_rust();
2226 }
2227 /// A signature by the funding key
2228 #[no_mangle]
2229 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2230         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature;
2231         crate::c_types::Signature::from_rust(&(*inner_val))
2232 }
2233 /// A signature by the funding key
2234 #[no_mangle]
2235 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2236         unsafe { &mut *this_ptr.inner }.bitcoin_signature = val.into_rust();
2237 }
2238 #[must_use]
2239 #[no_mangle]
2240 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 {
2241         AnnouncementSignatures { inner: Box::into_raw(Box::new(nativeAnnouncementSignatures {
2242                 channel_id: channel_id_arg.data,
2243                 short_channel_id: short_channel_id_arg,
2244                 node_signature: node_signature_arg.into_rust(),
2245                 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2246         })), is_owned: true }
2247 }
2248 impl Clone for AnnouncementSignatures {
2249         fn clone(&self) -> Self {
2250                 Self {
2251                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2252                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2253                         is_owned: true,
2254                 }
2255         }
2256 }
2257 #[allow(unused)]
2258 /// Used only if an object of this type is returned as a trait impl by a method
2259 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2260         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2261 }
2262 #[no_mangle]
2263 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2264         orig.clone()
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 /// The advertised features
2498 #[no_mangle]
2499 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::ln::features::NodeFeatures {
2500         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2501         crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2502 }
2503 /// The advertised features
2504 #[no_mangle]
2505 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::ln::features::NodeFeatures) {
2506         unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2507 }
2508 /// A strictly monotonic announcement counter, with gaps allowed
2509 #[no_mangle]
2510 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
2511         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2512         (*inner_val)
2513 }
2514 /// A strictly monotonic announcement counter, with gaps allowed
2515 #[no_mangle]
2516 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
2517         unsafe { &mut *this_ptr.inner }.timestamp = val;
2518 }
2519 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2520 /// to this node).
2521 #[no_mangle]
2522 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
2523         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
2524         crate::c_types::PublicKey::from_rust(&(*inner_val))
2525 }
2526 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2527 /// to this node).
2528 #[no_mangle]
2529 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
2530         unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
2531 }
2532 /// An RGB color for UI purposes
2533 #[no_mangle]
2534 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
2535         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
2536         &(*inner_val)
2537 }
2538 /// An RGB color for UI purposes
2539 #[no_mangle]
2540 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
2541         unsafe { &mut *this_ptr.inner }.rgb = val.data;
2542 }
2543 /// An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
2544 /// of uniqueness.
2545 #[no_mangle]
2546 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
2547         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
2548         &(*inner_val)
2549 }
2550 /// An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
2551 /// of uniqueness.
2552 #[no_mangle]
2553 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2554         unsafe { &mut *this_ptr.inner }.alias = val.data;
2555 }
2556 /// List of addresses on which this node is reachable
2557 #[no_mangle]
2558 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
2559         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
2560         unsafe { &mut *this_ptr.inner }.addresses = local_val;
2561 }
2562 impl Clone for UnsignedNodeAnnouncement {
2563         fn clone(&self) -> Self {
2564                 Self {
2565                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2566                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2567                         is_owned: true,
2568                 }
2569         }
2570 }
2571 #[allow(unused)]
2572 /// Used only if an object of this type is returned as a trait impl by a method
2573 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2574         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
2575 }
2576 #[no_mangle]
2577 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
2578         orig.clone()
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 /// The signature by the node key
2619 #[no_mangle]
2620 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
2621         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2622         crate::c_types::Signature::from_rust(&(*inner_val))
2623 }
2624 /// The signature by the node key
2625 #[no_mangle]
2626 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
2627         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2628 }
2629 /// The actual content of the announcement
2630 #[no_mangle]
2631 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::ln::msgs::UnsignedNodeAnnouncement {
2632         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2633         crate::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2634 }
2635 /// The actual content of the announcement
2636 #[no_mangle]
2637 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::ln::msgs::UnsignedNodeAnnouncement) {
2638         unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2639 }
2640 #[must_use]
2641 #[no_mangle]
2642 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
2643         NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement {
2644                 signature: signature_arg.into_rust(),
2645                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2646         })), is_owned: true }
2647 }
2648 impl Clone for NodeAnnouncement {
2649         fn clone(&self) -> Self {
2650                 Self {
2651                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2652                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2653                         is_owned: true,
2654                 }
2655         }
2656 }
2657 #[allow(unused)]
2658 /// Used only if an object of this type is returned as a trait impl by a method
2659 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2660         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
2661 }
2662 #[no_mangle]
2663 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
2664         orig.clone()
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 /// The advertised channel features
2705 #[no_mangle]
2706 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::ln::features::ChannelFeatures {
2707         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2708         crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2709 }
2710 /// The advertised channel features
2711 #[no_mangle]
2712 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::ln::features::ChannelFeatures) {
2713         unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2714 }
2715 /// The genesis hash of the blockchain where the channel is to be opened
2716 #[no_mangle]
2717 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
2718         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2719         (*inner_val).as_inner()
2720 }
2721 /// The genesis hash of the blockchain where the channel is to be opened
2722 #[no_mangle]
2723 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2724         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2725 }
2726 /// The short channel ID
2727 #[no_mangle]
2728 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
2729         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2730         (*inner_val)
2731 }
2732 /// The short channel ID
2733 #[no_mangle]
2734 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
2735         unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2736 }
2737 /// One of the two node_ids which are endpoints of this channel
2738 #[no_mangle]
2739 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2740         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1;
2741         crate::c_types::PublicKey::from_rust(&(*inner_val))
2742 }
2743 /// One of the two node_ids which are endpoints of this channel
2744 #[no_mangle]
2745 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2746         unsafe { &mut *this_ptr.inner }.node_id_1 = val.into_rust();
2747 }
2748 /// The other of the two node_ids which are endpoints of this channel
2749 #[no_mangle]
2750 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2751         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2;
2752         crate::c_types::PublicKey::from_rust(&(*inner_val))
2753 }
2754 /// The other of the two node_ids which are endpoints of this channel
2755 #[no_mangle]
2756 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2757         unsafe { &mut *this_ptr.inner }.node_id_2 = val.into_rust();
2758 }
2759 /// The funding key for the first node
2760 #[no_mangle]
2761 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2762         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1;
2763         crate::c_types::PublicKey::from_rust(&(*inner_val))
2764 }
2765 /// The funding key for the first node
2766 #[no_mangle]
2767 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2768         unsafe { &mut *this_ptr.inner }.bitcoin_key_1 = val.into_rust();
2769 }
2770 /// The funding key for the second node
2771 #[no_mangle]
2772 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2773         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2;
2774         crate::c_types::PublicKey::from_rust(&(*inner_val))
2775 }
2776 /// The funding key for the second node
2777 #[no_mangle]
2778 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2779         unsafe { &mut *this_ptr.inner }.bitcoin_key_2 = val.into_rust();
2780 }
2781 impl Clone for UnsignedChannelAnnouncement {
2782         fn clone(&self) -> Self {
2783                 Self {
2784                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2785                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2786                         is_owned: true,
2787                 }
2788         }
2789 }
2790 #[allow(unused)]
2791 /// Used only if an object of this type is returned as a trait impl by a method
2792 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2793         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
2794 }
2795 #[no_mangle]
2796 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
2797         orig.clone()
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 /// Authentication of the announcement by the first public node
2838 #[no_mangle]
2839 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2840         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1;
2841         crate::c_types::Signature::from_rust(&(*inner_val))
2842 }
2843 /// Authentication of the announcement by the first public node
2844 #[no_mangle]
2845 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2846         unsafe { &mut *this_ptr.inner }.node_signature_1 = val.into_rust();
2847 }
2848 /// Authentication of the announcement by the second public node
2849 #[no_mangle]
2850 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2851         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2;
2852         crate::c_types::Signature::from_rust(&(*inner_val))
2853 }
2854 /// Authentication of the announcement by the second public node
2855 #[no_mangle]
2856 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2857         unsafe { &mut *this_ptr.inner }.node_signature_2 = val.into_rust();
2858 }
2859 /// Proof of funding UTXO ownership by the first public node
2860 #[no_mangle]
2861 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2862         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1;
2863         crate::c_types::Signature::from_rust(&(*inner_val))
2864 }
2865 /// Proof of funding UTXO ownership by the first public node
2866 #[no_mangle]
2867 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2868         unsafe { &mut *this_ptr.inner }.bitcoin_signature_1 = val.into_rust();
2869 }
2870 /// Proof of funding UTXO ownership by the second public node
2871 #[no_mangle]
2872 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2873         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2;
2874         crate::c_types::Signature::from_rust(&(*inner_val))
2875 }
2876 /// Proof of funding UTXO ownership by the second public node
2877 #[no_mangle]
2878 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2879         unsafe { &mut *this_ptr.inner }.bitcoin_signature_2 = val.into_rust();
2880 }
2881 /// The actual announcement
2882 #[no_mangle]
2883 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::ln::msgs::UnsignedChannelAnnouncement {
2884         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2885         crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2886 }
2887 /// The actual announcement
2888 #[no_mangle]
2889 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::ln::msgs::UnsignedChannelAnnouncement) {
2890         unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2891 }
2892 #[must_use]
2893 #[no_mangle]
2894 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 {
2895         ChannelAnnouncement { inner: Box::into_raw(Box::new(nativeChannelAnnouncement {
2896                 node_signature_1: node_signature_1_arg.into_rust(),
2897                 node_signature_2: node_signature_2_arg.into_rust(),
2898                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
2899                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
2900                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2901         })), is_owned: true }
2902 }
2903 impl Clone for ChannelAnnouncement {
2904         fn clone(&self) -> Self {
2905                 Self {
2906                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2907                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2908                         is_owned: true,
2909                 }
2910         }
2911 }
2912 #[allow(unused)]
2913 /// Used only if an object of this type is returned as a trait impl by a method
2914 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2915         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
2916 }
2917 #[no_mangle]
2918 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
2919         orig.clone()
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 /// The genesis hash of the blockchain where the channel is to be opened
2960 #[no_mangle]
2961 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
2962         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2963         (*inner_val).as_inner()
2964 }
2965 /// The genesis hash of the blockchain where the channel is to be opened
2966 #[no_mangle]
2967 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
2968         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2969 }
2970 /// The short channel ID
2971 #[no_mangle]
2972 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
2973         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2974         (*inner_val)
2975 }
2976 /// The short channel ID
2977 #[no_mangle]
2978 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2979         unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2980 }
2981 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
2982 #[no_mangle]
2983 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
2984         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2985         (*inner_val)
2986 }
2987 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
2988 #[no_mangle]
2989 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
2990         unsafe { &mut *this_ptr.inner }.timestamp = val;
2991 }
2992 /// Channel flags
2993 #[no_mangle]
2994 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
2995         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags;
2996         (*inner_val)
2997 }
2998 /// Channel flags
2999 #[no_mangle]
3000 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3001         unsafe { &mut *this_ptr.inner }.flags = val;
3002 }
3003 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
3004 #[no_mangle]
3005 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3006         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
3007         (*inner_val)
3008 }
3009 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
3010 #[no_mangle]
3011 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3012         unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
3013 }
3014 /// The minimum HTLC size incoming to sender, in milli-satoshi
3015 #[no_mangle]
3016 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3017         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
3018         (*inner_val)
3019 }
3020 /// The minimum HTLC size incoming to sender, in milli-satoshi
3021 #[no_mangle]
3022 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3023         unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
3024 }
3025 /// The base HTLC fee charged by sender, in milli-satoshi
3026 #[no_mangle]
3027 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3028         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat;
3029         (*inner_val)
3030 }
3031 /// The base HTLC fee charged by sender, in milli-satoshi
3032 #[no_mangle]
3033 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3034         unsafe { &mut *this_ptr.inner }.fee_base_msat = val;
3035 }
3036 /// The amount to fee multiplier, in micro-satoshi
3037 #[no_mangle]
3038 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3039         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
3040         (*inner_val)
3041 }
3042 /// The amount to fee multiplier, in micro-satoshi
3043 #[no_mangle]
3044 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3045         unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
3046 }
3047 impl Clone for UnsignedChannelUpdate {
3048         fn clone(&self) -> Self {
3049                 Self {
3050                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3051                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3052                         is_owned: true,
3053                 }
3054         }
3055 }
3056 #[allow(unused)]
3057 /// Used only if an object of this type is returned as a trait impl by a method
3058 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3059         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3060 }
3061 #[no_mangle]
3062 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3063         orig.clone()
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 /// A signature of the channel update
3104 #[no_mangle]
3105 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3106         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
3107         crate::c_types::Signature::from_rust(&(*inner_val))
3108 }
3109 /// A signature of the channel update
3110 #[no_mangle]
3111 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3112         unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
3113 }
3114 /// The actual channel update
3115 #[no_mangle]
3116 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::ln::msgs::UnsignedChannelUpdate {
3117         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
3118         crate::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3119 }
3120 /// The actual channel update
3121 #[no_mangle]
3122 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::ln::msgs::UnsignedChannelUpdate) {
3123         unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3124 }
3125 #[must_use]
3126 #[no_mangle]
3127 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3128         ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate {
3129                 signature: signature_arg.into_rust(),
3130                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3131         })), is_owned: true }
3132 }
3133 impl Clone for ChannelUpdate {
3134         fn clone(&self) -> Self {
3135                 Self {
3136                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3137                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3138                         is_owned: true,
3139                 }
3140         }
3141 }
3142 #[allow(unused)]
3143 /// Used only if an object of this type is returned as a trait impl by a method
3144 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3145         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3146 }
3147 #[no_mangle]
3148 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3149         orig.clone()
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 /// The genesis hash of the blockchain being queried
3193 #[no_mangle]
3194 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3195         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3196         (*inner_val).as_inner()
3197 }
3198 /// The genesis hash of the blockchain being queried
3199 #[no_mangle]
3200 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3201         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3202 }
3203 /// The height of the first block for the channel UTXOs being queried
3204 #[no_mangle]
3205 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3206         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3207         (*inner_val)
3208 }
3209 /// The height of the first block for the channel UTXOs being queried
3210 #[no_mangle]
3211 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3212         unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3213 }
3214 /// The number of blocks to include in the query results
3215 #[no_mangle]
3216 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3217         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3218         (*inner_val)
3219 }
3220 /// The number of blocks to include in the query results
3221 #[no_mangle]
3222 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3223         unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3224 }
3225 #[must_use]
3226 #[no_mangle]
3227 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 {
3228         QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange {
3229                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3230                 first_blocknum: first_blocknum_arg,
3231                 number_of_blocks: number_of_blocks_arg,
3232         })), is_owned: true }
3233 }
3234 impl Clone for QueryChannelRange {
3235         fn clone(&self) -> Self {
3236                 Self {
3237                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3238                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3239                         is_owned: true,
3240                 }
3241         }
3242 }
3243 #[allow(unused)]
3244 /// Used only if an object of this type is returned as a trait impl by a method
3245 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3246         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3247 }
3248 #[no_mangle]
3249 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3250         orig.clone()
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 /// The genesis hash of the blockchain being queried
3297 #[no_mangle]
3298 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3299         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3300         (*inner_val).as_inner()
3301 }
3302 /// The genesis hash of the blockchain being queried
3303 #[no_mangle]
3304 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3305         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3306 }
3307 /// The height of the first block in the range of the reply
3308 #[no_mangle]
3309 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3310         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3311         (*inner_val)
3312 }
3313 /// The height of the first block in the range of the reply
3314 #[no_mangle]
3315 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3316         unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3317 }
3318 /// The number of blocks included in the range of the reply
3319 #[no_mangle]
3320 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3321         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3322         (*inner_val)
3323 }
3324 /// The number of blocks included in the range of the reply
3325 #[no_mangle]
3326 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3327         unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3328 }
3329 /// True when this is the final reply for a query
3330 #[no_mangle]
3331 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
3332         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.sync_complete;
3333         (*inner_val)
3334 }
3335 /// True when this is the final reply for a query
3336 #[no_mangle]
3337 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
3338         unsafe { &mut *this_ptr.inner }.sync_complete = val;
3339 }
3340 /// The short_channel_ids in the channel range
3341 #[no_mangle]
3342 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
3343         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3344         unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3345 }
3346 #[must_use]
3347 #[no_mangle]
3348 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 {
3349         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 }); };
3350         ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange {
3351                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3352                 first_blocknum: first_blocknum_arg,
3353                 number_of_blocks: number_of_blocks_arg,
3354                 sync_complete: sync_complete_arg,
3355                 short_channel_ids: local_short_channel_ids_arg,
3356         })), is_owned: true }
3357 }
3358 impl Clone for ReplyChannelRange {
3359         fn clone(&self) -> Self {
3360                 Self {
3361                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3362                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3363                         is_owned: true,
3364                 }
3365         }
3366 }
3367 #[allow(unused)]
3368 /// Used only if an object of this type is returned as a trait impl by a method
3369 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3370         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
3371 }
3372 #[no_mangle]
3373 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
3374         orig.clone()
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 /// The genesis hash of the blockchain being queried
3422 #[no_mangle]
3423 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
3424         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3425         (*inner_val).as_inner()
3426 }
3427 /// The genesis hash of the blockchain being queried
3428 #[no_mangle]
3429 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
3430         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3431 }
3432 /// The short_channel_ids that are being queried
3433 #[no_mangle]
3434 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
3435         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3436         unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3437 }
3438 #[must_use]
3439 #[no_mangle]
3440 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 {
3441         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 }); };
3442         QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds {
3443                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3444                 short_channel_ids: local_short_channel_ids_arg,
3445         })), is_owned: true }
3446 }
3447 impl Clone for QueryShortChannelIds {
3448         fn clone(&self) -> Self {
3449                 Self {
3450                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3451                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3452                         is_owned: true,
3453                 }
3454         }
3455 }
3456 #[allow(unused)]
3457 /// Used only if an object of this type is returned as a trait impl by a method
3458 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
3459         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
3460 }
3461 #[no_mangle]
3462 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
3463         orig.clone()
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 /// The genesis hash of the blockchain that was queried
3507 #[no_mangle]
3508 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
3509         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3510         (*inner_val).as_inner()
3511 }
3512 /// The genesis hash of the blockchain that was queried
3513 #[no_mangle]
3514 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
3515         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3516 }
3517 /// Indicates if the query recipient maintains up-to-date channel
3518 /// information for the chain_hash
3519 #[no_mangle]
3520 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
3521         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3522         (*inner_val)
3523 }
3524 /// Indicates if the query recipient maintains up-to-date channel
3525 /// information for the chain_hash
3526 #[no_mangle]
3527 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
3528         unsafe { &mut *this_ptr.inner }.full_information = val;
3529 }
3530 #[must_use]
3531 #[no_mangle]
3532 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
3533         ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd {
3534                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3535                 full_information: full_information_arg,
3536         })), is_owned: true }
3537 }
3538 impl Clone for ReplyShortChannelIdsEnd {
3539         fn clone(&self) -> Self {
3540                 Self {
3541                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3542                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3543                         is_owned: true,
3544                 }
3545         }
3546 }
3547 #[allow(unused)]
3548 /// Used only if an object of this type is returned as a trait impl by a method
3549 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
3550         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
3551 }
3552 #[no_mangle]
3553 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
3554         orig.clone()
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 /// The genesis hash of the blockchain for channel and node information
3597 #[no_mangle]
3598 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
3599         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3600         (*inner_val).as_inner()
3601 }
3602 /// The genesis hash of the blockchain for channel and node information
3603 #[no_mangle]
3604 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
3605         unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3606 }
3607 /// The starting unix timestamp
3608 #[no_mangle]
3609 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
3610         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp;
3611         (*inner_val)
3612 }
3613 /// The starting unix timestamp
3614 #[no_mangle]
3615 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3616         unsafe { &mut *this_ptr.inner }.first_timestamp = val;
3617 }
3618 /// The range of information in seconds
3619 #[no_mangle]
3620 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
3621         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range;
3622         (*inner_val)
3623 }
3624 /// The range of information in seconds
3625 #[no_mangle]
3626 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3627         unsafe { &mut *this_ptr.inner }.timestamp_range = val;
3628 }
3629 #[must_use]
3630 #[no_mangle]
3631 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 {
3632         GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter {
3633                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3634                 first_timestamp: first_timestamp_arg,
3635                 timestamp_range: timestamp_range_arg,
3636         })), is_owned: true }
3637 }
3638 impl Clone for GossipTimestampFilter {
3639         fn clone(&self) -> Self {
3640                 Self {
3641                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3642                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3643                         is_owned: true,
3644                 }
3645         }
3646 }
3647 #[allow(unused)]
3648 /// Used only if an object of this type is returned as a trait impl by a method
3649 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
3650         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
3651 }
3652 #[no_mangle]
3653 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
3654         orig.clone()
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 /// A human-readable message describing the error
3792 #[no_mangle]
3793 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
3794         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
3795         (*inner_val).as_str().into()
3796 }
3797 /// A human-readable message describing the error
3798 #[no_mangle]
3799 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::derived::CVec_u8Z) {
3800         unsafe { &mut *this_ptr.inner }.err = String::from_utf8(val.into_rust()).unwrap();
3801 }
3802 /// The action which should be taken against the offending peer.
3803 #[no_mangle]
3804 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::ln::msgs::ErrorAction {
3805         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
3806         crate::ln::msgs::ErrorAction::from_native(&(*inner_val))
3807 }
3808 /// The action which should be taken against the offending peer.
3809 #[no_mangle]
3810 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::ln::msgs::ErrorAction) {
3811         unsafe { &mut *this_ptr.inner }.action = val.into_native();
3812 }
3813 #[must_use]
3814 #[no_mangle]
3815 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::ln::msgs::ErrorAction) -> LightningError {
3816         LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
3817                 err: String::from_utf8(err_arg.into_rust()).unwrap(),
3818                 action: action_arg.into_native(),
3819         })), is_owned: true }
3820 }
3821 impl Clone for LightningError {
3822         fn clone(&self) -> Self {
3823                 Self {
3824                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3825                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3826                         is_owned: true,
3827                 }
3828         }
3829 }
3830 #[allow(unused)]
3831 /// Used only if an object of this type is returned as a trait impl by a method
3832 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
3833         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
3834 }
3835 #[no_mangle]
3836 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
3837         orig.clone()
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 /// update_add_htlc messages which should be sent
3879 #[no_mangle]
3880 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
3881         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3882         unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
3883 }
3884 /// update_fulfill_htlc messages which should be sent
3885 #[no_mangle]
3886 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
3887         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3888         unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
3889 }
3890 /// update_fail_htlc messages which should be sent
3891 #[no_mangle]
3892 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
3893         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3894         unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
3895 }
3896 /// update_fail_malformed_htlc messages which should be sent
3897 #[no_mangle]
3898 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
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_fail_malformed_htlcs = local_val;
3901 }
3902 /// An update_fee message which should be sent
3903 #[no_mangle]
3904 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::UpdateFee {
3905         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
3906         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 };
3907         local_inner_val
3908 }
3909 /// An update_fee message which should be sent
3910 #[no_mangle]
3911 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::UpdateFee) {
3912         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
3913         unsafe { &mut *this_ptr.inner }.update_fee = local_val;
3914 }
3915 /// Finally, the commitment_signed message which should be sent
3916 #[no_mangle]
3917 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::CommitmentSigned {
3918         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
3919         crate::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3920 }
3921 /// Finally, the commitment_signed message which should be sent
3922 #[no_mangle]
3923 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::CommitmentSigned) {
3924         unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
3925 }
3926 #[must_use]
3927 #[no_mangle]
3928 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 {
3929         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()) } }); };
3930         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()) } }); };
3931         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()) } }); };
3932         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()) } }); };
3933         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()) } }) };
3934         CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
3935                 update_add_htlcs: local_update_add_htlcs_arg,
3936                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
3937                 update_fail_htlcs: local_update_fail_htlcs_arg,
3938                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
3939                 update_fee: local_update_fee_arg,
3940                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
3941         })), is_owned: true }
3942 }
3943 impl Clone for CommitmentUpdate {
3944         fn clone(&self) -> Self {
3945                 Self {
3946                         inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3947                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3948                         is_owned: true,
3949                 }
3950         }
3951 }
3952 #[allow(unused)]
3953 /// Used only if an object of this type is returned as a trait impl by a method
3954 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3955         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
3956 }
3957 #[no_mangle]
3958 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
3959         orig.clone()
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 { &*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) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
4381         let res = crate::c_types::deserialize_obj(ser);
4382         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4383         local_res
4384 }
4385 #[no_mangle]
4386 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
4387         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4388 }
4389 #[no_mangle]
4390 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4391         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
4392 }
4393 #[no_mangle]
4394 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
4395         let res = crate::c_types::deserialize_obj(ser);
4396         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4397         local_res
4398 }
4399 #[no_mangle]
4400 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
4401         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4402 }
4403 #[no_mangle]
4404 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4405         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
4406 }
4407 #[no_mangle]
4408 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
4409         let res = crate::c_types::deserialize_obj(ser);
4410         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() };
4411         local_res
4412 }
4413 #[no_mangle]
4414 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
4415         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4416 }
4417 #[no_mangle]
4418 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4419         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
4420 }
4421 #[no_mangle]
4422 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
4423         let res = crate::c_types::deserialize_obj(ser);
4424         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4425         local_res
4426 }
4427 #[no_mangle]
4428 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
4429         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4430 }
4431 #[no_mangle]
4432 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4433         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
4434 }
4435 #[no_mangle]
4436 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
4437         let res = crate::c_types::deserialize_obj(ser);
4438         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::CommitmentSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4439         local_res
4440 }
4441 #[no_mangle]
4442 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
4443         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4444 }
4445 #[no_mangle]
4446 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4447         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
4448 }
4449 #[no_mangle]
4450 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
4451         let res = crate::c_types::deserialize_obj(ser);
4452         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4453         local_res
4454 }
4455 #[no_mangle]
4456 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
4457         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4458 }
4459 #[no_mangle]
4460 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4461         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
4462 }
4463 #[no_mangle]
4464 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
4465         let res = crate::c_types::deserialize_obj(ser);
4466         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4467         local_res
4468 }
4469 #[no_mangle]
4470 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
4471         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4472 }
4473 #[no_mangle]
4474 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4475         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
4476 }
4477 #[no_mangle]
4478 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
4479         let res = crate::c_types::deserialize_obj(ser);
4480         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4481         local_res
4482 }
4483 #[no_mangle]
4484 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
4485         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4486 }
4487 #[no_mangle]
4488 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4489         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
4490 }
4491 #[no_mangle]
4492 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
4493         let res = crate::c_types::deserialize_obj(ser);
4494         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() };
4495         local_res
4496 }
4497 #[no_mangle]
4498 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> 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 OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4503         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
4504 }
4505 #[no_mangle]
4506 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
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::OpenChannel { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4509         local_res
4510 }
4511 #[no_mangle]
4512 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
4513         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4514 }
4515 #[no_mangle]
4516 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4517         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
4518 }
4519 #[no_mangle]
4520 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
4521         let res = crate::c_types::deserialize_obj(ser);
4522         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4523         local_res
4524 }
4525 #[no_mangle]
4526 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
4527         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4528 }
4529 #[no_mangle]
4530 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4531         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
4532 }
4533 #[no_mangle]
4534 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
4535         let res = crate::c_types::deserialize_obj(ser);
4536         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4537         local_res
4538 }
4539 #[no_mangle]
4540 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
4541         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4542 }
4543 #[no_mangle]
4544 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4545         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
4546 }
4547 #[no_mangle]
4548 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
4549         let res = crate::c_types::deserialize_obj(ser);
4550         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFailHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4551         local_res
4552 }
4553 #[no_mangle]
4554 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
4555         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4556 }
4557 #[no_mangle]
4558 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4559         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
4560 }
4561 #[no_mangle]
4562 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
4563         let res = crate::c_types::deserialize_obj(ser);
4564         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4565         local_res
4566 }
4567 #[no_mangle]
4568 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
4569         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4570 }
4571 #[no_mangle]
4572 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4573         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
4574 }
4575 #[no_mangle]
4576 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
4577         let res = crate::c_types::deserialize_obj(ser);
4578         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFee { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4579         local_res
4580 }
4581 #[no_mangle]
4582 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
4583         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4584 }
4585 #[no_mangle]
4586 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4587         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
4588 }
4589 #[no_mangle]
4590 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
4591         let res = crate::c_types::deserialize_obj(ser);
4592         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFulfillHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4593         local_res
4594 }
4595 #[no_mangle]
4596 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
4597         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4598 }
4599 #[no_mangle]
4600 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4601         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
4602 }
4603 #[no_mangle]
4604 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
4605         let res = crate::c_types::deserialize_obj(ser);
4606         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateAddHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4607         local_res
4608 }
4609 #[no_mangle]
4610 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
4611         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4612 }
4613 #[no_mangle]
4614 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4615         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
4616 }
4617 #[no_mangle]
4618 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
4619         let res = crate::c_types::deserialize_obj(ser);
4620         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() };
4621         local_res
4622 }
4623 #[no_mangle]
4624 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
4625         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4626 }
4627 #[no_mangle]
4628 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4629         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
4630 }
4631 #[no_mangle]
4632 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
4633         let res = crate::c_types::deserialize_obj(ser);
4634         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() };
4635         local_res
4636 }
4637 #[no_mangle]
4638 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4639         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4640 }
4641 #[no_mangle]
4642 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4643         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
4644 }
4645 #[no_mangle]
4646 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
4647         let res = crate::c_types::deserialize_obj(ser);
4648         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() };
4649         local_res
4650 }
4651 #[no_mangle]
4652 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4653         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4654 }
4655 #[no_mangle]
4656 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4657         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
4658 }
4659 #[no_mangle]
4660 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
4661         let res = crate::c_types::deserialize_obj(ser);
4662         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4663         local_res
4664 }
4665 #[no_mangle]
4666 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4667         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4668 }
4669 #[no_mangle]
4670 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4671         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
4672 }
4673 #[no_mangle]
4674 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
4675         let res = crate::c_types::deserialize_obj(ser);
4676         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() };
4677         local_res
4678 }
4679 #[no_mangle]
4680 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4681         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4682 }
4683 #[no_mangle]
4684 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4685         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
4686 }
4687 #[no_mangle]
4688 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
4689         let res = crate::c_types::deserialize_obj(ser);
4690         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4691         local_res
4692 }
4693 #[no_mangle]
4694 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
4695         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4696 }
4697 #[no_mangle]
4698 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4699         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
4700 }
4701 #[no_mangle]
4702 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
4703         let res = crate::c_types::deserialize_obj(ser);
4704         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() };
4705         local_res
4706 }
4707 #[no_mangle]
4708 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4709         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4710 }
4711 #[no_mangle]
4712 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4713         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
4714 }
4715 #[no_mangle]
4716 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
4717         let res = crate::c_types::deserialize_obj(ser);
4718         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() };
4719         local_res
4720 }
4721 #[no_mangle]
4722 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4723         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4724 }
4725 #[no_mangle]
4726 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4727         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
4728 }
4729 #[no_mangle]
4730 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
4731         let res = crate::c_types::deserialize_obj(ser);
4732         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4733         local_res
4734 }
4735 #[no_mangle]
4736 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
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::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() };
4739         local_res
4740 }
4741 #[no_mangle]
4742 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> 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 QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4747         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
4748 }
4749 #[no_mangle]
4750 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
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::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() };
4753         local_res
4754 }
4755 #[no_mangle]
4756 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
4757         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4758 }
4759 #[no_mangle]
4760 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4761         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
4762 }
4763 #[no_mangle]
4764 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
4765         let res = crate::c_types::deserialize_obj(ser);
4766         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() };
4767         local_res
4768 }
4769 #[no_mangle]
4770 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
4771         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4772 }
4773 #[no_mangle]
4774 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4775         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
4776 }
4777 #[no_mangle]
4778 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
4779         let res = crate::c_types::deserialize_obj(ser);
4780         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() };
4781         local_res
4782 }
4783 #[no_mangle]
4784 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
4785         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4786 }
4787 #[no_mangle]
4788 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4789         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
4790 }
4791 #[no_mangle]
4792 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
4793         let res = crate::c_types::deserialize_obj(ser);
4794         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() };
4795         local_res
4796 }
4797 #[no_mangle]
4798 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
4799         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4800 }
4801 #[no_mangle]
4802 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4803         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
4804 }