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