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