d3e4c4bb96c8b40a421e93b240fc974a8b7faa94
[ldk-c-bindings] / lightning-c-bindings / src / lightning / ln / msgs.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Wire messages, traits representing wire message handlers, and a few error types live here.
10 //!
11 //! For a normal node you probably don't need to use anything here, however, if you wish to split a
12 //! node into an internet-facing route/message socket handling daemon and a separate daemon (or
13 //! server entirely) which handles only channel-related messages you may wish to implement
14 //! [`ChannelMessageHandler`] yourself and use it to re-serialize messages and pass them across
15 //! daemons/servers.
16 //!
17 //! Note that if you go with such an architecture (instead of passing raw socket events to a
18 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
19 //! source `node_id` of the message, however this does allow you to significantly reduce bandwidth
20 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
21 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
22 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
23 //! raw socket events into your non-internet-facing system and then send routing events back to
24 //! track the network on the less-secure system.
25
26 use alloc::str::FromStr;
27 use core::ffi::c_void;
28 use core::convert::Infallible;
29 use bitcoin::hashes::Hash;
30 use crate::c_types::*;
31 #[cfg(feature="no-std")]
32 use alloc::{vec::Vec, boxed::Box};
33
34 /// An error in decoding a message or struct.
35 #[derive(Clone)]
36 #[must_use]
37 #[repr(C)]
38 pub enum DecodeError {
39         /// A version byte specified something we don't know how to handle.
40         ///
41         /// Includes unknown realm byte in an onion hop data packet.
42         UnknownVersion,
43         /// Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type)
44         UnknownRequiredFeature,
45         /// Value was invalid.
46         ///
47         /// For example, a byte which was supposed to be a bool was something other than a 0
48         /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
49         /// syntactically incorrect, etc.
50         InvalidValue,
51         /// The buffer to be read was too short.
52         ShortRead,
53         /// A length descriptor in the packet didn't describe the later data correctly.
54         BadLengthDescriptor,
55         /// Error from [`std::io`].
56         Io(
57                 crate::c_types::IOError),
58         /// The message included zlib-compressed values, which we don't support.
59         UnsupportedCompression,
60 }
61 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
62 pub(crate) type nativeDecodeError = DecodeErrorImport;
63
64 impl DecodeError {
65         #[allow(unused)]
66         pub(crate) fn to_native(&self) -> nativeDecodeError {
67                 match self {
68                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
69                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
70                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
71                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
72                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
73                         DecodeError::Io (ref a, ) => {
74                                 let mut a_nonref = Clone::clone(a);
75                                 nativeDecodeError::Io (
76                                         a_nonref.to_rust_kind(),
77                                 )
78                         },
79                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
80                 }
81         }
82         #[allow(unused)]
83         pub(crate) fn into_native(self) -> nativeDecodeError {
84                 match self {
85                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
86                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
87                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
88                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
89                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
90                         DecodeError::Io (mut a, ) => {
91                                 nativeDecodeError::Io (
92                                         a.to_rust_kind(),
93                                 )
94                         },
95                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
96                 }
97         }
98         #[allow(unused)]
99         pub(crate) fn from_native(native: &nativeDecodeError) -> Self {
100                 match native {
101                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
102                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
103                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
104                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
105                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
106                         nativeDecodeError::Io (ref a, ) => {
107                                 let mut a_nonref = Clone::clone(a);
108                                 DecodeError::Io (
109                                         crate::c_types::IOError::from_rust_kind(a_nonref),
110                                 )
111                         },
112                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
113                 }
114         }
115         #[allow(unused)]
116         pub(crate) fn native_into(native: nativeDecodeError) -> Self {
117                 match native {
118                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
119                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
120                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
121                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
122                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
123                         nativeDecodeError::Io (mut a, ) => {
124                                 DecodeError::Io (
125                                         crate::c_types::IOError::from_rust_kind(a),
126                                 )
127                         },
128                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
129                 }
130         }
131 }
132 /// Frees any resources used by the DecodeError
133 #[no_mangle]
134 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
135 /// Creates a copy of the DecodeError
136 #[no_mangle]
137 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
138         orig.clone()
139 }
140 #[no_mangle]
141 /// Utility method to constructs a new UnknownVersion-variant DecodeError
142 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
143         DecodeError::UnknownVersion}
144 #[no_mangle]
145 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
146 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
147         DecodeError::UnknownRequiredFeature}
148 #[no_mangle]
149 /// Utility method to constructs a new InvalidValue-variant DecodeError
150 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
151         DecodeError::InvalidValue}
152 #[no_mangle]
153 /// Utility method to constructs a new ShortRead-variant DecodeError
154 pub extern "C" fn DecodeError_short_read() -> DecodeError {
155         DecodeError::ShortRead}
156 #[no_mangle]
157 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
158 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
159         DecodeError::BadLengthDescriptor}
160 #[no_mangle]
161 /// Utility method to constructs a new Io-variant DecodeError
162 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
163         DecodeError::Io(a, )
164 }
165 #[no_mangle]
166 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
167 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
168         DecodeError::UnsupportedCompression}
169 /// Checks if two DecodeErrors contain equal inner contents.
170 /// This ignores pointers and is_owned flags and looks at the values in fields.
171 #[no_mangle]
172 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
173         if &a.to_native() == &b.to_native() { true } else { false }
174 }
175
176 use lightning::ln::msgs::Init as nativeInitImport;
177 pub(crate) type nativeInit = nativeInitImport;
178
179 /// An [`init`] message to be sent to or received from a peer.
180 ///
181 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
182 #[must_use]
183 #[repr(C)]
184 pub struct Init {
185         /// A pointer to the opaque Rust object.
186
187         /// Nearly everywhere, inner must be non-null, however in places where
188         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
189         pub inner: *mut nativeInit,
190         /// Indicates that this is the only struct which contains the same pointer.
191
192         /// Rust functions which take ownership of an object provided via an argument require
193         /// this to be true and invalidate the object pointed to by inner.
194         pub is_owned: bool,
195 }
196
197 impl Drop for Init {
198         fn drop(&mut self) {
199                 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
200                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
201                 }
202         }
203 }
204 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
205 #[no_mangle]
206 pub extern "C" fn Init_free(this_obj: Init) { }
207 #[allow(unused)]
208 /// Used only if an object of this type is returned as a trait impl by a method
209 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
210         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
211 }
212 #[allow(unused)]
213 impl Init {
214         pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
215                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
216         }
217         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
218                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
219         }
220         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
221         pub(crate) fn take_inner(mut self) -> *mut nativeInit {
222                 assert!(self.is_owned);
223                 let ret = ObjOps::untweak_ptr(self.inner);
224                 self.inner = core::ptr::null_mut();
225                 ret
226         }
227 }
228 /// The relevant features which the sender supports.
229 #[no_mangle]
230 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
231         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
232         crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }
233 }
234 /// The relevant features which the sender supports.
235 #[no_mangle]
236 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
237         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
238 }
239 /// Indicates chains the sender is interested in.
240 ///
241 /// If there are no common chains, the connection will be closed.
242 ///
243 /// Returns a copy of the field.
244 #[no_mangle]
245 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ChainHashZZ {
246         let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
247         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ChainHashZZ::None } else { crate::c_types::derived::COption_CVec_ChainHashZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_inner_val_0.into() }) };
248         local_inner_val
249 }
250 /// Indicates chains the sender is interested in.
251 ///
252 /// If there are no common chains, the connection will be closed.
253 #[no_mangle]
254 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ChainHashZZ) {
255         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_val_0 }})} };
256         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
257 }
258 /// The receipient's network address.
259 ///
260 /// This adds the option to report a remote IP address back to a connecting peer using the init
261 /// message. A node can decide to use that information to discover a potential update to its
262 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
263 /// the new address.
264 #[no_mangle]
265 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_NetAddressZ {
266         let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
267         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NetAddressZ::None } else { crate::c_types::derived::COption_NetAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::msgs::NetAddress::native_into((*inner_val.as_ref().unwrap()).clone()) }) };
268         local_inner_val
269 }
270 /// The receipient's network address.
271 ///
272 /// This adds the option to report a remote IP address back to a connecting peer using the init
273 /// message. A node can decide to use that information to discover a potential update to its
274 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
275 /// the new address.
276 #[no_mangle]
277 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_NetAddressZ) {
278         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
279         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
280 }
281 /// Constructs a new Init given each field
282 #[must_use]
283 #[no_mangle]
284 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ChainHashZZ, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init {
285         let mut local_networks_arg = { /*networks_arg*/ let networks_arg_opt = networks_arg; if networks_arg_opt.is_none() { None } else { Some({ { let mut local_networks_arg_0 = Vec::new(); for mut item in { networks_arg_opt.take() }.into_rust().drain(..) { local_networks_arg_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_networks_arg_0 }})} };
286         let mut local_remote_network_address_arg = { /*remote_network_address_arg*/ let remote_network_address_arg_opt = remote_network_address_arg; if remote_network_address_arg_opt.is_none() { None } else { Some({ { { remote_network_address_arg_opt.take() }.into_native() }})} };
287         Init { inner: ObjOps::heap_alloc(nativeInit {
288                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
289                 networks: local_networks_arg,
290                 remote_network_address: local_remote_network_address_arg,
291         }), is_owned: true }
292 }
293 impl Clone for Init {
294         fn clone(&self) -> Self {
295                 Self {
296                         inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
297                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
298                         is_owned: true,
299                 }
300         }
301 }
302 #[allow(unused)]
303 /// Used only if an object of this type is returned as a trait impl by a method
304 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
305         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
306 }
307 #[no_mangle]
308 /// Creates a copy of the Init
309 pub extern "C" fn Init_clone(orig: &Init) -> Init {
310         orig.clone()
311 }
312 /// Checks if two Inits contain equal inner contents.
313 /// This ignores pointers and is_owned flags and looks at the values in fields.
314 /// Two objects with NULL inner values will be considered "equal" here.
315 #[no_mangle]
316 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
317         if a.inner == b.inner { return true; }
318         if a.inner.is_null() || b.inner.is_null() { return false; }
319         if a.get_native_ref() == b.get_native_ref() { true } else { false }
320 }
321
322 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
323 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
324
325 /// An [`error`] message to be sent to or received from a peer.
326 ///
327 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
328 #[must_use]
329 #[repr(C)]
330 pub struct ErrorMessage {
331         /// A pointer to the opaque Rust object.
332
333         /// Nearly everywhere, inner must be non-null, however in places where
334         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
335         pub inner: *mut nativeErrorMessage,
336         /// Indicates that this is the only struct which contains the same pointer.
337
338         /// Rust functions which take ownership of an object provided via an argument require
339         /// this to be true and invalidate the object pointed to by inner.
340         pub is_owned: bool,
341 }
342
343 impl Drop for ErrorMessage {
344         fn drop(&mut self) {
345                 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
346                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
347                 }
348         }
349 }
350 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
351 #[no_mangle]
352 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
353 #[allow(unused)]
354 /// Used only if an object of this type is returned as a trait impl by a method
355 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
356         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
357 }
358 #[allow(unused)]
359 impl ErrorMessage {
360         pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
361                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
362         }
363         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
364                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
365         }
366         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
367         pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
368                 assert!(self.is_owned);
369                 let ret = ObjOps::untweak_ptr(self.inner);
370                 self.inner = core::ptr::null_mut();
371                 ret
372         }
373 }
374 /// The channel ID involved in the error.
375 ///
376 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
377 /// with the sending peer should be closed.
378 #[no_mangle]
379 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
380         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
381         inner_val
382 }
383 /// The channel ID involved in the error.
384 ///
385 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
386 /// with the sending peer should be closed.
387 #[no_mangle]
388 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
389         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
390 }
391 /// A possibly human-readable error description.
392 ///
393 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
394 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
395 /// the terminal emulator or the logging subsystem.
396 #[no_mangle]
397 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
398         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
399         inner_val.as_str().into()
400 }
401 /// A possibly human-readable error description.
402 ///
403 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
404 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
405 /// the terminal emulator or the logging subsystem.
406 #[no_mangle]
407 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
408         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
409 }
410 /// Constructs a new ErrorMessage given each field
411 #[must_use]
412 #[no_mangle]
413 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
414         ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
415                 channel_id: channel_id_arg.data,
416                 data: data_arg.into_string(),
417         }), is_owned: true }
418 }
419 impl Clone for ErrorMessage {
420         fn clone(&self) -> Self {
421                 Self {
422                         inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
423                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
424                         is_owned: true,
425                 }
426         }
427 }
428 #[allow(unused)]
429 /// Used only if an object of this type is returned as a trait impl by a method
430 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
431         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
432 }
433 #[no_mangle]
434 /// Creates a copy of the ErrorMessage
435 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
436         orig.clone()
437 }
438 /// Checks if two ErrorMessages contain equal inner contents.
439 /// This ignores pointers and is_owned flags and looks at the values in fields.
440 /// Two objects with NULL inner values will be considered "equal" here.
441 #[no_mangle]
442 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
443         if a.inner == b.inner { return true; }
444         if a.inner.is_null() || b.inner.is_null() { return false; }
445         if a.get_native_ref() == b.get_native_ref() { true } else { false }
446 }
447
448 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
449 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
450
451 /// A [`warning`] message to be sent to or received from a peer.
452 ///
453 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
454 #[must_use]
455 #[repr(C)]
456 pub struct WarningMessage {
457         /// A pointer to the opaque Rust object.
458
459         /// Nearly everywhere, inner must be non-null, however in places where
460         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
461         pub inner: *mut nativeWarningMessage,
462         /// Indicates that this is the only struct which contains the same pointer.
463
464         /// Rust functions which take ownership of an object provided via an argument require
465         /// this to be true and invalidate the object pointed to by inner.
466         pub is_owned: bool,
467 }
468
469 impl Drop for WarningMessage {
470         fn drop(&mut self) {
471                 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
472                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
473                 }
474         }
475 }
476 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
477 #[no_mangle]
478 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
479 #[allow(unused)]
480 /// Used only if an object of this type is returned as a trait impl by a method
481 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
482         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
483 }
484 #[allow(unused)]
485 impl WarningMessage {
486         pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
487                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
488         }
489         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
490                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
491         }
492         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
493         pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
494                 assert!(self.is_owned);
495                 let ret = ObjOps::untweak_ptr(self.inner);
496                 self.inner = core::ptr::null_mut();
497                 ret
498         }
499 }
500 /// The channel ID involved in the warning.
501 ///
502 /// All-0s indicates a warning unrelated to a specific channel.
503 #[no_mangle]
504 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
505         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
506         inner_val
507 }
508 /// The channel ID involved in the warning.
509 ///
510 /// All-0s indicates a warning unrelated to a specific channel.
511 #[no_mangle]
512 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
513         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
514 }
515 /// A possibly human-readable warning description.
516 ///
517 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
518 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
519 /// the terminal emulator or the logging subsystem.
520 #[no_mangle]
521 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
522         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
523         inner_val.as_str().into()
524 }
525 /// A possibly human-readable warning description.
526 ///
527 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
528 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
529 /// the terminal emulator or the logging subsystem.
530 #[no_mangle]
531 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
532         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
533 }
534 /// Constructs a new WarningMessage given each field
535 #[must_use]
536 #[no_mangle]
537 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
538         WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
539                 channel_id: channel_id_arg.data,
540                 data: data_arg.into_string(),
541         }), is_owned: true }
542 }
543 impl Clone for WarningMessage {
544         fn clone(&self) -> Self {
545                 Self {
546                         inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
547                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
548                         is_owned: true,
549                 }
550         }
551 }
552 #[allow(unused)]
553 /// Used only if an object of this type is returned as a trait impl by a method
554 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
555         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void
556 }
557 #[no_mangle]
558 /// Creates a copy of the WarningMessage
559 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
560         orig.clone()
561 }
562 /// Checks if two WarningMessages contain equal inner contents.
563 /// This ignores pointers and is_owned flags and looks at the values in fields.
564 /// Two objects with NULL inner values will be considered "equal" here.
565 #[no_mangle]
566 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
567         if a.inner == b.inner { return true; }
568         if a.inner.is_null() || b.inner.is_null() { return false; }
569         if a.get_native_ref() == b.get_native_ref() { true } else { false }
570 }
571
572 use lightning::ln::msgs::Ping as nativePingImport;
573 pub(crate) type nativePing = nativePingImport;
574
575 /// A [`ping`] message to be sent to or received from a peer.
576 ///
577 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
578 #[must_use]
579 #[repr(C)]
580 pub struct Ping {
581         /// A pointer to the opaque Rust object.
582
583         /// Nearly everywhere, inner must be non-null, however in places where
584         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
585         pub inner: *mut nativePing,
586         /// Indicates that this is the only struct which contains the same pointer.
587
588         /// Rust functions which take ownership of an object provided via an argument require
589         /// this to be true and invalidate the object pointed to by inner.
590         pub is_owned: bool,
591 }
592
593 impl Drop for Ping {
594         fn drop(&mut self) {
595                 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
596                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
597                 }
598         }
599 }
600 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
601 #[no_mangle]
602 pub extern "C" fn Ping_free(this_obj: Ping) { }
603 #[allow(unused)]
604 /// Used only if an object of this type is returned as a trait impl by a method
605 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
606         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
607 }
608 #[allow(unused)]
609 impl Ping {
610         pub(crate) fn get_native_ref(&self) -> &'static nativePing {
611                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
612         }
613         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
614                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
615         }
616         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
617         pub(crate) fn take_inner(mut self) -> *mut nativePing {
618                 assert!(self.is_owned);
619                 let ret = ObjOps::untweak_ptr(self.inner);
620                 self.inner = core::ptr::null_mut();
621                 ret
622         }
623 }
624 /// The desired response length.
625 #[no_mangle]
626 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
627         let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
628         *inner_val
629 }
630 /// The desired response length.
631 #[no_mangle]
632 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
633         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
634 }
635 /// The ping packet size.
636 ///
637 /// This field is not sent on the wire. byteslen zeros are sent.
638 #[no_mangle]
639 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
640         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
641         *inner_val
642 }
643 /// The ping packet size.
644 ///
645 /// This field is not sent on the wire. byteslen zeros are sent.
646 #[no_mangle]
647 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
648         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
649 }
650 /// Constructs a new Ping given each field
651 #[must_use]
652 #[no_mangle]
653 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
654         Ping { inner: ObjOps::heap_alloc(nativePing {
655                 ponglen: ponglen_arg,
656                 byteslen: byteslen_arg,
657         }), is_owned: true }
658 }
659 impl Clone for Ping {
660         fn clone(&self) -> Self {
661                 Self {
662                         inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
663                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
664                         is_owned: true,
665                 }
666         }
667 }
668 #[allow(unused)]
669 /// Used only if an object of this type is returned as a trait impl by a method
670 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
671         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
672 }
673 #[no_mangle]
674 /// Creates a copy of the Ping
675 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
676         orig.clone()
677 }
678 /// Checks if two Pings contain equal inner contents.
679 /// This ignores pointers and is_owned flags and looks at the values in fields.
680 /// Two objects with NULL inner values will be considered "equal" here.
681 #[no_mangle]
682 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
683         if a.inner == b.inner { return true; }
684         if a.inner.is_null() || b.inner.is_null() { return false; }
685         if a.get_native_ref() == b.get_native_ref() { true } else { false }
686 }
687
688 use lightning::ln::msgs::Pong as nativePongImport;
689 pub(crate) type nativePong = nativePongImport;
690
691 /// A [`pong`] message to be sent to or received from a peer.
692 ///
693 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
694 #[must_use]
695 #[repr(C)]
696 pub struct Pong {
697         /// A pointer to the opaque Rust object.
698
699         /// Nearly everywhere, inner must be non-null, however in places where
700         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
701         pub inner: *mut nativePong,
702         /// Indicates that this is the only struct which contains the same pointer.
703
704         /// Rust functions which take ownership of an object provided via an argument require
705         /// this to be true and invalidate the object pointed to by inner.
706         pub is_owned: bool,
707 }
708
709 impl Drop for Pong {
710         fn drop(&mut self) {
711                 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
712                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
713                 }
714         }
715 }
716 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
717 #[no_mangle]
718 pub extern "C" fn Pong_free(this_obj: Pong) { }
719 #[allow(unused)]
720 /// Used only if an object of this type is returned as a trait impl by a method
721 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
722         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
723 }
724 #[allow(unused)]
725 impl Pong {
726         pub(crate) fn get_native_ref(&self) -> &'static nativePong {
727                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
728         }
729         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
730                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
731         }
732         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
733         pub(crate) fn take_inner(mut self) -> *mut nativePong {
734                 assert!(self.is_owned);
735                 let ret = ObjOps::untweak_ptr(self.inner);
736                 self.inner = core::ptr::null_mut();
737                 ret
738         }
739 }
740 /// The pong packet size.
741 ///
742 /// This field is not sent on the wire. byteslen zeros are sent.
743 #[no_mangle]
744 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
745         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
746         *inner_val
747 }
748 /// The pong packet size.
749 ///
750 /// This field is not sent on the wire. byteslen zeros are sent.
751 #[no_mangle]
752 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
753         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
754 }
755 /// Constructs a new Pong given each field
756 #[must_use]
757 #[no_mangle]
758 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
759         Pong { inner: ObjOps::heap_alloc(nativePong {
760                 byteslen: byteslen_arg,
761         }), is_owned: true }
762 }
763 impl Clone for Pong {
764         fn clone(&self) -> Self {
765                 Self {
766                         inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
767                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
768                         is_owned: true,
769                 }
770         }
771 }
772 #[allow(unused)]
773 /// Used only if an object of this type is returned as a trait impl by a method
774 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
775         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
776 }
777 #[no_mangle]
778 /// Creates a copy of the Pong
779 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
780         orig.clone()
781 }
782 /// Checks if two Pongs contain equal inner contents.
783 /// This ignores pointers and is_owned flags and looks at the values in fields.
784 /// Two objects with NULL inner values will be considered "equal" here.
785 #[no_mangle]
786 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
787         if a.inner == b.inner { return true; }
788         if a.inner.is_null() || b.inner.is_null() { return false; }
789         if a.get_native_ref() == b.get_native_ref() { true } else { false }
790 }
791
792 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
793 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
794
795 /// An [`open_channel`] message to be sent to or received from a peer.
796 ///
797 /// Used in V1 channel establishment
798 ///
799 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
800 #[must_use]
801 #[repr(C)]
802 pub struct OpenChannel {
803         /// A pointer to the opaque Rust object.
804
805         /// Nearly everywhere, inner must be non-null, however in places where
806         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
807         pub inner: *mut nativeOpenChannel,
808         /// Indicates that this is the only struct which contains the same pointer.
809
810         /// Rust functions which take ownership of an object provided via an argument require
811         /// this to be true and invalidate the object pointed to by inner.
812         pub is_owned: bool,
813 }
814
815 impl Drop for OpenChannel {
816         fn drop(&mut self) {
817                 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
818                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
819                 }
820         }
821 }
822 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
823 #[no_mangle]
824 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
825 #[allow(unused)]
826 /// Used only if an object of this type is returned as a trait impl by a method
827 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
828         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
829 }
830 #[allow(unused)]
831 impl OpenChannel {
832         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
833                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
834         }
835         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
836                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
837         }
838         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
839         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
840                 assert!(self.is_owned);
841                 let ret = ObjOps::untweak_ptr(self.inner);
842                 self.inner = core::ptr::null_mut();
843                 ret
844         }
845 }
846 /// The genesis hash of the blockchain where the channel is to be opened
847 #[no_mangle]
848 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
849         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
850         inner_val.as_inner()
851 }
852 /// The genesis hash of the blockchain where the channel is to be opened
853 #[no_mangle]
854 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
855         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
856 }
857 /// A temporary channel ID, until the funding outpoint is announced
858 #[no_mangle]
859 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
860         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
861         inner_val
862 }
863 /// A temporary channel ID, until the funding outpoint is announced
864 #[no_mangle]
865 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
866         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
867 }
868 /// The channel value
869 #[no_mangle]
870 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
871         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
872         *inner_val
873 }
874 /// The channel value
875 #[no_mangle]
876 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
877         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
878 }
879 /// The amount to push to the counterparty as part of the open, in milli-satoshi
880 #[no_mangle]
881 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
882         let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
883         *inner_val
884 }
885 /// The amount to push to the counterparty as part of the open, in milli-satoshi
886 #[no_mangle]
887 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
888         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
889 }
890 /// The threshold below which outputs on transactions broadcast by sender will be omitted
891 #[no_mangle]
892 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
893         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
894         *inner_val
895 }
896 /// The threshold below which outputs on transactions broadcast by sender will be omitted
897 #[no_mangle]
898 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
899         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
900 }
901 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
902 #[no_mangle]
903 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
904         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
905         *inner_val
906 }
907 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
908 #[no_mangle]
909 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
910         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
911 }
912 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
913 #[no_mangle]
914 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
915         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
916         *inner_val
917 }
918 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
919 #[no_mangle]
920 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
921         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
922 }
923 /// The minimum HTLC size incoming to sender, in milli-satoshi
924 #[no_mangle]
925 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
926         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
927         *inner_val
928 }
929 /// The minimum HTLC size incoming to sender, in milli-satoshi
930 #[no_mangle]
931 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
932         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
933 }
934 /// The feerate per 1000-weight of sender generated transactions, until updated by
935 /// [`UpdateFee`]
936 #[no_mangle]
937 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
938         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
939         *inner_val
940 }
941 /// The feerate per 1000-weight of sender generated transactions, until updated by
942 /// [`UpdateFee`]
943 #[no_mangle]
944 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
945         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
946 }
947 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
948 /// they broadcast a commitment transaction
949 #[no_mangle]
950 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
951         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
952         *inner_val
953 }
954 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
955 /// they broadcast a commitment transaction
956 #[no_mangle]
957 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
958         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
959 }
960 /// The maximum number of inbound HTLCs towards sender
961 #[no_mangle]
962 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
963         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
964         *inner_val
965 }
966 /// The maximum number of inbound HTLCs towards sender
967 #[no_mangle]
968 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
969         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
970 }
971 /// The sender's key controlling the funding transaction
972 #[no_mangle]
973 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
974         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
975         crate::c_types::PublicKey::from_rust(&inner_val)
976 }
977 /// The sender's key controlling the funding transaction
978 #[no_mangle]
979 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
980         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
981 }
982 /// Used to derive a revocation key for transactions broadcast by counterparty
983 #[no_mangle]
984 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
985         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
986         crate::c_types::PublicKey::from_rust(&inner_val)
987 }
988 /// Used to derive a revocation key for transactions broadcast by counterparty
989 #[no_mangle]
990 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
991         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
992 }
993 /// A payment key to sender for transactions broadcast by counterparty
994 #[no_mangle]
995 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
996         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
997         crate::c_types::PublicKey::from_rust(&inner_val)
998 }
999 /// A payment key to sender for transactions broadcast by counterparty
1000 #[no_mangle]
1001 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1002         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1003 }
1004 /// Used to derive a payment key to sender for transactions broadcast by sender
1005 #[no_mangle]
1006 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1007         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1008         crate::c_types::PublicKey::from_rust(&inner_val)
1009 }
1010 /// Used to derive a payment key to sender for transactions broadcast by sender
1011 #[no_mangle]
1012 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1013         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1014 }
1015 /// Used to derive an HTLC payment key to sender
1016 #[no_mangle]
1017 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1018         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1019         crate::c_types::PublicKey::from_rust(&inner_val)
1020 }
1021 /// Used to derive an HTLC payment key to sender
1022 #[no_mangle]
1023 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1024         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1025 }
1026 /// The first to-be-broadcast-by-sender transaction's per commitment point
1027 #[no_mangle]
1028 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1029         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1030         crate::c_types::PublicKey::from_rust(&inner_val)
1031 }
1032 /// The first to-be-broadcast-by-sender transaction's per commitment point
1033 #[no_mangle]
1034 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1035         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1036 }
1037 /// The channel flags to be used
1038 #[no_mangle]
1039 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
1040         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1041         *inner_val
1042 }
1043 /// The channel flags to be used
1044 #[no_mangle]
1045 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
1046         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1047 }
1048 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1049 #[no_mangle]
1050 pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_ScriptZ {
1051         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1052         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1053         local_inner_val
1054 }
1055 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1056 #[no_mangle]
1057 pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_ScriptZ) {
1058         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1059         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1060 }
1061 /// The channel type that this channel will represent
1062 ///
1063 /// If this is `None`, we derive the channel type from the intersection of our
1064 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1065 ///
1066 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1067 #[no_mangle]
1068 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1069         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1070         let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1071         local_inner_val
1072 }
1073 /// The channel type that this channel will represent
1074 ///
1075 /// If this is `None`, we derive the channel type from the intersection of our
1076 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1077 ///
1078 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1079 #[no_mangle]
1080 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1081         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1082         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1083 }
1084 /// Constructs a new OpenChannel given each field
1085 #[must_use]
1086 #[no_mangle]
1087 pub extern "C" fn OpenChannel_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut push_msat_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut feerate_per_kw_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> OpenChannel {
1088         let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1089         let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1090         OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1091                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
1092                 temporary_channel_id: temporary_channel_id_arg.data,
1093                 funding_satoshis: funding_satoshis_arg,
1094                 push_msat: push_msat_arg,
1095                 dust_limit_satoshis: dust_limit_satoshis_arg,
1096                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1097                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1098                 htlc_minimum_msat: htlc_minimum_msat_arg,
1099                 feerate_per_kw: feerate_per_kw_arg,
1100                 to_self_delay: to_self_delay_arg,
1101                 max_accepted_htlcs: max_accepted_htlcs_arg,
1102                 funding_pubkey: funding_pubkey_arg.into_rust(),
1103                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1104                 payment_point: payment_point_arg.into_rust(),
1105                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1106                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1107                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1108                 channel_flags: channel_flags_arg,
1109                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1110                 channel_type: local_channel_type_arg,
1111         }), is_owned: true }
1112 }
1113 impl Clone for OpenChannel {
1114         fn clone(&self) -> Self {
1115                 Self {
1116                         inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1117                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1118                         is_owned: true,
1119                 }
1120         }
1121 }
1122 #[allow(unused)]
1123 /// Used only if an object of this type is returned as a trait impl by a method
1124 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1125         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
1126 }
1127 #[no_mangle]
1128 /// Creates a copy of the OpenChannel
1129 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1130         orig.clone()
1131 }
1132 /// Checks if two OpenChannels contain equal inner contents.
1133 /// This ignores pointers and is_owned flags and looks at the values in fields.
1134 /// Two objects with NULL inner values will be considered "equal" here.
1135 #[no_mangle]
1136 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1137         if a.inner == b.inner { return true; }
1138         if a.inner.is_null() || b.inner.is_null() { return false; }
1139         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1140 }
1141
1142 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1143 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1144
1145 /// An open_channel2 message to be sent by or received from the channel initiator.
1146 ///
1147 /// Used in V2 channel establishment
1148 ///
1149 #[must_use]
1150 #[repr(C)]
1151 pub struct OpenChannelV2 {
1152         /// A pointer to the opaque Rust object.
1153
1154         /// Nearly everywhere, inner must be non-null, however in places where
1155         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1156         pub inner: *mut nativeOpenChannelV2,
1157         /// Indicates that this is the only struct which contains the same pointer.
1158
1159         /// Rust functions which take ownership of an object provided via an argument require
1160         /// this to be true and invalidate the object pointed to by inner.
1161         pub is_owned: bool,
1162 }
1163
1164 impl Drop for OpenChannelV2 {
1165         fn drop(&mut self) {
1166                 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1167                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1168                 }
1169         }
1170 }
1171 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1172 #[no_mangle]
1173 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1174 #[allow(unused)]
1175 /// Used only if an object of this type is returned as a trait impl by a method
1176 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1177         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1178 }
1179 #[allow(unused)]
1180 impl OpenChannelV2 {
1181         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1182                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1183         }
1184         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1185                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1186         }
1187         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1188         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1189                 assert!(self.is_owned);
1190                 let ret = ObjOps::untweak_ptr(self.inner);
1191                 self.inner = core::ptr::null_mut();
1192                 ret
1193         }
1194 }
1195 /// The genesis hash of the blockchain where the channel is to be opened
1196 #[no_mangle]
1197 pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1198         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
1199         inner_val.as_inner()
1200 }
1201 /// The genesis hash of the blockchain where the channel is to be opened
1202 #[no_mangle]
1203 pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1204         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
1205 }
1206 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1207 #[no_mangle]
1208 pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1209         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1210         inner_val
1211 }
1212 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1213 #[no_mangle]
1214 pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1215         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1216 }
1217 /// The feerate for the funding transaction set by the channel initiator
1218 #[no_mangle]
1219 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1220         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1221         *inner_val
1222 }
1223 /// The feerate for the funding transaction set by the channel initiator
1224 #[no_mangle]
1225 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1226         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1227 }
1228 /// The feerate for the commitment transaction set by the channel initiator
1229 #[no_mangle]
1230 pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1231         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1232         *inner_val
1233 }
1234 /// The feerate for the commitment transaction set by the channel initiator
1235 #[no_mangle]
1236 pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1237         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1238 }
1239 /// Part of the channel value contributed by the channel initiator
1240 #[no_mangle]
1241 pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1242         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1243         *inner_val
1244 }
1245 /// Part of the channel value contributed by the channel initiator
1246 #[no_mangle]
1247 pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1248         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1249 }
1250 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1251 /// omitted
1252 #[no_mangle]
1253 pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1254         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1255         *inner_val
1256 }
1257 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1258 /// omitted
1259 #[no_mangle]
1260 pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1261         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1262 }
1263 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1264 #[no_mangle]
1265 pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 {
1266         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1267         *inner_val
1268 }
1269 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1270 #[no_mangle]
1271 pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1272         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1273 }
1274 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1275 #[no_mangle]
1276 pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 {
1277         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1278         *inner_val
1279 }
1280 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1281 #[no_mangle]
1282 pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1283         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1284 }
1285 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1286 /// broadcast a commitment transaction
1287 #[no_mangle]
1288 pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 {
1289         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1290         *inner_val
1291 }
1292 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1293 /// broadcast a commitment transaction
1294 #[no_mangle]
1295 pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) {
1296         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1297 }
1298 /// The maximum number of inbound HTLCs towards channel initiator
1299 #[no_mangle]
1300 pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 {
1301         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1302         *inner_val
1303 }
1304 /// The maximum number of inbound HTLCs towards channel initiator
1305 #[no_mangle]
1306 pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) {
1307         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1308 }
1309 /// The locktime for the funding transaction
1310 #[no_mangle]
1311 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1312         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1313         *inner_val
1314 }
1315 /// The locktime for the funding transaction
1316 #[no_mangle]
1317 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1318         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1319 }
1320 /// The channel initiator's key controlling the funding transaction
1321 #[no_mangle]
1322 pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1323         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1324         crate::c_types::PublicKey::from_rust(&inner_val)
1325 }
1326 /// The channel initiator's key controlling the funding transaction
1327 #[no_mangle]
1328 pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1329         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1330 }
1331 /// Used to derive a revocation key for transactions broadcast by counterparty
1332 #[no_mangle]
1333 pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1334         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1335         crate::c_types::PublicKey::from_rust(&inner_val)
1336 }
1337 /// Used to derive a revocation key for transactions broadcast by counterparty
1338 #[no_mangle]
1339 pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1340         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1341 }
1342 /// A payment key to channel initiator for transactions broadcast by counterparty
1343 #[no_mangle]
1344 pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1345         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1346         crate::c_types::PublicKey::from_rust(&inner_val)
1347 }
1348 /// A payment key to channel initiator for transactions broadcast by counterparty
1349 #[no_mangle]
1350 pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1351         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1352 }
1353 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1354 /// initiator
1355 #[no_mangle]
1356 pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1357         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1358         crate::c_types::PublicKey::from_rust(&inner_val)
1359 }
1360 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1361 /// initiator
1362 #[no_mangle]
1363 pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1364         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1365 }
1366 /// Used to derive an HTLC payment key to channel initiator
1367 #[no_mangle]
1368 pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1369         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1370         crate::c_types::PublicKey::from_rust(&inner_val)
1371 }
1372 /// Used to derive an HTLC payment key to channel initiator
1373 #[no_mangle]
1374 pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1375         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1376 }
1377 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1378 #[no_mangle]
1379 pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1380         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1381         crate::c_types::PublicKey::from_rust(&inner_val)
1382 }
1383 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1384 #[no_mangle]
1385 pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1386         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1387 }
1388 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1389 #[no_mangle]
1390 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1391         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1392         crate::c_types::PublicKey::from_rust(&inner_val)
1393 }
1394 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1395 #[no_mangle]
1396 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1397         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1398 }
1399 /// Channel flags
1400 #[no_mangle]
1401 pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 {
1402         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1403         *inner_val
1404 }
1405 /// Channel flags
1406 #[no_mangle]
1407 pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) {
1408         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1409 }
1410 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1411 /// collaboratively close
1412 #[no_mangle]
1413 pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_ScriptZ {
1414         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1415         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1416         local_inner_val
1417 }
1418 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1419 /// collaboratively close
1420 #[no_mangle]
1421 pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_ScriptZ) {
1422         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1423         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1424 }
1425 /// The channel type that this channel will represent. If none is set, we derive the channel
1426 /// type from the intersection of our feature bits with our counterparty's feature bits from
1427 /// the Init message.
1428 ///
1429 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1430 #[no_mangle]
1431 pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
1432         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1433         let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1434         local_inner_val
1435 }
1436 /// The channel type that this channel will represent. If none is set, we derive the channel
1437 /// type from the intersection of our feature bits with our counterparty's feature bits from
1438 /// the Init message.
1439 ///
1440 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1441 #[no_mangle]
1442 pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1443         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1444         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1445 }
1446 /// Optionally, a requirement that only confirmed inputs can be added
1447 #[no_mangle]
1448 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1449         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1450         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /*  { () /**/ } */ };
1451         local_inner_val
1452 }
1453 /// Optionally, a requirement that only confirmed inputs can be added
1454 #[no_mangle]
1455 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1456         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1457         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1458 }
1459 /// Constructs a new OpenChannelV2 given each field
1460 #[must_use]
1461 #[no_mangle]
1462 pub extern "C" fn OpenChannelV2_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_feerate_sat_per_1000_weight_arg: u32, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 {
1463         let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1464         let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1465         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1466         OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1467                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
1468                 temporary_channel_id: temporary_channel_id_arg.data,
1469                 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1470                 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1471                 funding_satoshis: funding_satoshis_arg,
1472                 dust_limit_satoshis: dust_limit_satoshis_arg,
1473                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1474                 htlc_minimum_msat: htlc_minimum_msat_arg,
1475                 to_self_delay: to_self_delay_arg,
1476                 max_accepted_htlcs: max_accepted_htlcs_arg,
1477                 locktime: locktime_arg,
1478                 funding_pubkey: funding_pubkey_arg.into_rust(),
1479                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1480                 payment_basepoint: payment_basepoint_arg.into_rust(),
1481                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1482                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1483                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1484                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1485                 channel_flags: channel_flags_arg,
1486                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1487                 channel_type: local_channel_type_arg,
1488                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1489         }), is_owned: true }
1490 }
1491 impl Clone for OpenChannelV2 {
1492         fn clone(&self) -> Self {
1493                 Self {
1494                         inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1495                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1496                         is_owned: true,
1497                 }
1498         }
1499 }
1500 #[allow(unused)]
1501 /// Used only if an object of this type is returned as a trait impl by a method
1502 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1503         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannelV2)).clone() })) as *mut c_void
1504 }
1505 #[no_mangle]
1506 /// Creates a copy of the OpenChannelV2
1507 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1508         orig.clone()
1509 }
1510 /// Checks if two OpenChannelV2s contain equal inner contents.
1511 /// This ignores pointers and is_owned flags and looks at the values in fields.
1512 /// Two objects with NULL inner values will be considered "equal" here.
1513 #[no_mangle]
1514 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1515         if a.inner == b.inner { return true; }
1516         if a.inner.is_null() || b.inner.is_null() { return false; }
1517         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1518 }
1519
1520 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1521 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1522
1523 /// An [`accept_channel`] message to be sent to or received from a peer.
1524 ///
1525 /// Used in V1 channel establishment
1526 ///
1527 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1528 #[must_use]
1529 #[repr(C)]
1530 pub struct AcceptChannel {
1531         /// A pointer to the opaque Rust object.
1532
1533         /// Nearly everywhere, inner must be non-null, however in places where
1534         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1535         pub inner: *mut nativeAcceptChannel,
1536         /// Indicates that this is the only struct which contains the same pointer.
1537
1538         /// Rust functions which take ownership of an object provided via an argument require
1539         /// this to be true and invalidate the object pointed to by inner.
1540         pub is_owned: bool,
1541 }
1542
1543 impl Drop for AcceptChannel {
1544         fn drop(&mut self) {
1545                 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1546                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1547                 }
1548         }
1549 }
1550 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1551 #[no_mangle]
1552 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1553 #[allow(unused)]
1554 /// Used only if an object of this type is returned as a trait impl by a method
1555 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1556         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1557 }
1558 #[allow(unused)]
1559 impl AcceptChannel {
1560         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1561                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1562         }
1563         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1564                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1565         }
1566         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1567         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1568                 assert!(self.is_owned);
1569                 let ret = ObjOps::untweak_ptr(self.inner);
1570                 self.inner = core::ptr::null_mut();
1571                 ret
1572         }
1573 }
1574 /// A temporary channel ID, until the funding outpoint is announced
1575 #[no_mangle]
1576 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1577         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1578         inner_val
1579 }
1580 /// A temporary channel ID, until the funding outpoint is announced
1581 #[no_mangle]
1582 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1583         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1584 }
1585 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1586 #[no_mangle]
1587 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1588         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1589         *inner_val
1590 }
1591 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1592 #[no_mangle]
1593 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1594         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1595 }
1596 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1597 #[no_mangle]
1598 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1599         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1600         *inner_val
1601 }
1602 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1603 #[no_mangle]
1604 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1605         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1606 }
1607 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1608 #[no_mangle]
1609 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1610         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1611         *inner_val
1612 }
1613 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1614 #[no_mangle]
1615 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1616         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1617 }
1618 /// The minimum HTLC size incoming to sender, in milli-satoshi
1619 #[no_mangle]
1620 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1621         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1622         *inner_val
1623 }
1624 /// The minimum HTLC size incoming to sender, in milli-satoshi
1625 #[no_mangle]
1626 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1627         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1628 }
1629 /// Minimum depth of the funding transaction before the channel is considered open
1630 #[no_mangle]
1631 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1632         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1633         *inner_val
1634 }
1635 /// Minimum depth of the funding transaction before the channel is considered open
1636 #[no_mangle]
1637 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1638         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1639 }
1640 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1641 #[no_mangle]
1642 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1643         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1644         *inner_val
1645 }
1646 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1647 #[no_mangle]
1648 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1649         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1650 }
1651 /// The maximum number of inbound HTLCs towards sender
1652 #[no_mangle]
1653 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1654         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1655         *inner_val
1656 }
1657 /// The maximum number of inbound HTLCs towards sender
1658 #[no_mangle]
1659 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1660         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1661 }
1662 /// The sender's key controlling the funding transaction
1663 #[no_mangle]
1664 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1665         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1666         crate::c_types::PublicKey::from_rust(&inner_val)
1667 }
1668 /// The sender's key controlling the funding transaction
1669 #[no_mangle]
1670 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1671         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1672 }
1673 /// Used to derive a revocation key for transactions broadcast by counterparty
1674 #[no_mangle]
1675 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1676         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1677         crate::c_types::PublicKey::from_rust(&inner_val)
1678 }
1679 /// Used to derive a revocation key for transactions broadcast by counterparty
1680 #[no_mangle]
1681 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1682         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1683 }
1684 /// A payment key to sender for transactions broadcast by counterparty
1685 #[no_mangle]
1686 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1687         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1688         crate::c_types::PublicKey::from_rust(&inner_val)
1689 }
1690 /// A payment key to sender for transactions broadcast by counterparty
1691 #[no_mangle]
1692 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1693         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1694 }
1695 /// Used to derive a payment key to sender for transactions broadcast by sender
1696 #[no_mangle]
1697 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1698         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1699         crate::c_types::PublicKey::from_rust(&inner_val)
1700 }
1701 /// Used to derive a payment key to sender for transactions broadcast by sender
1702 #[no_mangle]
1703 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1704         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1705 }
1706 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1707 #[no_mangle]
1708 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1709         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1710         crate::c_types::PublicKey::from_rust(&inner_val)
1711 }
1712 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1713 #[no_mangle]
1714 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1715         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1716 }
1717 /// The first to-be-broadcast-by-sender transaction's per commitment point
1718 #[no_mangle]
1719 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1720         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1721         crate::c_types::PublicKey::from_rust(&inner_val)
1722 }
1723 /// The first to-be-broadcast-by-sender transaction's per commitment point
1724 #[no_mangle]
1725 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1726         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1727 }
1728 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1729 #[no_mangle]
1730 pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_ScriptZ {
1731         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1732         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1733         local_inner_val
1734 }
1735 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1736 #[no_mangle]
1737 pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_ScriptZ) {
1738         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1739         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1740 }
1741 /// The channel type that this channel will represent.
1742 ///
1743 /// If this is `None`, we derive the channel type from the intersection of
1744 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1745 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1746 ///
1747 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1748 #[no_mangle]
1749 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1750         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1751         let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1752         local_inner_val
1753 }
1754 /// The channel type that this channel will represent.
1755 ///
1756 /// If this is `None`, we derive the channel type from the intersection of
1757 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1758 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1759 ///
1760 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1761 #[no_mangle]
1762 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1763         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1764         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1765 }
1766 /// Constructs a new AcceptChannel given each field
1767 #[must_use]
1768 #[no_mangle]
1769 pub extern "C" fn AcceptChannel_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> AcceptChannel {
1770         let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1771         let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1772         AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1773                 temporary_channel_id: temporary_channel_id_arg.data,
1774                 dust_limit_satoshis: dust_limit_satoshis_arg,
1775                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1776                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1777                 htlc_minimum_msat: htlc_minimum_msat_arg,
1778                 minimum_depth: minimum_depth_arg,
1779                 to_self_delay: to_self_delay_arg,
1780                 max_accepted_htlcs: max_accepted_htlcs_arg,
1781                 funding_pubkey: funding_pubkey_arg.into_rust(),
1782                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1783                 payment_point: payment_point_arg.into_rust(),
1784                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1785                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1786                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1787                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1788                 channel_type: local_channel_type_arg,
1789         }), is_owned: true }
1790 }
1791 impl Clone for AcceptChannel {
1792         fn clone(&self) -> Self {
1793                 Self {
1794                         inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1795                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1796                         is_owned: true,
1797                 }
1798         }
1799 }
1800 #[allow(unused)]
1801 /// Used only if an object of this type is returned as a trait impl by a method
1802 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1803         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1804 }
1805 #[no_mangle]
1806 /// Creates a copy of the AcceptChannel
1807 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1808         orig.clone()
1809 }
1810 /// Checks if two AcceptChannels contain equal inner contents.
1811 /// This ignores pointers and is_owned flags and looks at the values in fields.
1812 /// Two objects with NULL inner values will be considered "equal" here.
1813 #[no_mangle]
1814 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1815         if a.inner == b.inner { return true; }
1816         if a.inner.is_null() || b.inner.is_null() { return false; }
1817         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1818 }
1819
1820 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1821 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1822
1823 /// An accept_channel2 message to be sent by or received from the channel accepter.
1824 ///
1825 /// Used in V2 channel establishment
1826 ///
1827 #[must_use]
1828 #[repr(C)]
1829 pub struct AcceptChannelV2 {
1830         /// A pointer to the opaque Rust object.
1831
1832         /// Nearly everywhere, inner must be non-null, however in places where
1833         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1834         pub inner: *mut nativeAcceptChannelV2,
1835         /// Indicates that this is the only struct which contains the same pointer.
1836
1837         /// Rust functions which take ownership of an object provided via an argument require
1838         /// this to be true and invalidate the object pointed to by inner.
1839         pub is_owned: bool,
1840 }
1841
1842 impl Drop for AcceptChannelV2 {
1843         fn drop(&mut self) {
1844                 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
1845                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1846                 }
1847         }
1848 }
1849 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
1850 #[no_mangle]
1851 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
1852 #[allow(unused)]
1853 /// Used only if an object of this type is returned as a trait impl by a method
1854 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
1855         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
1856 }
1857 #[allow(unused)]
1858 impl AcceptChannelV2 {
1859         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
1860                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1861         }
1862         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
1863                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1864         }
1865         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1866         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
1867                 assert!(self.is_owned);
1868                 let ret = ObjOps::untweak_ptr(self.inner);
1869                 self.inner = core::ptr::null_mut();
1870                 ret
1871         }
1872 }
1873 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1874 #[no_mangle]
1875 pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] {
1876         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1877         inner_val
1878 }
1879 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1880 #[no_mangle]
1881 pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1882         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1883 }
1884 /// Part of the channel value contributed by the channel acceptor
1885 #[no_mangle]
1886 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1887         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1888         *inner_val
1889 }
1890 /// Part of the channel value contributed by the channel acceptor
1891 #[no_mangle]
1892 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1893         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1894 }
1895 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1896 /// omitted
1897 #[no_mangle]
1898 pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1899         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1900         *inner_val
1901 }
1902 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1903 /// omitted
1904 #[no_mangle]
1905 pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1906         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1907 }
1908 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1909 #[no_mangle]
1910 pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 {
1911         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1912         *inner_val
1913 }
1914 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1915 #[no_mangle]
1916 pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1917         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1918 }
1919 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1920 #[no_mangle]
1921 pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 {
1922         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1923         *inner_val
1924 }
1925 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1926 #[no_mangle]
1927 pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1928         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1929 }
1930 /// Minimum depth of the funding transaction before the channel is considered open
1931 #[no_mangle]
1932 pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 {
1933         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1934         *inner_val
1935 }
1936 /// Minimum depth of the funding transaction before the channel is considered open
1937 #[no_mangle]
1938 pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) {
1939         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1940 }
1941 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1942 /// broadcast a commitment transaction
1943 #[no_mangle]
1944 pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 {
1945         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1946         *inner_val
1947 }
1948 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1949 /// broadcast a commitment transaction
1950 #[no_mangle]
1951 pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1952         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1953 }
1954 /// The maximum number of inbound HTLCs towards channel acceptor
1955 #[no_mangle]
1956 pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 {
1957         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1958         *inner_val
1959 }
1960 /// The maximum number of inbound HTLCs towards channel acceptor
1961 #[no_mangle]
1962 pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1963         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1964 }
1965 /// The channel acceptor's key controlling the funding transaction
1966 #[no_mangle]
1967 pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1968         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1969         crate::c_types::PublicKey::from_rust(&inner_val)
1970 }
1971 /// The channel acceptor's key controlling the funding transaction
1972 #[no_mangle]
1973 pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1974         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1975 }
1976 /// Used to derive a revocation key for transactions broadcast by counterparty
1977 #[no_mangle]
1978 pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1979         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1980         crate::c_types::PublicKey::from_rust(&inner_val)
1981 }
1982 /// Used to derive a revocation key for transactions broadcast by counterparty
1983 #[no_mangle]
1984 pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1985         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1986 }
1987 /// A payment key to channel acceptor for transactions broadcast by counterparty
1988 #[no_mangle]
1989 pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1990         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1991         crate::c_types::PublicKey::from_rust(&inner_val)
1992 }
1993 /// A payment key to channel acceptor for transactions broadcast by counterparty
1994 #[no_mangle]
1995 pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1996         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1997 }
1998 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
1999 /// acceptor
2000 #[no_mangle]
2001 pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2002         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
2003         crate::c_types::PublicKey::from_rust(&inner_val)
2004 }
2005 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2006 /// acceptor
2007 #[no_mangle]
2008 pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2009         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
2010 }
2011 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2012 #[no_mangle]
2013 pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2014         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
2015         crate::c_types::PublicKey::from_rust(&inner_val)
2016 }
2017 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2018 #[no_mangle]
2019 pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2020         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
2021 }
2022 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2023 #[no_mangle]
2024 pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2025         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
2026         crate::c_types::PublicKey::from_rust(&inner_val)
2027 }
2028 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2029 #[no_mangle]
2030 pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2031         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
2032 }
2033 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2034 #[no_mangle]
2035 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2036         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2037         crate::c_types::PublicKey::from_rust(&inner_val)
2038 }
2039 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2040 #[no_mangle]
2041 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2042         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2043 }
2044 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2045 /// collaboratively close
2046 #[no_mangle]
2047 pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_ScriptZ {
2048         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
2049         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
2050         local_inner_val
2051 }
2052 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2053 /// collaboratively close
2054 #[no_mangle]
2055 pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_ScriptZ) {
2056         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
2057         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
2058 }
2059 /// The channel type that this channel will represent. If none is set, we derive the channel
2060 /// type from the intersection of our feature bits with our counterparty's feature bits from
2061 /// the Init message.
2062 ///
2063 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2064 ///
2065 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2066 #[no_mangle]
2067 pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
2068         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
2069         let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
2070         local_inner_val
2071 }
2072 /// The channel type that this channel will represent. If none is set, we derive the channel
2073 /// type from the intersection of our feature bits with our counterparty's feature bits from
2074 /// the Init message.
2075 ///
2076 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2077 ///
2078 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
2079 #[no_mangle]
2080 pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
2081         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2082         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
2083 }
2084 /// Optionally, a requirement that only confirmed inputs can be added
2085 #[no_mangle]
2086 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2087         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2088         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /*  { () /**/ } */ };
2089         local_inner_val
2090 }
2091 /// Optionally, a requirement that only confirmed inputs can be added
2092 #[no_mangle]
2093 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2094         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2095         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2096 }
2097 /// Constructs a new AcceptChannelV2 given each field
2098 #[must_use]
2099 #[no_mangle]
2100 pub extern "C" fn AcceptChannelV2_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 {
2101         let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
2102         let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
2103         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2104         AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2105                 temporary_channel_id: temporary_channel_id_arg.data,
2106                 funding_satoshis: funding_satoshis_arg,
2107                 dust_limit_satoshis: dust_limit_satoshis_arg,
2108                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
2109                 htlc_minimum_msat: htlc_minimum_msat_arg,
2110                 minimum_depth: minimum_depth_arg,
2111                 to_self_delay: to_self_delay_arg,
2112                 max_accepted_htlcs: max_accepted_htlcs_arg,
2113                 funding_pubkey: funding_pubkey_arg.into_rust(),
2114                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
2115                 payment_basepoint: payment_basepoint_arg.into_rust(),
2116                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
2117                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
2118                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
2119                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2120                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
2121                 channel_type: local_channel_type_arg,
2122                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2123         }), is_owned: true }
2124 }
2125 impl Clone for AcceptChannelV2 {
2126         fn clone(&self) -> Self {
2127                 Self {
2128                         inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2129                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2130                         is_owned: true,
2131                 }
2132         }
2133 }
2134 #[allow(unused)]
2135 /// Used only if an object of this type is returned as a trait impl by a method
2136 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2137         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannelV2)).clone() })) as *mut c_void
2138 }
2139 #[no_mangle]
2140 /// Creates a copy of the AcceptChannelV2
2141 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2142         orig.clone()
2143 }
2144 /// Checks if two AcceptChannelV2s contain equal inner contents.
2145 /// This ignores pointers and is_owned flags and looks at the values in fields.
2146 /// Two objects with NULL inner values will be considered "equal" here.
2147 #[no_mangle]
2148 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2149         if a.inner == b.inner { return true; }
2150         if a.inner.is_null() || b.inner.is_null() { return false; }
2151         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2152 }
2153
2154 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2155 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2156
2157 /// A [`funding_created`] message to be sent to or received from a peer.
2158 ///
2159 /// Used in V1 channel establishment
2160 ///
2161 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2162 #[must_use]
2163 #[repr(C)]
2164 pub struct FundingCreated {
2165         /// A pointer to the opaque Rust object.
2166
2167         /// Nearly everywhere, inner must be non-null, however in places where
2168         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2169         pub inner: *mut nativeFundingCreated,
2170         /// Indicates that this is the only struct which contains the same pointer.
2171
2172         /// Rust functions which take ownership of an object provided via an argument require
2173         /// this to be true and invalidate the object pointed to by inner.
2174         pub is_owned: bool,
2175 }
2176
2177 impl Drop for FundingCreated {
2178         fn drop(&mut self) {
2179                 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2180                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2181                 }
2182         }
2183 }
2184 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2185 #[no_mangle]
2186 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2187 #[allow(unused)]
2188 /// Used only if an object of this type is returned as a trait impl by a method
2189 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2190         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2191 }
2192 #[allow(unused)]
2193 impl FundingCreated {
2194         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2195                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2196         }
2197         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2198                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2199         }
2200         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2201         pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2202                 assert!(self.is_owned);
2203                 let ret = ObjOps::untweak_ptr(self.inner);
2204                 self.inner = core::ptr::null_mut();
2205                 ret
2206         }
2207 }
2208 /// A temporary channel ID, until the funding is established
2209 #[no_mangle]
2210 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
2211         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2212         inner_val
2213 }
2214 /// A temporary channel ID, until the funding is established
2215 #[no_mangle]
2216 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2217         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
2218 }
2219 /// The funding transaction ID
2220 #[no_mangle]
2221 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2222         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2223         inner_val.as_inner()
2224 }
2225 /// The funding transaction ID
2226 #[no_mangle]
2227 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2228         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2229 }
2230 /// The specific output index funding this channel
2231 #[no_mangle]
2232 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2233         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2234         *inner_val
2235 }
2236 /// The specific output index funding this channel
2237 #[no_mangle]
2238 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2239         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2240 }
2241 /// The signature of the channel initiator (funder) on the initial commitment transaction
2242 #[no_mangle]
2243 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
2244         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2245         crate::c_types::Signature::from_rust(&inner_val)
2246 }
2247 /// The signature of the channel initiator (funder) on the initial commitment transaction
2248 #[no_mangle]
2249 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
2250         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2251 }
2252 /// Constructs a new FundingCreated given each field
2253 #[must_use]
2254 #[no_mangle]
2255 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 {
2256         FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2257                 temporary_channel_id: temporary_channel_id_arg.data,
2258                 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2259                 funding_output_index: funding_output_index_arg,
2260                 signature: signature_arg.into_rust(),
2261         }), is_owned: true }
2262 }
2263 impl Clone for FundingCreated {
2264         fn clone(&self) -> Self {
2265                 Self {
2266                         inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2267                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2268                         is_owned: true,
2269                 }
2270         }
2271 }
2272 #[allow(unused)]
2273 /// Used only if an object of this type is returned as a trait impl by a method
2274 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2275         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
2276 }
2277 #[no_mangle]
2278 /// Creates a copy of the FundingCreated
2279 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2280         orig.clone()
2281 }
2282 /// Checks if two FundingCreateds contain equal inner contents.
2283 /// This ignores pointers and is_owned flags and looks at the values in fields.
2284 /// Two objects with NULL inner values will be considered "equal" here.
2285 #[no_mangle]
2286 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2287         if a.inner == b.inner { return true; }
2288         if a.inner.is_null() || b.inner.is_null() { return false; }
2289         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2290 }
2291
2292 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2293 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2294
2295 /// A [`funding_signed`] message to be sent to or received from a peer.
2296 ///
2297 /// Used in V1 channel establishment
2298 ///
2299 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2300 #[must_use]
2301 #[repr(C)]
2302 pub struct FundingSigned {
2303         /// A pointer to the opaque Rust object.
2304
2305         /// Nearly everywhere, inner must be non-null, however in places where
2306         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2307         pub inner: *mut nativeFundingSigned,
2308         /// Indicates that this is the only struct which contains the same pointer.
2309
2310         /// Rust functions which take ownership of an object provided via an argument require
2311         /// this to be true and invalidate the object pointed to by inner.
2312         pub is_owned: bool,
2313 }
2314
2315 impl Drop for FundingSigned {
2316         fn drop(&mut self) {
2317                 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2318                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2319                 }
2320         }
2321 }
2322 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2323 #[no_mangle]
2324 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2325 #[allow(unused)]
2326 /// Used only if an object of this type is returned as a trait impl by a method
2327 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2328         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2329 }
2330 #[allow(unused)]
2331 impl FundingSigned {
2332         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2333                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2334         }
2335         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2336                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2337         }
2338         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2339         pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2340                 assert!(self.is_owned);
2341                 let ret = ObjOps::untweak_ptr(self.inner);
2342                 self.inner = core::ptr::null_mut();
2343                 ret
2344         }
2345 }
2346 /// The channel ID
2347 #[no_mangle]
2348 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
2349         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2350         inner_val
2351 }
2352 /// The channel ID
2353 #[no_mangle]
2354 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2355         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2356 }
2357 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2358 #[no_mangle]
2359 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
2360         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2361         crate::c_types::Signature::from_rust(&inner_val)
2362 }
2363 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2364 #[no_mangle]
2365 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
2366         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2367 }
2368 /// Constructs a new FundingSigned given each field
2369 #[must_use]
2370 #[no_mangle]
2371 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
2372         FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2373                 channel_id: channel_id_arg.data,
2374                 signature: signature_arg.into_rust(),
2375         }), is_owned: true }
2376 }
2377 impl Clone for FundingSigned {
2378         fn clone(&self) -> Self {
2379                 Self {
2380                         inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2381                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2382                         is_owned: true,
2383                 }
2384         }
2385 }
2386 #[allow(unused)]
2387 /// Used only if an object of this type is returned as a trait impl by a method
2388 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2389         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
2390 }
2391 #[no_mangle]
2392 /// Creates a copy of the FundingSigned
2393 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2394         orig.clone()
2395 }
2396 /// Checks if two FundingSigneds contain equal inner contents.
2397 /// This ignores pointers and is_owned flags and looks at the values in fields.
2398 /// Two objects with NULL inner values will be considered "equal" here.
2399 #[no_mangle]
2400 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2401         if a.inner == b.inner { return true; }
2402         if a.inner.is_null() || b.inner.is_null() { return false; }
2403         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2404 }
2405
2406 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2407 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2408
2409 /// A [`channel_ready`] message to be sent to or received from a peer.
2410 ///
2411 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2412 #[must_use]
2413 #[repr(C)]
2414 pub struct ChannelReady {
2415         /// A pointer to the opaque Rust object.
2416
2417         /// Nearly everywhere, inner must be non-null, however in places where
2418         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2419         pub inner: *mut nativeChannelReady,
2420         /// Indicates that this is the only struct which contains the same pointer.
2421
2422         /// Rust functions which take ownership of an object provided via an argument require
2423         /// this to be true and invalidate the object pointed to by inner.
2424         pub is_owned: bool,
2425 }
2426
2427 impl Drop for ChannelReady {
2428         fn drop(&mut self) {
2429                 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2430                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2431                 }
2432         }
2433 }
2434 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2435 #[no_mangle]
2436 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2437 #[allow(unused)]
2438 /// Used only if an object of this type is returned as a trait impl by a method
2439 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2440         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2441 }
2442 #[allow(unused)]
2443 impl ChannelReady {
2444         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2445                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2446         }
2447         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2448                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2449         }
2450         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2451         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2452                 assert!(self.is_owned);
2453                 let ret = ObjOps::untweak_ptr(self.inner);
2454                 self.inner = core::ptr::null_mut();
2455                 ret
2456         }
2457 }
2458 /// The channel ID
2459 #[no_mangle]
2460 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
2461         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2462         inner_val
2463 }
2464 /// The channel ID
2465 #[no_mangle]
2466 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
2467         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2468 }
2469 /// The per-commitment point of the second commitment transaction
2470 #[no_mangle]
2471 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2472         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2473         crate::c_types::PublicKey::from_rust(&inner_val)
2474 }
2475 /// The per-commitment point of the second commitment transaction
2476 #[no_mangle]
2477 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2478         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2479 }
2480 /// If set, provides a `short_channel_id` alias for this channel.
2481 ///
2482 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2483 /// messages' recipient.
2484 #[no_mangle]
2485 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2486         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2487         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
2488         local_inner_val
2489 }
2490 /// If set, provides a `short_channel_id` alias for this channel.
2491 ///
2492 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2493 /// messages' recipient.
2494 #[no_mangle]
2495 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2496         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2497         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2498 }
2499 /// Constructs a new ChannelReady given each field
2500 #[must_use]
2501 #[no_mangle]
2502 pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady {
2503         let mut local_short_channel_id_alias_arg = if short_channel_id_alias_arg.is_some() { Some( { short_channel_id_alias_arg.take() }) } else { None };
2504         ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2505                 channel_id: channel_id_arg.data,
2506                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2507                 short_channel_id_alias: local_short_channel_id_alias_arg,
2508         }), is_owned: true }
2509 }
2510 impl Clone for ChannelReady {
2511         fn clone(&self) -> Self {
2512                 Self {
2513                         inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2514                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2515                         is_owned: true,
2516                 }
2517         }
2518 }
2519 #[allow(unused)]
2520 /// Used only if an object of this type is returned as a trait impl by a method
2521 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2522         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void
2523 }
2524 #[no_mangle]
2525 /// Creates a copy of the ChannelReady
2526 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2527         orig.clone()
2528 }
2529 /// Checks if two ChannelReadys contain equal inner contents.
2530 /// This ignores pointers and is_owned flags and looks at the values in fields.
2531 /// Two objects with NULL inner values will be considered "equal" here.
2532 #[no_mangle]
2533 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2534         if a.inner == b.inner { return true; }
2535         if a.inner.is_null() || b.inner.is_null() { return false; }
2536         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2537 }
2538
2539 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
2540 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
2541
2542 /// A tx_add_input message for adding an input during interactive transaction construction
2543 ///
2544 #[must_use]
2545 #[repr(C)]
2546 pub struct TxAddInput {
2547         /// A pointer to the opaque Rust object.
2548
2549         /// Nearly everywhere, inner must be non-null, however in places where
2550         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2551         pub inner: *mut nativeTxAddInput,
2552         /// Indicates that this is the only struct which contains the same pointer.
2553
2554         /// Rust functions which take ownership of an object provided via an argument require
2555         /// this to be true and invalidate the object pointed to by inner.
2556         pub is_owned: bool,
2557 }
2558
2559 impl Drop for TxAddInput {
2560         fn drop(&mut self) {
2561                 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
2562                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2563                 }
2564         }
2565 }
2566 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
2567 #[no_mangle]
2568 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
2569 #[allow(unused)]
2570 /// Used only if an object of this type is returned as a trait impl by a method
2571 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
2572         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
2573 }
2574 #[allow(unused)]
2575 impl TxAddInput {
2576         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
2577                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2578         }
2579         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
2580                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2581         }
2582         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2583         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
2584                 assert!(self.is_owned);
2585                 let ret = ObjOps::untweak_ptr(self.inner);
2586                 self.inner = core::ptr::null_mut();
2587                 ret
2588         }
2589 }
2590 /// The channel ID
2591 #[no_mangle]
2592 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] {
2593         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2594         inner_val
2595 }
2596 /// The channel ID
2597 #[no_mangle]
2598 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) {
2599         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2600 }
2601 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2602 /// non-initiators.
2603 #[no_mangle]
2604 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
2605         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2606         *inner_val
2607 }
2608 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2609 /// non-initiators.
2610 #[no_mangle]
2611 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
2612         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2613 }
2614 /// Serialized transaction that contains the output this input spends to verify that it is non
2615 /// malleable.
2616 #[no_mangle]
2617 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
2618         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
2619         crate::lightning::util::ser::TransactionU16LenLimited { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::ser::TransactionU16LenLimited<>) as *mut _) }, is_owned: false }
2620 }
2621 /// Serialized transaction that contains the output this input spends to verify that it is non
2622 /// malleable.
2623 #[no_mangle]
2624 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
2625         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
2626 }
2627 /// The index of the output being spent
2628 #[no_mangle]
2629 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
2630         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
2631         *inner_val
2632 }
2633 /// The index of the output being spent
2634 #[no_mangle]
2635 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
2636         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
2637 }
2638 /// The sequence number of this input
2639 #[no_mangle]
2640 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
2641         let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
2642         *inner_val
2643 }
2644 /// The sequence number of this input
2645 #[no_mangle]
2646 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
2647         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
2648 }
2649 /// Constructs a new TxAddInput given each field
2650 #[must_use]
2651 #[no_mangle]
2652 pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput {
2653         TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
2654                 channel_id: channel_id_arg.data,
2655                 serial_id: serial_id_arg,
2656                 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
2657                 prevtx_out: prevtx_out_arg,
2658                 sequence: sequence_arg,
2659         }), is_owned: true }
2660 }
2661 impl Clone for TxAddInput {
2662         fn clone(&self) -> Self {
2663                 Self {
2664                         inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2665                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2666                         is_owned: true,
2667                 }
2668         }
2669 }
2670 #[allow(unused)]
2671 /// Used only if an object of this type is returned as a trait impl by a method
2672 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2673         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddInput)).clone() })) as *mut c_void
2674 }
2675 #[no_mangle]
2676 /// Creates a copy of the TxAddInput
2677 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
2678         orig.clone()
2679 }
2680 /// Checks if two TxAddInputs contain equal inner contents.
2681 /// This ignores pointers and is_owned flags and looks at the values in fields.
2682 /// Two objects with NULL inner values will be considered "equal" here.
2683 #[no_mangle]
2684 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
2685         if a.inner == b.inner { return true; }
2686         if a.inner.is_null() || b.inner.is_null() { return false; }
2687         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2688 }
2689
2690 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
2691 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
2692
2693 /// A tx_add_output message for adding an output during interactive transaction construction.
2694 ///
2695 #[must_use]
2696 #[repr(C)]
2697 pub struct TxAddOutput {
2698         /// A pointer to the opaque Rust object.
2699
2700         /// Nearly everywhere, inner must be non-null, however in places where
2701         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2702         pub inner: *mut nativeTxAddOutput,
2703         /// Indicates that this is the only struct which contains the same pointer.
2704
2705         /// Rust functions which take ownership of an object provided via an argument require
2706         /// this to be true and invalidate the object pointed to by inner.
2707         pub is_owned: bool,
2708 }
2709
2710 impl Drop for TxAddOutput {
2711         fn drop(&mut self) {
2712                 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
2713                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2714                 }
2715         }
2716 }
2717 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
2718 #[no_mangle]
2719 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
2720 #[allow(unused)]
2721 /// Used only if an object of this type is returned as a trait impl by a method
2722 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
2723         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
2724 }
2725 #[allow(unused)]
2726 impl TxAddOutput {
2727         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
2728                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2729         }
2730         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
2731                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2732         }
2733         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2734         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
2735                 assert!(self.is_owned);
2736                 let ret = ObjOps::untweak_ptr(self.inner);
2737                 self.inner = core::ptr::null_mut();
2738                 ret
2739         }
2740 }
2741 /// The channel ID
2742 #[no_mangle]
2743 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] {
2744         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2745         inner_val
2746 }
2747 /// The channel ID
2748 #[no_mangle]
2749 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) {
2750         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2751 }
2752 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2753 /// non-initiators.
2754 #[no_mangle]
2755 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
2756         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2757         *inner_val
2758 }
2759 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2760 /// non-initiators.
2761 #[no_mangle]
2762 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
2763         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2764 }
2765 /// The satoshi value of the output
2766 #[no_mangle]
2767 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
2768         let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
2769         *inner_val
2770 }
2771 /// The satoshi value of the output
2772 #[no_mangle]
2773 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
2774         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
2775 }
2776 /// The scriptPubKey for the output
2777 #[no_mangle]
2778 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::u8slice {
2779         let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
2780         crate::c_types::u8slice::from_slice(&inner_val[..])
2781 }
2782 /// The scriptPubKey for the output
2783 #[no_mangle]
2784 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
2785         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::Script::from(val.into_rust());
2786 }
2787 /// Constructs a new TxAddOutput given each field
2788 #[must_use]
2789 #[no_mangle]
2790 pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput {
2791         TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
2792                 channel_id: channel_id_arg.data,
2793                 serial_id: serial_id_arg,
2794                 sats: sats_arg,
2795                 script: ::bitcoin::blockdata::script::Script::from(script_arg.into_rust()),
2796         }), is_owned: true }
2797 }
2798 impl Clone for TxAddOutput {
2799         fn clone(&self) -> Self {
2800                 Self {
2801                         inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
2802                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2803                         is_owned: true,
2804                 }
2805         }
2806 }
2807 #[allow(unused)]
2808 /// Used only if an object of this type is returned as a trait impl by a method
2809 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2810         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddOutput)).clone() })) as *mut c_void
2811 }
2812 #[no_mangle]
2813 /// Creates a copy of the TxAddOutput
2814 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
2815         orig.clone()
2816 }
2817 /// Checks if two TxAddOutputs contain equal inner contents.
2818 /// This ignores pointers and is_owned flags and looks at the values in fields.
2819 /// Two objects with NULL inner values will be considered "equal" here.
2820 #[no_mangle]
2821 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
2822         if a.inner == b.inner { return true; }
2823         if a.inner.is_null() || b.inner.is_null() { return false; }
2824         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2825 }
2826
2827 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
2828 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
2829
2830 /// A tx_remove_input message for removing an input during interactive transaction construction.
2831 ///
2832 #[must_use]
2833 #[repr(C)]
2834 pub struct TxRemoveInput {
2835         /// A pointer to the opaque Rust object.
2836
2837         /// Nearly everywhere, inner must be non-null, however in places where
2838         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2839         pub inner: *mut nativeTxRemoveInput,
2840         /// Indicates that this is the only struct which contains the same pointer.
2841
2842         /// Rust functions which take ownership of an object provided via an argument require
2843         /// this to be true and invalidate the object pointed to by inner.
2844         pub is_owned: bool,
2845 }
2846
2847 impl Drop for TxRemoveInput {
2848         fn drop(&mut self) {
2849                 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
2850                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2851                 }
2852         }
2853 }
2854 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
2855 #[no_mangle]
2856 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
2857 #[allow(unused)]
2858 /// Used only if an object of this type is returned as a trait impl by a method
2859 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
2860         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
2861 }
2862 #[allow(unused)]
2863 impl TxRemoveInput {
2864         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
2865                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2866         }
2867         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
2868                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2869         }
2870         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2871         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
2872                 assert!(self.is_owned);
2873                 let ret = ObjOps::untweak_ptr(self.inner);
2874                 self.inner = core::ptr::null_mut();
2875                 ret
2876         }
2877 }
2878 /// The channel ID
2879 #[no_mangle]
2880 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] {
2881         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2882         inner_val
2883 }
2884 /// The channel ID
2885 #[no_mangle]
2886 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) {
2887         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2888 }
2889 /// The serial ID of the input to be removed
2890 #[no_mangle]
2891 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
2892         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2893         *inner_val
2894 }
2895 /// The serial ID of the input to be removed
2896 #[no_mangle]
2897 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
2898         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2899 }
2900 /// Constructs a new TxRemoveInput given each field
2901 #[must_use]
2902 #[no_mangle]
2903 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput {
2904         TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
2905                 channel_id: channel_id_arg.data,
2906                 serial_id: serial_id_arg,
2907         }), is_owned: true }
2908 }
2909 impl Clone for TxRemoveInput {
2910         fn clone(&self) -> Self {
2911                 Self {
2912                         inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2913                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2914                         is_owned: true,
2915                 }
2916         }
2917 }
2918 #[allow(unused)]
2919 /// Used only if an object of this type is returned as a trait impl by a method
2920 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2921         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveInput)).clone() })) as *mut c_void
2922 }
2923 #[no_mangle]
2924 /// Creates a copy of the TxRemoveInput
2925 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
2926         orig.clone()
2927 }
2928 /// Checks if two TxRemoveInputs contain equal inner contents.
2929 /// This ignores pointers and is_owned flags and looks at the values in fields.
2930 /// Two objects with NULL inner values will be considered "equal" here.
2931 #[no_mangle]
2932 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
2933         if a.inner == b.inner { return true; }
2934         if a.inner.is_null() || b.inner.is_null() { return false; }
2935         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2936 }
2937
2938 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
2939 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
2940
2941 /// A tx_remove_output message for removing an output during interactive transaction construction.
2942 ///
2943 #[must_use]
2944 #[repr(C)]
2945 pub struct TxRemoveOutput {
2946         /// A pointer to the opaque Rust object.
2947
2948         /// Nearly everywhere, inner must be non-null, however in places where
2949         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2950         pub inner: *mut nativeTxRemoveOutput,
2951         /// Indicates that this is the only struct which contains the same pointer.
2952
2953         /// Rust functions which take ownership of an object provided via an argument require
2954         /// this to be true and invalidate the object pointed to by inner.
2955         pub is_owned: bool,
2956 }
2957
2958 impl Drop for TxRemoveOutput {
2959         fn drop(&mut self) {
2960                 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
2961                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2962                 }
2963         }
2964 }
2965 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
2966 #[no_mangle]
2967 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
2968 #[allow(unused)]
2969 /// Used only if an object of this type is returned as a trait impl by a method
2970 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
2971         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
2972 }
2973 #[allow(unused)]
2974 impl TxRemoveOutput {
2975         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
2976                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2977         }
2978         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
2979                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2980         }
2981         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2982         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
2983                 assert!(self.is_owned);
2984                 let ret = ObjOps::untweak_ptr(self.inner);
2985                 self.inner = core::ptr::null_mut();
2986                 ret
2987         }
2988 }
2989 /// The channel ID
2990 #[no_mangle]
2991 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] {
2992         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2993         inner_val
2994 }
2995 /// The channel ID
2996 #[no_mangle]
2997 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) {
2998         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2999 }
3000 /// The serial ID of the output to be removed
3001 #[no_mangle]
3002 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3003         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3004         *inner_val
3005 }
3006 /// The serial ID of the output to be removed
3007 #[no_mangle]
3008 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3009         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3010 }
3011 /// Constructs a new TxRemoveOutput given each field
3012 #[must_use]
3013 #[no_mangle]
3014 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput {
3015         TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3016                 channel_id: channel_id_arg.data,
3017                 serial_id: serial_id_arg,
3018         }), is_owned: true }
3019 }
3020 impl Clone for TxRemoveOutput {
3021         fn clone(&self) -> Self {
3022                 Self {
3023                         inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3024                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3025                         is_owned: true,
3026                 }
3027         }
3028 }
3029 #[allow(unused)]
3030 /// Used only if an object of this type is returned as a trait impl by a method
3031 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3032         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveOutput)).clone() })) as *mut c_void
3033 }
3034 #[no_mangle]
3035 /// Creates a copy of the TxRemoveOutput
3036 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3037         orig.clone()
3038 }
3039 /// Checks if two TxRemoveOutputs contain equal inner contents.
3040 /// This ignores pointers and is_owned flags and looks at the values in fields.
3041 /// Two objects with NULL inner values will be considered "equal" here.
3042 #[no_mangle]
3043 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3044         if a.inner == b.inner { return true; }
3045         if a.inner.is_null() || b.inner.is_null() { return false; }
3046         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3047 }
3048
3049 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3050 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3051
3052 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3053 /// interactive transaction construction.
3054 ///
3055 #[must_use]
3056 #[repr(C)]
3057 pub struct TxComplete {
3058         /// A pointer to the opaque Rust object.
3059
3060         /// Nearly everywhere, inner must be non-null, however in places where
3061         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3062         pub inner: *mut nativeTxComplete,
3063         /// Indicates that this is the only struct which contains the same pointer.
3064
3065         /// Rust functions which take ownership of an object provided via an argument require
3066         /// this to be true and invalidate the object pointed to by inner.
3067         pub is_owned: bool,
3068 }
3069
3070 impl Drop for TxComplete {
3071         fn drop(&mut self) {
3072                 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3073                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3074                 }
3075         }
3076 }
3077 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3078 #[no_mangle]
3079 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3080 #[allow(unused)]
3081 /// Used only if an object of this type is returned as a trait impl by a method
3082 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3083         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3084 }
3085 #[allow(unused)]
3086 impl TxComplete {
3087         pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3088                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3089         }
3090         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3091                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3092         }
3093         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3094         pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3095                 assert!(self.is_owned);
3096                 let ret = ObjOps::untweak_ptr(self.inner);
3097                 self.inner = core::ptr::null_mut();
3098                 ret
3099         }
3100 }
3101 /// The channel ID
3102 #[no_mangle]
3103 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] {
3104         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3105         inner_val
3106 }
3107 /// The channel ID
3108 #[no_mangle]
3109 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) {
3110         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3111 }
3112 /// Constructs a new TxComplete given each field
3113 #[must_use]
3114 #[no_mangle]
3115 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete {
3116         TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3117                 channel_id: channel_id_arg.data,
3118         }), is_owned: true }
3119 }
3120 impl Clone for TxComplete {
3121         fn clone(&self) -> Self {
3122                 Self {
3123                         inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3124                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3125                         is_owned: true,
3126                 }
3127         }
3128 }
3129 #[allow(unused)]
3130 /// Used only if an object of this type is returned as a trait impl by a method
3131 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3132         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxComplete)).clone() })) as *mut c_void
3133 }
3134 #[no_mangle]
3135 /// Creates a copy of the TxComplete
3136 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3137         orig.clone()
3138 }
3139 /// Checks if two TxCompletes contain equal inner contents.
3140 /// This ignores pointers and is_owned flags and looks at the values in fields.
3141 /// Two objects with NULL inner values will be considered "equal" here.
3142 #[no_mangle]
3143 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3144         if a.inner == b.inner { return true; }
3145         if a.inner.is_null() || b.inner.is_null() { return false; }
3146         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3147 }
3148
3149 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3150 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3151
3152 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3153 /// interactive transaction construction.
3154 ///
3155 #[must_use]
3156 #[repr(C)]
3157 pub struct TxSignatures {
3158         /// A pointer to the opaque Rust object.
3159
3160         /// Nearly everywhere, inner must be non-null, however in places where
3161         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3162         pub inner: *mut nativeTxSignatures,
3163         /// Indicates that this is the only struct which contains the same pointer.
3164
3165         /// Rust functions which take ownership of an object provided via an argument require
3166         /// this to be true and invalidate the object pointed to by inner.
3167         pub is_owned: bool,
3168 }
3169
3170 impl Drop for TxSignatures {
3171         fn drop(&mut self) {
3172                 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3173                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3174                 }
3175         }
3176 }
3177 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3178 #[no_mangle]
3179 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3180 #[allow(unused)]
3181 /// Used only if an object of this type is returned as a trait impl by a method
3182 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3183         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3184 }
3185 #[allow(unused)]
3186 impl TxSignatures {
3187         pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3188                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3189         }
3190         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3191                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3192         }
3193         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3194         pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3195                 assert!(self.is_owned);
3196                 let ret = ObjOps::untweak_ptr(self.inner);
3197                 self.inner = core::ptr::null_mut();
3198                 ret
3199         }
3200 }
3201 /// The channel ID
3202 #[no_mangle]
3203 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] {
3204         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3205         inner_val
3206 }
3207 /// The channel ID
3208 #[no_mangle]
3209 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3210         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3211 }
3212 /// The TXID
3213 #[no_mangle]
3214 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3215         let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3216         inner_val.as_inner()
3217 }
3218 /// The TXID
3219 #[no_mangle]
3220 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3221         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3222 }
3223 /// The list of witnesses
3224 ///
3225 /// Returns a copy of the field.
3226 #[no_mangle]
3227 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3228         let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
3229         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Witness::from_bitcoin(&item) }); };
3230         local_inner_val.into()
3231 }
3232 /// The list of witnesses
3233 #[no_mangle]
3234 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
3235         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
3236         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
3237 }
3238 /// Constructs a new TxSignatures given each field
3239 #[must_use]
3240 #[no_mangle]
3241 pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ) -> TxSignatures {
3242         let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
3243         TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
3244                 channel_id: channel_id_arg.data,
3245                 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
3246                 witnesses: local_witnesses_arg,
3247         }), is_owned: true }
3248 }
3249 impl Clone for TxSignatures {
3250         fn clone(&self) -> Self {
3251                 Self {
3252                         inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3253                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3254                         is_owned: true,
3255                 }
3256         }
3257 }
3258 #[allow(unused)]
3259 /// Used only if an object of this type is returned as a trait impl by a method
3260 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3261         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxSignatures)).clone() })) as *mut c_void
3262 }
3263 #[no_mangle]
3264 /// Creates a copy of the TxSignatures
3265 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
3266         orig.clone()
3267 }
3268 /// Checks if two TxSignaturess contain equal inner contents.
3269 /// This ignores pointers and is_owned flags and looks at the values in fields.
3270 /// Two objects with NULL inner values will be considered "equal" here.
3271 #[no_mangle]
3272 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
3273         if a.inner == b.inner { return true; }
3274         if a.inner.is_null() || b.inner.is_null() { return false; }
3275         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3276 }
3277
3278 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
3279 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
3280
3281 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
3282 /// completed.
3283 ///
3284 #[must_use]
3285 #[repr(C)]
3286 pub struct TxInitRbf {
3287         /// A pointer to the opaque Rust object.
3288
3289         /// Nearly everywhere, inner must be non-null, however in places where
3290         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3291         pub inner: *mut nativeTxInitRbf,
3292         /// Indicates that this is the only struct which contains the same pointer.
3293
3294         /// Rust functions which take ownership of an object provided via an argument require
3295         /// this to be true and invalidate the object pointed to by inner.
3296         pub is_owned: bool,
3297 }
3298
3299 impl Drop for TxInitRbf {
3300         fn drop(&mut self) {
3301                 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
3302                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3303                 }
3304         }
3305 }
3306 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
3307 #[no_mangle]
3308 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
3309 #[allow(unused)]
3310 /// Used only if an object of this type is returned as a trait impl by a method
3311 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
3312         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
3313 }
3314 #[allow(unused)]
3315 impl TxInitRbf {
3316         pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
3317                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3318         }
3319         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
3320                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3321         }
3322         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3323         pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
3324                 assert!(self.is_owned);
3325                 let ret = ObjOps::untweak_ptr(self.inner);
3326                 self.inner = core::ptr::null_mut();
3327                 ret
3328         }
3329 }
3330 /// The channel ID
3331 #[no_mangle]
3332 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] {
3333         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3334         inner_val
3335 }
3336 /// The channel ID
3337 #[no_mangle]
3338 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3339         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3340 }
3341 /// The locktime of the transaction
3342 #[no_mangle]
3343 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
3344         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
3345         *inner_val
3346 }
3347 /// The locktime of the transaction
3348 #[no_mangle]
3349 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
3350         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
3351 }
3352 /// The feerate of the transaction
3353 #[no_mangle]
3354 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
3355         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
3356         *inner_val
3357 }
3358 /// The feerate of the transaction
3359 #[no_mangle]
3360 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
3361         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
3362 }
3363 /// The number of satoshis the sender will contribute to or, if negative, remove from
3364 /// (e.g. splice-out) the funding output of the transaction
3365 #[no_mangle]
3366 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
3367         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3368         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) };
3369         local_inner_val
3370 }
3371 /// The number of satoshis the sender will contribute to or, if negative, remove from
3372 /// (e.g. splice-out) the funding output of the transaction
3373 #[no_mangle]
3374 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
3375         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3376         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3377 }
3378 /// Constructs a new TxInitRbf given each field
3379 #[must_use]
3380 #[no_mangle]
3381 pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf {
3382         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3383         TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
3384                 channel_id: channel_id_arg.data,
3385                 locktime: locktime_arg,
3386                 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
3387                 funding_output_contribution: local_funding_output_contribution_arg,
3388         }), is_owned: true }
3389 }
3390 impl Clone for TxInitRbf {
3391         fn clone(&self) -> Self {
3392                 Self {
3393                         inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3394                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3395                         is_owned: true,
3396                 }
3397         }
3398 }
3399 #[allow(unused)]
3400 /// Used only if an object of this type is returned as a trait impl by a method
3401 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3402         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxInitRbf)).clone() })) as *mut c_void
3403 }
3404 #[no_mangle]
3405 /// Creates a copy of the TxInitRbf
3406 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
3407         orig.clone()
3408 }
3409 /// Checks if two TxInitRbfs contain equal inner contents.
3410 /// This ignores pointers and is_owned flags and looks at the values in fields.
3411 /// Two objects with NULL inner values will be considered "equal" here.
3412 #[no_mangle]
3413 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
3414         if a.inner == b.inner { return true; }
3415         if a.inner.is_null() || b.inner.is_null() { return false; }
3416         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3417 }
3418
3419 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
3420 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
3421
3422 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
3423 /// completed.
3424 ///
3425 #[must_use]
3426 #[repr(C)]
3427 pub struct TxAckRbf {
3428         /// A pointer to the opaque Rust object.
3429
3430         /// Nearly everywhere, inner must be non-null, however in places where
3431         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3432         pub inner: *mut nativeTxAckRbf,
3433         /// Indicates that this is the only struct which contains the same pointer.
3434
3435         /// Rust functions which take ownership of an object provided via an argument require
3436         /// this to be true and invalidate the object pointed to by inner.
3437         pub is_owned: bool,
3438 }
3439
3440 impl Drop for TxAckRbf {
3441         fn drop(&mut self) {
3442                 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
3443                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3444                 }
3445         }
3446 }
3447 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
3448 #[no_mangle]
3449 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
3450 #[allow(unused)]
3451 /// Used only if an object of this type is returned as a trait impl by a method
3452 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
3453         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
3454 }
3455 #[allow(unused)]
3456 impl TxAckRbf {
3457         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
3458                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3459         }
3460         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
3461                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3462         }
3463         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3464         pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
3465                 assert!(self.is_owned);
3466                 let ret = ObjOps::untweak_ptr(self.inner);
3467                 self.inner = core::ptr::null_mut();
3468                 ret
3469         }
3470 }
3471 /// The channel ID
3472 #[no_mangle]
3473 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] {
3474         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3475         inner_val
3476 }
3477 /// The channel ID
3478 #[no_mangle]
3479 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3480         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3481 }
3482 /// The number of satoshis the sender will contribute to or, if negative, remove from
3483 /// (e.g. splice-out) the funding output of the transaction
3484 #[no_mangle]
3485 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
3486         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3487         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) };
3488         local_inner_val
3489 }
3490 /// The number of satoshis the sender will contribute to or, if negative, remove from
3491 /// (e.g. splice-out) the funding output of the transaction
3492 #[no_mangle]
3493 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
3494         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3495         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3496 }
3497 /// Constructs a new TxAckRbf given each field
3498 #[must_use]
3499 #[no_mangle]
3500 pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf {
3501         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3502         TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
3503                 channel_id: channel_id_arg.data,
3504                 funding_output_contribution: local_funding_output_contribution_arg,
3505         }), is_owned: true }
3506 }
3507 impl Clone for TxAckRbf {
3508         fn clone(&self) -> Self {
3509                 Self {
3510                         inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3511                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3512                         is_owned: true,
3513                 }
3514         }
3515 }
3516 #[allow(unused)]
3517 /// Used only if an object of this type is returned as a trait impl by a method
3518 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3519         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAckRbf)).clone() })) as *mut c_void
3520 }
3521 #[no_mangle]
3522 /// Creates a copy of the TxAckRbf
3523 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
3524         orig.clone()
3525 }
3526 /// Checks if two TxAckRbfs contain equal inner contents.
3527 /// This ignores pointers and is_owned flags and looks at the values in fields.
3528 /// Two objects with NULL inner values will be considered "equal" here.
3529 #[no_mangle]
3530 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
3531         if a.inner == b.inner { return true; }
3532         if a.inner.is_null() || b.inner.is_null() { return false; }
3533         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3534 }
3535
3536 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
3537 pub(crate) type nativeTxAbort = nativeTxAbortImport;
3538
3539 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
3540 ///
3541 #[must_use]
3542 #[repr(C)]
3543 pub struct TxAbort {
3544         /// A pointer to the opaque Rust object.
3545
3546         /// Nearly everywhere, inner must be non-null, however in places where
3547         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3548         pub inner: *mut nativeTxAbort,
3549         /// Indicates that this is the only struct which contains the same pointer.
3550
3551         /// Rust functions which take ownership of an object provided via an argument require
3552         /// this to be true and invalidate the object pointed to by inner.
3553         pub is_owned: bool,
3554 }
3555
3556 impl Drop for TxAbort {
3557         fn drop(&mut self) {
3558                 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
3559                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3560                 }
3561         }
3562 }
3563 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
3564 #[no_mangle]
3565 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
3566 #[allow(unused)]
3567 /// Used only if an object of this type is returned as a trait impl by a method
3568 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
3569         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
3570 }
3571 #[allow(unused)]
3572 impl TxAbort {
3573         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
3574                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3575         }
3576         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
3577                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3578         }
3579         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3580         pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
3581                 assert!(self.is_owned);
3582                 let ret = ObjOps::untweak_ptr(self.inner);
3583                 self.inner = core::ptr::null_mut();
3584                 ret
3585         }
3586 }
3587 /// The channel ID
3588 #[no_mangle]
3589 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] {
3590         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3591         inner_val
3592 }
3593 /// The channel ID
3594 #[no_mangle]
3595 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) {
3596         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3597 }
3598 /// Message data
3599 ///
3600 /// Returns a copy of the field.
3601 #[no_mangle]
3602 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
3603         let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
3604         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
3605         local_inner_val.into()
3606 }
3607 /// Message data
3608 #[no_mangle]
3609 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
3610         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3611         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
3612 }
3613 /// Constructs a new TxAbort given each field
3614 #[must_use]
3615 #[no_mangle]
3616 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
3617         let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
3618         TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
3619                 channel_id: channel_id_arg.data,
3620                 data: local_data_arg,
3621         }), is_owned: true }
3622 }
3623 impl Clone for TxAbort {
3624         fn clone(&self) -> Self {
3625                 Self {
3626                         inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
3627                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3628                         is_owned: true,
3629                 }
3630         }
3631 }
3632 #[allow(unused)]
3633 /// Used only if an object of this type is returned as a trait impl by a method
3634 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
3635         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAbort)).clone() })) as *mut c_void
3636 }
3637 #[no_mangle]
3638 /// Creates a copy of the TxAbort
3639 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
3640         orig.clone()
3641 }
3642 /// Checks if two TxAborts contain equal inner contents.
3643 /// This ignores pointers and is_owned flags and looks at the values in fields.
3644 /// Two objects with NULL inner values will be considered "equal" here.
3645 #[no_mangle]
3646 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
3647         if a.inner == b.inner { return true; }
3648         if a.inner.is_null() || b.inner.is_null() { return false; }
3649         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3650 }
3651
3652 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
3653 pub(crate) type nativeShutdown = nativeShutdownImport;
3654
3655 /// A [`shutdown`] message to be sent to or received from a peer.
3656 ///
3657 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
3658 #[must_use]
3659 #[repr(C)]
3660 pub struct Shutdown {
3661         /// A pointer to the opaque Rust object.
3662
3663         /// Nearly everywhere, inner must be non-null, however in places where
3664         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3665         pub inner: *mut nativeShutdown,
3666         /// Indicates that this is the only struct which contains the same pointer.
3667
3668         /// Rust functions which take ownership of an object provided via an argument require
3669         /// this to be true and invalidate the object pointed to by inner.
3670         pub is_owned: bool,
3671 }
3672
3673 impl Drop for Shutdown {
3674         fn drop(&mut self) {
3675                 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
3676                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3677                 }
3678         }
3679 }
3680 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
3681 #[no_mangle]
3682 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
3683 #[allow(unused)]
3684 /// Used only if an object of this type is returned as a trait impl by a method
3685 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
3686         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
3687 }
3688 #[allow(unused)]
3689 impl Shutdown {
3690         pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
3691                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3692         }
3693         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
3694                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3695         }
3696         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3697         pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
3698                 assert!(self.is_owned);
3699                 let ret = ObjOps::untweak_ptr(self.inner);
3700                 self.inner = core::ptr::null_mut();
3701                 ret
3702         }
3703 }
3704 /// The channel ID
3705 #[no_mangle]
3706 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
3707         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3708         inner_val
3709 }
3710 /// The channel ID
3711 #[no_mangle]
3712 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
3713         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3714 }
3715 /// The destination of this peer's funds on closing.
3716 ///
3717 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3718 #[no_mangle]
3719 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
3720         let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
3721         crate::c_types::u8slice::from_slice(&inner_val[..])
3722 }
3723 /// The destination of this peer's funds on closing.
3724 ///
3725 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3726 #[no_mangle]
3727 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
3728         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
3729 }
3730 /// Constructs a new Shutdown given each field
3731 #[must_use]
3732 #[no_mangle]
3733 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
3734         Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
3735                 channel_id: channel_id_arg.data,
3736                 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
3737         }), is_owned: true }
3738 }
3739 impl Clone for Shutdown {
3740         fn clone(&self) -> Self {
3741                 Self {
3742                         inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
3743                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3744                         is_owned: true,
3745                 }
3746         }
3747 }
3748 #[allow(unused)]
3749 /// Used only if an object of this type is returned as a trait impl by a method
3750 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
3751         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
3752 }
3753 #[no_mangle]
3754 /// Creates a copy of the Shutdown
3755 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
3756         orig.clone()
3757 }
3758 /// Checks if two Shutdowns contain equal inner contents.
3759 /// This ignores pointers and is_owned flags and looks at the values in fields.
3760 /// Two objects with NULL inner values will be considered "equal" here.
3761 #[no_mangle]
3762 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
3763         if a.inner == b.inner { return true; }
3764         if a.inner.is_null() || b.inner.is_null() { return false; }
3765         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3766 }
3767
3768 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
3769 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
3770
3771 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
3772 ///
3773 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
3774 /// to use.
3775 #[must_use]
3776 #[repr(C)]
3777 pub struct ClosingSignedFeeRange {
3778         /// A pointer to the opaque Rust object.
3779
3780         /// Nearly everywhere, inner must be non-null, however in places where
3781         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3782         pub inner: *mut nativeClosingSignedFeeRange,
3783         /// Indicates that this is the only struct which contains the same pointer.
3784
3785         /// Rust functions which take ownership of an object provided via an argument require
3786         /// this to be true and invalidate the object pointed to by inner.
3787         pub is_owned: bool,
3788 }
3789
3790 impl Drop for ClosingSignedFeeRange {
3791         fn drop(&mut self) {
3792                 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
3793                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3794                 }
3795         }
3796 }
3797 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
3798 #[no_mangle]
3799 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
3800 #[allow(unused)]
3801 /// Used only if an object of this type is returned as a trait impl by a method
3802 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
3803         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
3804 }
3805 #[allow(unused)]
3806 impl ClosingSignedFeeRange {
3807         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
3808                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3809         }
3810         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
3811                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3812         }
3813         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3814         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
3815                 assert!(self.is_owned);
3816                 let ret = ObjOps::untweak_ptr(self.inner);
3817                 self.inner = core::ptr::null_mut();
3818                 ret
3819         }
3820 }
3821 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3822 /// transaction.
3823 #[no_mangle]
3824 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3825         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
3826         *inner_val
3827 }
3828 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3829 /// transaction.
3830 #[no_mangle]
3831 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3832         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
3833 }
3834 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3835 /// transaction.
3836 #[no_mangle]
3837 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3838         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
3839         *inner_val
3840 }
3841 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3842 /// transaction.
3843 #[no_mangle]
3844 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3845         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
3846 }
3847 /// Constructs a new ClosingSignedFeeRange given each field
3848 #[must_use]
3849 #[no_mangle]
3850 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
3851         ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
3852                 min_fee_satoshis: min_fee_satoshis_arg,
3853                 max_fee_satoshis: max_fee_satoshis_arg,
3854         }), is_owned: true }
3855 }
3856 impl Clone for ClosingSignedFeeRange {
3857         fn clone(&self) -> Self {
3858                 Self {
3859                         inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
3860                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3861                         is_owned: true,
3862                 }
3863         }
3864 }
3865 #[allow(unused)]
3866 /// Used only if an object of this type is returned as a trait impl by a method
3867 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3868         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
3869 }
3870 #[no_mangle]
3871 /// Creates a copy of the ClosingSignedFeeRange
3872 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
3873         orig.clone()
3874 }
3875 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
3876 /// This ignores pointers and is_owned flags and looks at the values in fields.
3877 /// Two objects with NULL inner values will be considered "equal" here.
3878 #[no_mangle]
3879 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
3880         if a.inner == b.inner { return true; }
3881         if a.inner.is_null() || b.inner.is_null() { return false; }
3882         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3883 }
3884
3885 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
3886 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
3887
3888 /// A [`closing_signed`] message to be sent to or received from a peer.
3889 ///
3890 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
3891 #[must_use]
3892 #[repr(C)]
3893 pub struct ClosingSigned {
3894         /// A pointer to the opaque Rust object.
3895
3896         /// Nearly everywhere, inner must be non-null, however in places where
3897         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3898         pub inner: *mut nativeClosingSigned,
3899         /// Indicates that this is the only struct which contains the same pointer.
3900
3901         /// Rust functions which take ownership of an object provided via an argument require
3902         /// this to be true and invalidate the object pointed to by inner.
3903         pub is_owned: bool,
3904 }
3905
3906 impl Drop for ClosingSigned {
3907         fn drop(&mut self) {
3908                 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
3909                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3910                 }
3911         }
3912 }
3913 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
3914 #[no_mangle]
3915 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
3916 #[allow(unused)]
3917 /// Used only if an object of this type is returned as a trait impl by a method
3918 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
3919         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
3920 }
3921 #[allow(unused)]
3922 impl ClosingSigned {
3923         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
3924                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3925         }
3926         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
3927                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3928         }
3929         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3930         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
3931                 assert!(self.is_owned);
3932                 let ret = ObjOps::untweak_ptr(self.inner);
3933                 self.inner = core::ptr::null_mut();
3934                 ret
3935         }
3936 }
3937 /// The channel ID
3938 #[no_mangle]
3939 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
3940         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3941         inner_val
3942 }
3943 /// The channel ID
3944 #[no_mangle]
3945 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
3946         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3947 }
3948 /// The proposed total fee for the closing transaction
3949 #[no_mangle]
3950 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
3951         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
3952         *inner_val
3953 }
3954 /// The proposed total fee for the closing transaction
3955 #[no_mangle]
3956 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
3957         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
3958 }
3959 /// A signature on the closing transaction
3960 #[no_mangle]
3961 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
3962         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3963         crate::c_types::Signature::from_rust(&inner_val)
3964 }
3965 /// A signature on the closing transaction
3966 #[no_mangle]
3967 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
3968         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3969 }
3970 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
3971 /// nodes.
3972 ///
3973 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
3974 #[no_mangle]
3975 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
3976         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
3977         let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ClosingSignedFeeRange<>) as *mut _ }, is_owned: false };
3978         local_inner_val
3979 }
3980 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
3981 /// nodes.
3982 ///
3983 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
3984 #[no_mangle]
3985 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
3986         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
3987         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
3988 }
3989 /// Constructs a new ClosingSigned given each field
3990 #[must_use]
3991 #[no_mangle]
3992 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, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
3993         let mut local_fee_range_arg = if fee_range_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(fee_range_arg.take_inner()) } }) };
3994         ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
3995                 channel_id: channel_id_arg.data,
3996                 fee_satoshis: fee_satoshis_arg,
3997                 signature: signature_arg.into_rust(),
3998                 fee_range: local_fee_range_arg,
3999         }), is_owned: true }
4000 }
4001 impl Clone for ClosingSigned {
4002         fn clone(&self) -> Self {
4003                 Self {
4004                         inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4005                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4006                         is_owned: true,
4007                 }
4008         }
4009 }
4010 #[allow(unused)]
4011 /// Used only if an object of this type is returned as a trait impl by a method
4012 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4013         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
4014 }
4015 #[no_mangle]
4016 /// Creates a copy of the ClosingSigned
4017 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4018         orig.clone()
4019 }
4020 /// Checks if two ClosingSigneds contain equal inner contents.
4021 /// This ignores pointers and is_owned flags and looks at the values in fields.
4022 /// Two objects with NULL inner values will be considered "equal" here.
4023 #[no_mangle]
4024 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4025         if a.inner == b.inner { return true; }
4026         if a.inner.is_null() || b.inner.is_null() { return false; }
4027         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4028 }
4029
4030 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4031 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4032
4033 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4034 ///
4035 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4036 #[must_use]
4037 #[repr(C)]
4038 pub struct UpdateAddHTLC {
4039         /// A pointer to the opaque Rust object.
4040
4041         /// Nearly everywhere, inner must be non-null, however in places where
4042         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4043         pub inner: *mut nativeUpdateAddHTLC,
4044         /// Indicates that this is the only struct which contains the same pointer.
4045
4046         /// Rust functions which take ownership of an object provided via an argument require
4047         /// this to be true and invalidate the object pointed to by inner.
4048         pub is_owned: bool,
4049 }
4050
4051 impl Drop for UpdateAddHTLC {
4052         fn drop(&mut self) {
4053                 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4054                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4055                 }
4056         }
4057 }
4058 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4059 #[no_mangle]
4060 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4061 #[allow(unused)]
4062 /// Used only if an object of this type is returned as a trait impl by a method
4063 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4064         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4065 }
4066 #[allow(unused)]
4067 impl UpdateAddHTLC {
4068         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4069                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4070         }
4071         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4072                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4073         }
4074         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4075         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4076                 assert!(self.is_owned);
4077                 let ret = ObjOps::untweak_ptr(self.inner);
4078                 self.inner = core::ptr::null_mut();
4079                 ret
4080         }
4081 }
4082 /// The channel ID
4083 #[no_mangle]
4084 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4085         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4086         inner_val
4087 }
4088 /// The channel ID
4089 #[no_mangle]
4090 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4091         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4092 }
4093 /// The HTLC ID
4094 #[no_mangle]
4095 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4096         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4097         *inner_val
4098 }
4099 /// The HTLC ID
4100 #[no_mangle]
4101 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4102         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4103 }
4104 /// The HTLC value in milli-satoshi
4105 #[no_mangle]
4106 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4107         let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4108         *inner_val
4109 }
4110 /// The HTLC value in milli-satoshi
4111 #[no_mangle]
4112 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4113         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4114 }
4115 /// The payment hash, the pre-image of which controls HTLC redemption
4116 #[no_mangle]
4117 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4118         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4119         &inner_val.0
4120 }
4121 /// The payment hash, the pre-image of which controls HTLC redemption
4122 #[no_mangle]
4123 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4124         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
4125 }
4126 /// The expiry height of the HTLC
4127 #[no_mangle]
4128 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4129         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4130         *inner_val
4131 }
4132 /// The expiry height of the HTLC
4133 #[no_mangle]
4134 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4135         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
4136 }
4137 /// The extra fee skimmed by the sender of this message. See
4138 /// [`ChannelConfig::accept_underpaying_htlcs`].
4139 ///
4140 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4141 #[no_mangle]
4142 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
4143         let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
4144         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
4145         local_inner_val
4146 }
4147 /// The extra fee skimmed by the sender of this message. See
4148 /// [`ChannelConfig::accept_underpaying_htlcs`].
4149 ///
4150 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4151 #[no_mangle]
4152 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
4153         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4154         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
4155 }
4156 impl Clone for UpdateAddHTLC {
4157         fn clone(&self) -> Self {
4158                 Self {
4159                         inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4160                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4161                         is_owned: true,
4162                 }
4163         }
4164 }
4165 #[allow(unused)]
4166 /// Used only if an object of this type is returned as a trait impl by a method
4167 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4168         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
4169 }
4170 #[no_mangle]
4171 /// Creates a copy of the UpdateAddHTLC
4172 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
4173         orig.clone()
4174 }
4175 /// Checks if two UpdateAddHTLCs contain equal inner contents.
4176 /// This ignores pointers and is_owned flags and looks at the values in fields.
4177 /// Two objects with NULL inner values will be considered "equal" here.
4178 #[no_mangle]
4179 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
4180         if a.inner == b.inner { return true; }
4181         if a.inner.is_null() || b.inner.is_null() { return false; }
4182         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4183 }
4184
4185 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
4186 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
4187
4188 /// An onion message to be sent to or received from a peer.
4189 ///
4190 #[must_use]
4191 #[repr(C)]
4192 pub struct OnionMessage {
4193         /// A pointer to the opaque Rust object.
4194
4195         /// Nearly everywhere, inner must be non-null, however in places where
4196         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4197         pub inner: *mut nativeOnionMessage,
4198         /// Indicates that this is the only struct which contains the same pointer.
4199
4200         /// Rust functions which take ownership of an object provided via an argument require
4201         /// this to be true and invalidate the object pointed to by inner.
4202         pub is_owned: bool,
4203 }
4204
4205 impl Drop for OnionMessage {
4206         fn drop(&mut self) {
4207                 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
4208                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4209                 }
4210         }
4211 }
4212 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
4213 #[no_mangle]
4214 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
4215 #[allow(unused)]
4216 /// Used only if an object of this type is returned as a trait impl by a method
4217 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
4218         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
4219 }
4220 #[allow(unused)]
4221 impl OnionMessage {
4222         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
4223                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4224         }
4225         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
4226                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4227         }
4228         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4229         pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
4230                 assert!(self.is_owned);
4231                 let ret = ObjOps::untweak_ptr(self.inner);
4232                 self.inner = core::ptr::null_mut();
4233                 ret
4234         }
4235 }
4236 /// Used in decrypting the onion packet's payload.
4237 #[no_mangle]
4238 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
4239         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
4240         crate::c_types::PublicKey::from_rust(&inner_val)
4241 }
4242 /// Used in decrypting the onion packet's payload.
4243 #[no_mangle]
4244 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
4245         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
4246 }
4247 impl Clone for OnionMessage {
4248         fn clone(&self) -> Self {
4249                 Self {
4250                         inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
4251                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4252                         is_owned: true,
4253                 }
4254         }
4255 }
4256 #[allow(unused)]
4257 /// Used only if an object of this type is returned as a trait impl by a method
4258 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
4259         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessage)).clone() })) as *mut c_void
4260 }
4261 #[no_mangle]
4262 /// Creates a copy of the OnionMessage
4263 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
4264         orig.clone()
4265 }
4266 /// Checks if two OnionMessages contain equal inner contents.
4267 /// This ignores pointers and is_owned flags and looks at the values in fields.
4268 /// Two objects with NULL inner values will be considered "equal" here.
4269 #[no_mangle]
4270 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
4271         if a.inner == b.inner { return true; }
4272         if a.inner.is_null() || b.inner.is_null() { return false; }
4273         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4274 }
4275
4276 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
4277 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
4278
4279 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
4280 ///
4281 /// [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
4282 #[must_use]
4283 #[repr(C)]
4284 pub struct UpdateFulfillHTLC {
4285         /// A pointer to the opaque Rust object.
4286
4287         /// Nearly everywhere, inner must be non-null, however in places where
4288         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4289         pub inner: *mut nativeUpdateFulfillHTLC,
4290         /// Indicates that this is the only struct which contains the same pointer.
4291
4292         /// Rust functions which take ownership of an object provided via an argument require
4293         /// this to be true and invalidate the object pointed to by inner.
4294         pub is_owned: bool,
4295 }
4296
4297 impl Drop for UpdateFulfillHTLC {
4298         fn drop(&mut self) {
4299                 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
4300                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4301                 }
4302         }
4303 }
4304 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
4305 #[no_mangle]
4306 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
4307 #[allow(unused)]
4308 /// Used only if an object of this type is returned as a trait impl by a method
4309 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
4310         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
4311 }
4312 #[allow(unused)]
4313 impl UpdateFulfillHTLC {
4314         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
4315                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4316         }
4317         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
4318                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4319         }
4320         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4321         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
4322                 assert!(self.is_owned);
4323                 let ret = ObjOps::untweak_ptr(self.inner);
4324                 self.inner = core::ptr::null_mut();
4325                 ret
4326         }
4327 }
4328 /// The channel ID
4329 #[no_mangle]
4330 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4331         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4332         inner_val
4333 }
4334 /// The channel ID
4335 #[no_mangle]
4336 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4337         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4338 }
4339 /// The HTLC ID
4340 #[no_mangle]
4341 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
4342         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4343         *inner_val
4344 }
4345 /// The HTLC ID
4346 #[no_mangle]
4347 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
4348         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4349 }
4350 /// The pre-image of the payment hash, allowing HTLC redemption
4351 #[no_mangle]
4352 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4353         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
4354         &inner_val.0
4355 }
4356 /// The pre-image of the payment hash, allowing HTLC redemption
4357 #[no_mangle]
4358 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4359         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
4360 }
4361 /// Constructs a new UpdateFulfillHTLC given each field
4362 #[must_use]
4363 #[no_mangle]
4364 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 {
4365         UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
4366                 channel_id: channel_id_arg.data,
4367                 htlc_id: htlc_id_arg,
4368                 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
4369         }), is_owned: true }
4370 }
4371 impl Clone for UpdateFulfillHTLC {
4372         fn clone(&self) -> Self {
4373                 Self {
4374                         inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4375                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4376                         is_owned: true,
4377                 }
4378         }
4379 }
4380 #[allow(unused)]
4381 /// Used only if an object of this type is returned as a trait impl by a method
4382 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4383         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
4384 }
4385 #[no_mangle]
4386 /// Creates a copy of the UpdateFulfillHTLC
4387 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
4388         orig.clone()
4389 }
4390 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
4391 /// This ignores pointers and is_owned flags and looks at the values in fields.
4392 /// Two objects with NULL inner values will be considered "equal" here.
4393 #[no_mangle]
4394 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
4395         if a.inner == b.inner { return true; }
4396         if a.inner.is_null() || b.inner.is_null() { return false; }
4397         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4398 }
4399
4400 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
4401 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
4402
4403 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
4404 ///
4405 /// [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
4406 #[must_use]
4407 #[repr(C)]
4408 pub struct UpdateFailHTLC {
4409         /// A pointer to the opaque Rust object.
4410
4411         /// Nearly everywhere, inner must be non-null, however in places where
4412         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4413         pub inner: *mut nativeUpdateFailHTLC,
4414         /// Indicates that this is the only struct which contains the same pointer.
4415
4416         /// Rust functions which take ownership of an object provided via an argument require
4417         /// this to be true and invalidate the object pointed to by inner.
4418         pub is_owned: bool,
4419 }
4420
4421 impl Drop for UpdateFailHTLC {
4422         fn drop(&mut self) {
4423                 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
4424                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4425                 }
4426         }
4427 }
4428 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
4429 #[no_mangle]
4430 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
4431 #[allow(unused)]
4432 /// Used only if an object of this type is returned as a trait impl by a method
4433 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
4434         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
4435 }
4436 #[allow(unused)]
4437 impl UpdateFailHTLC {
4438         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
4439                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4440         }
4441         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
4442                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4443         }
4444         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4445         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
4446                 assert!(self.is_owned);
4447                 let ret = ObjOps::untweak_ptr(self.inner);
4448                 self.inner = core::ptr::null_mut();
4449                 ret
4450         }
4451 }
4452 /// The channel ID
4453 #[no_mangle]
4454 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
4455         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4456         inner_val
4457 }
4458 /// The channel ID
4459 #[no_mangle]
4460 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4461         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4462 }
4463 /// The HTLC ID
4464 #[no_mangle]
4465 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
4466         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4467         *inner_val
4468 }
4469 /// The HTLC ID
4470 #[no_mangle]
4471 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
4472         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4473 }
4474 impl Clone for UpdateFailHTLC {
4475         fn clone(&self) -> Self {
4476                 Self {
4477                         inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4478                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4479                         is_owned: true,
4480                 }
4481         }
4482 }
4483 #[allow(unused)]
4484 /// Used only if an object of this type is returned as a trait impl by a method
4485 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4486         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
4487 }
4488 #[no_mangle]
4489 /// Creates a copy of the UpdateFailHTLC
4490 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
4491         orig.clone()
4492 }
4493 /// Checks if two UpdateFailHTLCs contain equal inner contents.
4494 /// This ignores pointers and is_owned flags and looks at the values in fields.
4495 /// Two objects with NULL inner values will be considered "equal" here.
4496 #[no_mangle]
4497 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
4498         if a.inner == b.inner { return true; }
4499         if a.inner.is_null() || b.inner.is_null() { return false; }
4500         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4501 }
4502
4503 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
4504 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
4505
4506 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
4507 ///
4508 /// [`update_fail_malformed_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
4509 #[must_use]
4510 #[repr(C)]
4511 pub struct UpdateFailMalformedHTLC {
4512         /// A pointer to the opaque Rust object.
4513
4514         /// Nearly everywhere, inner must be non-null, however in places where
4515         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4516         pub inner: *mut nativeUpdateFailMalformedHTLC,
4517         /// Indicates that this is the only struct which contains the same pointer.
4518
4519         /// Rust functions which take ownership of an object provided via an argument require
4520         /// this to be true and invalidate the object pointed to by inner.
4521         pub is_owned: bool,
4522 }
4523
4524 impl Drop for UpdateFailMalformedHTLC {
4525         fn drop(&mut self) {
4526                 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
4527                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4528                 }
4529         }
4530 }
4531 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
4532 #[no_mangle]
4533 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
4534 #[allow(unused)]
4535 /// Used only if an object of this type is returned as a trait impl by a method
4536 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
4537         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
4538 }
4539 #[allow(unused)]
4540 impl UpdateFailMalformedHTLC {
4541         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
4542                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4543         }
4544         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
4545                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4546         }
4547         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4548         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
4549                 assert!(self.is_owned);
4550                 let ret = ObjOps::untweak_ptr(self.inner);
4551                 self.inner = core::ptr::null_mut();
4552                 ret
4553         }
4554 }
4555 /// The channel ID
4556 #[no_mangle]
4557 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
4558         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4559         inner_val
4560 }
4561 /// The channel ID
4562 #[no_mangle]
4563 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4564         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4565 }
4566 /// The HTLC ID
4567 #[no_mangle]
4568 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
4569         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4570         *inner_val
4571 }
4572 /// The HTLC ID
4573 #[no_mangle]
4574 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
4575         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4576 }
4577 /// The failure code
4578 #[no_mangle]
4579 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
4580         let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
4581         *inner_val
4582 }
4583 /// The failure code
4584 #[no_mangle]
4585 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
4586         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
4587 }
4588 impl Clone for UpdateFailMalformedHTLC {
4589         fn clone(&self) -> Self {
4590                 Self {
4591                         inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4592                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4593                         is_owned: true,
4594                 }
4595         }
4596 }
4597 #[allow(unused)]
4598 /// Used only if an object of this type is returned as a trait impl by a method
4599 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4600         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
4601 }
4602 #[no_mangle]
4603 /// Creates a copy of the UpdateFailMalformedHTLC
4604 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
4605         orig.clone()
4606 }
4607 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
4608 /// This ignores pointers and is_owned flags and looks at the values in fields.
4609 /// Two objects with NULL inner values will be considered "equal" here.
4610 #[no_mangle]
4611 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
4612         if a.inner == b.inner { return true; }
4613         if a.inner.is_null() || b.inner.is_null() { return false; }
4614         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4615 }
4616
4617 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
4618 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
4619
4620 /// A [`commitment_signed`] message to be sent to or received from a peer.
4621 ///
4622 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
4623 #[must_use]
4624 #[repr(C)]
4625 pub struct CommitmentSigned {
4626         /// A pointer to the opaque Rust object.
4627
4628         /// Nearly everywhere, inner must be non-null, however in places where
4629         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4630         pub inner: *mut nativeCommitmentSigned,
4631         /// Indicates that this is the only struct which contains the same pointer.
4632
4633         /// Rust functions which take ownership of an object provided via an argument require
4634         /// this to be true and invalidate the object pointed to by inner.
4635         pub is_owned: bool,
4636 }
4637
4638 impl Drop for CommitmentSigned {
4639         fn drop(&mut self) {
4640                 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
4641                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4642                 }
4643         }
4644 }
4645 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
4646 #[no_mangle]
4647 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
4648 #[allow(unused)]
4649 /// Used only if an object of this type is returned as a trait impl by a method
4650 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
4651         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
4652 }
4653 #[allow(unused)]
4654 impl CommitmentSigned {
4655         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
4656                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4657         }
4658         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
4659                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4660         }
4661         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4662         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
4663                 assert!(self.is_owned);
4664                 let ret = ObjOps::untweak_ptr(self.inner);
4665                 self.inner = core::ptr::null_mut();
4666                 ret
4667         }
4668 }
4669 /// The channel ID
4670 #[no_mangle]
4671 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
4672         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4673         inner_val
4674 }
4675 /// The channel ID
4676 #[no_mangle]
4677 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
4678         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4679 }
4680 /// A signature on the commitment transaction
4681 #[no_mangle]
4682 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
4683         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4684         crate::c_types::Signature::from_rust(&inner_val)
4685 }
4686 /// A signature on the commitment transaction
4687 #[no_mangle]
4688 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
4689         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4690 }
4691 /// Signatures on the HTLC transactions
4692 ///
4693 /// Returns a copy of the field.
4694 #[no_mangle]
4695 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_SignatureZ {
4696         let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
4697         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Signature::from_rust(&item) }); };
4698         local_inner_val.into()
4699 }
4700 /// Signatures on the HTLC transactions
4701 #[no_mangle]
4702 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
4703         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
4704         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
4705 }
4706 /// Constructs a new CommitmentSigned given each field
4707 #[must_use]
4708 #[no_mangle]
4709 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 {
4710         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() }); };
4711         CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
4712                 channel_id: channel_id_arg.data,
4713                 signature: signature_arg.into_rust(),
4714                 htlc_signatures: local_htlc_signatures_arg,
4715         }), is_owned: true }
4716 }
4717 impl Clone for CommitmentSigned {
4718         fn clone(&self) -> Self {
4719                 Self {
4720                         inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4721                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4722                         is_owned: true,
4723                 }
4724         }
4725 }
4726 #[allow(unused)]
4727 /// Used only if an object of this type is returned as a trait impl by a method
4728 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4729         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
4730 }
4731 #[no_mangle]
4732 /// Creates a copy of the CommitmentSigned
4733 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
4734         orig.clone()
4735 }
4736 /// Checks if two CommitmentSigneds contain equal inner contents.
4737 /// This ignores pointers and is_owned flags and looks at the values in fields.
4738 /// Two objects with NULL inner values will be considered "equal" here.
4739 #[no_mangle]
4740 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
4741         if a.inner == b.inner { return true; }
4742         if a.inner.is_null() || b.inner.is_null() { return false; }
4743         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4744 }
4745
4746 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
4747 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
4748
4749 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
4750 ///
4751 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
4752 #[must_use]
4753 #[repr(C)]
4754 pub struct RevokeAndACK {
4755         /// A pointer to the opaque Rust object.
4756
4757         /// Nearly everywhere, inner must be non-null, however in places where
4758         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4759         pub inner: *mut nativeRevokeAndACK,
4760         /// Indicates that this is the only struct which contains the same pointer.
4761
4762         /// Rust functions which take ownership of an object provided via an argument require
4763         /// this to be true and invalidate the object pointed to by inner.
4764         pub is_owned: bool,
4765 }
4766
4767 impl Drop for RevokeAndACK {
4768         fn drop(&mut self) {
4769                 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
4770                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4771                 }
4772         }
4773 }
4774 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
4775 #[no_mangle]
4776 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
4777 #[allow(unused)]
4778 /// Used only if an object of this type is returned as a trait impl by a method
4779 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
4780         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
4781 }
4782 #[allow(unused)]
4783 impl RevokeAndACK {
4784         pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
4785                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4786         }
4787         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
4788                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4789         }
4790         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4791         pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
4792                 assert!(self.is_owned);
4793                 let ret = ObjOps::untweak_ptr(self.inner);
4794                 self.inner = core::ptr::null_mut();
4795                 ret
4796         }
4797 }
4798 /// The channel ID
4799 #[no_mangle]
4800 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4801         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4802         inner_val
4803 }
4804 /// The channel ID
4805 #[no_mangle]
4806 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4807         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4808 }
4809 /// The secret corresponding to the per-commitment point
4810 #[no_mangle]
4811 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4812         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
4813         inner_val
4814 }
4815 /// The secret corresponding to the per-commitment point
4816 #[no_mangle]
4817 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4818         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
4819 }
4820 /// The next sender-broadcast commitment transaction's per-commitment point
4821 #[no_mangle]
4822 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
4823         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
4824         crate::c_types::PublicKey::from_rust(&inner_val)
4825 }
4826 /// The next sender-broadcast commitment transaction's per-commitment point
4827 #[no_mangle]
4828 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
4829         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
4830 }
4831 /// Constructs a new RevokeAndACK given each field
4832 #[must_use]
4833 #[no_mangle]
4834 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 {
4835         RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
4836                 channel_id: channel_id_arg.data,
4837                 per_commitment_secret: per_commitment_secret_arg.data,
4838                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
4839         }), is_owned: true }
4840 }
4841 impl Clone for RevokeAndACK {
4842         fn clone(&self) -> Self {
4843                 Self {
4844                         inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
4845                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4846                         is_owned: true,
4847                 }
4848         }
4849 }
4850 #[allow(unused)]
4851 /// Used only if an object of this type is returned as a trait impl by a method
4852 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
4853         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
4854 }
4855 #[no_mangle]
4856 /// Creates a copy of the RevokeAndACK
4857 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
4858         orig.clone()
4859 }
4860 /// Checks if two RevokeAndACKs contain equal inner contents.
4861 /// This ignores pointers and is_owned flags and looks at the values in fields.
4862 /// Two objects with NULL inner values will be considered "equal" here.
4863 #[no_mangle]
4864 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
4865         if a.inner == b.inner { return true; }
4866         if a.inner.is_null() || b.inner.is_null() { return false; }
4867         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4868 }
4869
4870 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
4871 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
4872
4873 /// An [`update_fee`] message to be sent to or received from a peer
4874 ///
4875 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
4876 #[must_use]
4877 #[repr(C)]
4878 pub struct UpdateFee {
4879         /// A pointer to the opaque Rust object.
4880
4881         /// Nearly everywhere, inner must be non-null, however in places where
4882         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4883         pub inner: *mut nativeUpdateFee,
4884         /// Indicates that this is the only struct which contains the same pointer.
4885
4886         /// Rust functions which take ownership of an object provided via an argument require
4887         /// this to be true and invalidate the object pointed to by inner.
4888         pub is_owned: bool,
4889 }
4890
4891 impl Drop for UpdateFee {
4892         fn drop(&mut self) {
4893                 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
4894                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4895                 }
4896         }
4897 }
4898 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
4899 #[no_mangle]
4900 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
4901 #[allow(unused)]
4902 /// Used only if an object of this type is returned as a trait impl by a method
4903 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
4904         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
4905 }
4906 #[allow(unused)]
4907 impl UpdateFee {
4908         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
4909                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4910         }
4911         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
4912                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4913         }
4914         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4915         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
4916                 assert!(self.is_owned);
4917                 let ret = ObjOps::untweak_ptr(self.inner);
4918                 self.inner = core::ptr::null_mut();
4919                 ret
4920         }
4921 }
4922 /// The channel ID
4923 #[no_mangle]
4924 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
4925         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4926         inner_val
4927 }
4928 /// The channel ID
4929 #[no_mangle]
4930 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
4931         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4932 }
4933 /// Fee rate per 1000-weight of the transaction
4934 #[no_mangle]
4935 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
4936         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
4937         *inner_val
4938 }
4939 /// Fee rate per 1000-weight of the transaction
4940 #[no_mangle]
4941 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
4942         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
4943 }
4944 /// Constructs a new UpdateFee given each field
4945 #[must_use]
4946 #[no_mangle]
4947 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
4948         UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
4949                 channel_id: channel_id_arg.data,
4950                 feerate_per_kw: feerate_per_kw_arg,
4951         }), is_owned: true }
4952 }
4953 impl Clone for UpdateFee {
4954         fn clone(&self) -> Self {
4955                 Self {
4956                         inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
4957                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4958                         is_owned: true,
4959                 }
4960         }
4961 }
4962 #[allow(unused)]
4963 /// Used only if an object of this type is returned as a trait impl by a method
4964 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
4965         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
4966 }
4967 #[no_mangle]
4968 /// Creates a copy of the UpdateFee
4969 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
4970         orig.clone()
4971 }
4972 /// Checks if two UpdateFees contain equal inner contents.
4973 /// This ignores pointers and is_owned flags and looks at the values in fields.
4974 /// Two objects with NULL inner values will be considered "equal" here.
4975 #[no_mangle]
4976 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
4977         if a.inner == b.inner { return true; }
4978         if a.inner.is_null() || b.inner.is_null() { return false; }
4979         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4980 }
4981
4982 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
4983 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
4984
4985 /// A [`channel_reestablish`] message to be sent to or received from a peer.
4986 ///
4987 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
4988 #[must_use]
4989 #[repr(C)]
4990 pub struct ChannelReestablish {
4991         /// A pointer to the opaque Rust object.
4992
4993         /// Nearly everywhere, inner must be non-null, however in places where
4994         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4995         pub inner: *mut nativeChannelReestablish,
4996         /// Indicates that this is the only struct which contains the same pointer.
4997
4998         /// Rust functions which take ownership of an object provided via an argument require
4999         /// this to be true and invalidate the object pointed to by inner.
5000         pub is_owned: bool,
5001 }
5002
5003 impl Drop for ChannelReestablish {
5004         fn drop(&mut self) {
5005                 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
5006                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5007                 }
5008         }
5009 }
5010 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
5011 #[no_mangle]
5012 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
5013 #[allow(unused)]
5014 /// Used only if an object of this type is returned as a trait impl by a method
5015 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
5016         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
5017 }
5018 #[allow(unused)]
5019 impl ChannelReestablish {
5020         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
5021                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5022         }
5023         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
5024                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5025         }
5026         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5027         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
5028                 assert!(self.is_owned);
5029                 let ret = ObjOps::untweak_ptr(self.inner);
5030                 self.inner = core::ptr::null_mut();
5031                 ret
5032         }
5033 }
5034 /// The channel ID
5035 #[no_mangle]
5036 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5037         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5038         inner_val
5039 }
5040 /// The channel ID
5041 #[no_mangle]
5042 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5043         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
5044 }
5045 /// The next commitment number for the sender
5046 #[no_mangle]
5047 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5048         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
5049         *inner_val
5050 }
5051 /// The next commitment number for the sender
5052 #[no_mangle]
5053 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5054         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
5055 }
5056 /// The next commitment number for the recipient
5057 #[no_mangle]
5058 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5059         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
5060         *inner_val
5061 }
5062 /// The next commitment number for the recipient
5063 #[no_mangle]
5064 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5065         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
5066 }
5067 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5068 /// belonging to the recipient
5069 #[no_mangle]
5070 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5071         let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
5072         inner_val
5073 }
5074 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5075 /// belonging to the recipient
5076 #[no_mangle]
5077 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5078         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
5079 }
5080 /// The sender's per-commitment point for their current commitment transaction
5081 #[no_mangle]
5082 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
5083         let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
5084         crate::c_types::PublicKey::from_rust(&inner_val)
5085 }
5086 /// The sender's per-commitment point for their current commitment transaction
5087 #[no_mangle]
5088 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
5089         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
5090 }
5091 /// The next funding transaction ID
5092 #[no_mangle]
5093 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_TxidZ {
5094         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
5095         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_TxidZ::None } else { crate::c_types::derived::COption_TxidZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().into_inner() } }) };
5096         local_inner_val
5097 }
5098 /// The next funding transaction ID
5099 #[no_mangle]
5100 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_TxidZ) {
5101         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ val_opt.take() }.data[..]).unwrap() }})} };
5102         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
5103 }
5104 /// Constructs a new ChannelReestablish given each field
5105 #[must_use]
5106 #[no_mangle]
5107 pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_TxidZ) -> ChannelReestablish {
5108         let mut local_next_funding_txid_arg = { /*next_funding_txid_arg*/ let next_funding_txid_arg_opt = next_funding_txid_arg; if next_funding_txid_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ next_funding_txid_arg_opt.take() }.data[..]).unwrap() }})} };
5109         ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
5110                 channel_id: channel_id_arg.data,
5111                 next_local_commitment_number: next_local_commitment_number_arg,
5112                 next_remote_commitment_number: next_remote_commitment_number_arg,
5113                 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
5114                 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
5115                 next_funding_txid: local_next_funding_txid_arg,
5116         }), is_owned: true }
5117 }
5118 impl Clone for ChannelReestablish {
5119         fn clone(&self) -> Self {
5120                 Self {
5121                         inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
5122                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5123                         is_owned: true,
5124                 }
5125         }
5126 }
5127 #[allow(unused)]
5128 /// Used only if an object of this type is returned as a trait impl by a method
5129 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
5130         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
5131 }
5132 #[no_mangle]
5133 /// Creates a copy of the ChannelReestablish
5134 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
5135         orig.clone()
5136 }
5137 /// Checks if two ChannelReestablishs contain equal inner contents.
5138 /// This ignores pointers and is_owned flags and looks at the values in fields.
5139 /// Two objects with NULL inner values will be considered "equal" here.
5140 #[no_mangle]
5141 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
5142         if a.inner == b.inner { return true; }
5143         if a.inner.is_null() || b.inner.is_null() { return false; }
5144         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5145 }
5146
5147 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
5148 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
5149
5150 /// An [`announcement_signatures`] message to be sent to or received from a peer.
5151 ///
5152 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
5153 #[must_use]
5154 #[repr(C)]
5155 pub struct AnnouncementSignatures {
5156         /// A pointer to the opaque Rust object.
5157
5158         /// Nearly everywhere, inner must be non-null, however in places where
5159         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5160         pub inner: *mut nativeAnnouncementSignatures,
5161         /// Indicates that this is the only struct which contains the same pointer.
5162
5163         /// Rust functions which take ownership of an object provided via an argument require
5164         /// this to be true and invalidate the object pointed to by inner.
5165         pub is_owned: bool,
5166 }
5167
5168 impl Drop for AnnouncementSignatures {
5169         fn drop(&mut self) {
5170                 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
5171                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5172                 }
5173         }
5174 }
5175 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
5176 #[no_mangle]
5177 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
5178 #[allow(unused)]
5179 /// Used only if an object of this type is returned as a trait impl by a method
5180 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
5181         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
5182 }
5183 #[allow(unused)]
5184 impl AnnouncementSignatures {
5185         pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
5186                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5187         }
5188         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
5189                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5190         }
5191         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5192         pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
5193                 assert!(self.is_owned);
5194                 let ret = ObjOps::untweak_ptr(self.inner);
5195                 self.inner = core::ptr::null_mut();
5196                 ret
5197         }
5198 }
5199 /// The channel ID
5200 #[no_mangle]
5201 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
5202         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5203         inner_val
5204 }
5205 /// The channel ID
5206 #[no_mangle]
5207 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
5208         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
5209 }
5210 /// The short channel ID
5211 #[no_mangle]
5212 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
5213         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
5214         *inner_val
5215 }
5216 /// The short channel ID
5217 #[no_mangle]
5218 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
5219         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
5220 }
5221 /// A signature by the node key
5222 #[no_mangle]
5223 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
5224         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
5225         crate::c_types::Signature::from_rust(&inner_val)
5226 }
5227 /// A signature by the node key
5228 #[no_mangle]
5229 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
5230         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
5231 }
5232 /// A signature by the funding key
5233 #[no_mangle]
5234 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
5235         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
5236         crate::c_types::Signature::from_rust(&inner_val)
5237 }
5238 /// A signature by the funding key
5239 #[no_mangle]
5240 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
5241         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
5242 }
5243 /// Constructs a new AnnouncementSignatures given each field
5244 #[must_use]
5245 #[no_mangle]
5246 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 {
5247         AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
5248                 channel_id: channel_id_arg.data,
5249                 short_channel_id: short_channel_id_arg,
5250                 node_signature: node_signature_arg.into_rust(),
5251                 bitcoin_signature: bitcoin_signature_arg.into_rust(),
5252         }), is_owned: true }
5253 }
5254 impl Clone for AnnouncementSignatures {
5255         fn clone(&self) -> Self {
5256                 Self {
5257                         inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
5258                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5259                         is_owned: true,
5260                 }
5261         }
5262 }
5263 #[allow(unused)]
5264 /// Used only if an object of this type is returned as a trait impl by a method
5265 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
5266         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
5267 }
5268 #[no_mangle]
5269 /// Creates a copy of the AnnouncementSignatures
5270 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
5271         orig.clone()
5272 }
5273 /// Checks if two AnnouncementSignaturess contain equal inner contents.
5274 /// This ignores pointers and is_owned flags and looks at the values in fields.
5275 /// Two objects with NULL inner values will be considered "equal" here.
5276 #[no_mangle]
5277 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
5278         if a.inner == b.inner { return true; }
5279         if a.inner.is_null() || b.inner.is_null() { return false; }
5280         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5281 }
5282 /// An address which can be used to connect to a remote peer.
5283 #[derive(Clone)]
5284 #[must_use]
5285 #[repr(C)]
5286 pub enum NetAddress {
5287         /// An IPv4 address/port on which the peer is listening.
5288         IPv4 {
5289                 /// The 4-byte IPv4 address
5290                 addr: crate::c_types::FourBytes,
5291                 /// The port on which the node is listening
5292                 port: u16,
5293         },
5294         /// An IPv6 address/port on which the peer is listening.
5295         IPv6 {
5296                 /// The 16-byte IPv6 address
5297                 addr: crate::c_types::SixteenBytes,
5298                 /// The port on which the node is listening
5299                 port: u16,
5300         },
5301         /// An old-style Tor onion address/port on which the peer is listening.
5302         ///
5303         /// This field is deprecated and the Tor network generally no longer supports V2 Onion
5304         /// addresses. Thus, the details are not parsed here.
5305         OnionV2(
5306                 crate::c_types::TwelveBytes),
5307         /// A new-style Tor onion address/port on which the peer is listening.
5308         ///
5309         /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
5310         /// wrap as base32 and append \".onion\".
5311         OnionV3 {
5312                 /// The ed25519 long-term public key of the peer
5313                 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
5314                 /// The checksum of the pubkey and version, as included in the onion address
5315                 checksum: u16,
5316                 /// The version byte, as defined by the Tor Onion v3 spec.
5317                 version: u8,
5318                 /// The port on which the node is listening
5319                 port: u16,
5320         },
5321         /// A hostname/port on which the peer is listening.
5322         Hostname {
5323                 /// The hostname on which the node is listening.
5324                 hostname: crate::lightning::util::ser::Hostname,
5325                 /// The port on which the node is listening.
5326                 port: u16,
5327         },
5328 }
5329 use lightning::ln::msgs::NetAddress as NetAddressImport;
5330 pub(crate) type nativeNetAddress = NetAddressImport;
5331
5332 impl NetAddress {
5333         #[allow(unused)]
5334         pub(crate) fn to_native(&self) -> nativeNetAddress {
5335                 match self {
5336                         NetAddress::IPv4 {ref addr, ref port, } => {
5337                                 let mut addr_nonref = Clone::clone(addr);
5338                                 let mut port_nonref = Clone::clone(port);
5339                                 nativeNetAddress::IPv4 {
5340                                         addr: addr_nonref.data,
5341                                         port: port_nonref,
5342                                 }
5343                         },
5344                         NetAddress::IPv6 {ref addr, ref port, } => {
5345                                 let mut addr_nonref = Clone::clone(addr);
5346                                 let mut port_nonref = Clone::clone(port);
5347                                 nativeNetAddress::IPv6 {
5348                                         addr: addr_nonref.data,
5349                                         port: port_nonref,
5350                                 }
5351                         },
5352                         NetAddress::OnionV2 (ref a, ) => {
5353                                 let mut a_nonref = Clone::clone(a);
5354                                 nativeNetAddress::OnionV2 (
5355                                         a_nonref.data,
5356                                 )
5357                         },
5358                         NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5359                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5360                                 let mut checksum_nonref = Clone::clone(checksum);
5361                                 let mut version_nonref = Clone::clone(version);
5362                                 let mut port_nonref = Clone::clone(port);
5363                                 nativeNetAddress::OnionV3 {
5364                                         ed25519_pubkey: ed25519_pubkey_nonref.data,
5365                                         checksum: checksum_nonref,
5366                                         version: version_nonref,
5367                                         port: port_nonref,
5368                                 }
5369                         },
5370                         NetAddress::Hostname {ref hostname, ref port, } => {
5371                                 let mut hostname_nonref = Clone::clone(hostname);
5372                                 let mut port_nonref = Clone::clone(port);
5373                                 nativeNetAddress::Hostname {
5374                                         hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
5375                                         port: port_nonref,
5376                                 }
5377                         },
5378                 }
5379         }
5380         #[allow(unused)]
5381         pub(crate) fn into_native(self) -> nativeNetAddress {
5382                 match self {
5383                         NetAddress::IPv4 {mut addr, mut port, } => {
5384                                 nativeNetAddress::IPv4 {
5385                                         addr: addr.data,
5386                                         port: port,
5387                                 }
5388                         },
5389                         NetAddress::IPv6 {mut addr, mut port, } => {
5390                                 nativeNetAddress::IPv6 {
5391                                         addr: addr.data,
5392                                         port: port,
5393                                 }
5394                         },
5395                         NetAddress::OnionV2 (mut a, ) => {
5396                                 nativeNetAddress::OnionV2 (
5397                                         a.data,
5398                                 )
5399                         },
5400                         NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5401                                 nativeNetAddress::OnionV3 {
5402                                         ed25519_pubkey: ed25519_pubkey.data,
5403                                         checksum: checksum,
5404                                         version: version,
5405                                         port: port,
5406                                 }
5407                         },
5408                         NetAddress::Hostname {mut hostname, mut port, } => {
5409                                 nativeNetAddress::Hostname {
5410                                         hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
5411                                         port: port,
5412                                 }
5413                         },
5414                 }
5415         }
5416         #[allow(unused)]
5417         pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
5418                 match native {
5419                         nativeNetAddress::IPv4 {ref addr, ref port, } => {
5420                                 let mut addr_nonref = Clone::clone(addr);
5421                                 let mut port_nonref = Clone::clone(port);
5422                                 NetAddress::IPv4 {
5423                                         addr: crate::c_types::FourBytes { data: addr_nonref },
5424                                         port: port_nonref,
5425                                 }
5426                         },
5427                         nativeNetAddress::IPv6 {ref addr, ref port, } => {
5428                                 let mut addr_nonref = Clone::clone(addr);
5429                                 let mut port_nonref = Clone::clone(port);
5430                                 NetAddress::IPv6 {
5431                                         addr: crate::c_types::SixteenBytes { data: addr_nonref },
5432                                         port: port_nonref,
5433                                 }
5434                         },
5435                         nativeNetAddress::OnionV2 (ref a, ) => {
5436                                 let mut a_nonref = Clone::clone(a);
5437                                 NetAddress::OnionV2 (
5438                                         crate::c_types::TwelveBytes { data: a_nonref },
5439                                 )
5440                         },
5441                         nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5442                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5443                                 let mut checksum_nonref = Clone::clone(checksum);
5444                                 let mut version_nonref = Clone::clone(version);
5445                                 let mut port_nonref = Clone::clone(port);
5446                                 NetAddress::OnionV3 {
5447                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
5448                                         checksum: checksum_nonref,
5449                                         version: version_nonref,
5450                                         port: port_nonref,
5451                                 }
5452                         },
5453                         nativeNetAddress::Hostname {ref hostname, ref port, } => {
5454                                 let mut hostname_nonref = Clone::clone(hostname);
5455                                 let mut port_nonref = Clone::clone(port);
5456                                 NetAddress::Hostname {
5457                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
5458                                         port: port_nonref,
5459                                 }
5460                         },
5461                 }
5462         }
5463         #[allow(unused)]
5464         pub(crate) fn native_into(native: nativeNetAddress) -> Self {
5465                 match native {
5466                         nativeNetAddress::IPv4 {mut addr, mut port, } => {
5467                                 NetAddress::IPv4 {
5468                                         addr: crate::c_types::FourBytes { data: addr },
5469                                         port: port,
5470                                 }
5471                         },
5472                         nativeNetAddress::IPv6 {mut addr, mut port, } => {
5473                                 NetAddress::IPv6 {
5474                                         addr: crate::c_types::SixteenBytes { data: addr },
5475                                         port: port,
5476                                 }
5477                         },
5478                         nativeNetAddress::OnionV2 (mut a, ) => {
5479                                 NetAddress::OnionV2 (
5480                                         crate::c_types::TwelveBytes { data: a },
5481                                 )
5482                         },
5483                         nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5484                                 NetAddress::OnionV3 {
5485                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
5486                                         checksum: checksum,
5487                                         version: version,
5488                                         port: port,
5489                                 }
5490                         },
5491                         nativeNetAddress::Hostname {mut hostname, mut port, } => {
5492                                 NetAddress::Hostname {
5493                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
5494                                         port: port,
5495                                 }
5496                         },
5497                 }
5498         }
5499 }
5500 /// Frees any resources used by the NetAddress
5501 #[no_mangle]
5502 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
5503 /// Creates a copy of the NetAddress
5504 #[no_mangle]
5505 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
5506         orig.clone()
5507 }
5508 #[no_mangle]
5509 /// Utility method to constructs a new IPv4-variant NetAddress
5510 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
5511         NetAddress::IPv4 {
5512                 addr,
5513                 port,
5514         }
5515 }
5516 #[no_mangle]
5517 /// Utility method to constructs a new IPv6-variant NetAddress
5518 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
5519         NetAddress::IPv6 {
5520                 addr,
5521                 port,
5522         }
5523 }
5524 #[no_mangle]
5525 /// Utility method to constructs a new OnionV2-variant NetAddress
5526 pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
5527         NetAddress::OnionV2(a, )
5528 }
5529 #[no_mangle]
5530 /// Utility method to constructs a new OnionV3-variant NetAddress
5531 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
5532         NetAddress::OnionV3 {
5533                 ed25519_pubkey,
5534                 checksum,
5535                 version,
5536                 port,
5537         }
5538 }
5539 #[no_mangle]
5540 /// Utility method to constructs a new Hostname-variant NetAddress
5541 pub extern "C" fn NetAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> NetAddress {
5542         NetAddress::Hostname {
5543                 hostname,
5544                 port,
5545         }
5546 }
5547 /// Checks if two NetAddresss contain equal inner contents.
5548 /// This ignores pointers and is_owned flags and looks at the values in fields.
5549 #[no_mangle]
5550 pub extern "C" fn NetAddress_eq(a: &NetAddress, b: &NetAddress) -> bool {
5551         if &a.to_native() == &b.to_native() { true } else { false }
5552 }
5553 #[no_mangle]
5554 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
5555 pub extern "C" fn NetAddress_write(obj: &crate::lightning::ln::msgs::NetAddress) -> crate::c_types::derived::CVec_u8Z {
5556         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5557 }
5558 #[no_mangle]
5559 /// Read a NetAddress from a byte array, created by NetAddress_write
5560 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
5561         let res: Result<lightning::ln::msgs::NetAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5562         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
5563         local_res
5564 }
5565 /// Represents the set of gossip messages that require a signature from a node's identity key.
5566 #[derive(Clone)]
5567 #[must_use]
5568 #[repr(C)]
5569 pub enum UnsignedGossipMessage {
5570         /// An unsigned channel announcement.
5571         ChannelAnnouncement(
5572                 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
5573         /// An unsigned channel update.
5574         ChannelUpdate(
5575                 crate::lightning::ln::msgs::UnsignedChannelUpdate),
5576         /// An unsigned node announcement.
5577         NodeAnnouncement(
5578                 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
5579 }
5580 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
5581 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
5582
5583 impl UnsignedGossipMessage {
5584         #[allow(unused)]
5585         pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
5586                 match self {
5587                         UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5588                                 let mut a_nonref = Clone::clone(a);
5589                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
5590                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
5591                                 )
5592                         },
5593                         UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5594                                 let mut a_nonref = Clone::clone(a);
5595                                 nativeUnsignedGossipMessage::ChannelUpdate (
5596                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
5597                                 )
5598                         },
5599                         UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5600                                 let mut a_nonref = Clone::clone(a);
5601                                 nativeUnsignedGossipMessage::NodeAnnouncement (
5602                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
5603                                 )
5604                         },
5605                 }
5606         }
5607         #[allow(unused)]
5608         pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
5609                 match self {
5610                         UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5611                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
5612                                         *unsafe { Box::from_raw(a.take_inner()) },
5613                                 )
5614                         },
5615                         UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5616                                 nativeUnsignedGossipMessage::ChannelUpdate (
5617                                         *unsafe { Box::from_raw(a.take_inner()) },
5618                                 )
5619                         },
5620                         UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5621                                 nativeUnsignedGossipMessage::NodeAnnouncement (
5622                                         *unsafe { Box::from_raw(a.take_inner()) },
5623                                 )
5624                         },
5625                 }
5626         }
5627         #[allow(unused)]
5628         pub(crate) fn from_native(native: &nativeUnsignedGossipMessage) -> Self {
5629                 match native {
5630                         nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5631                                 let mut a_nonref = Clone::clone(a);
5632                                 UnsignedGossipMessage::ChannelAnnouncement (
5633                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5634                                 )
5635                         },
5636                         nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5637                                 let mut a_nonref = Clone::clone(a);
5638                                 UnsignedGossipMessage::ChannelUpdate (
5639                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5640                                 )
5641                         },
5642                         nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5643                                 let mut a_nonref = Clone::clone(a);
5644                                 UnsignedGossipMessage::NodeAnnouncement (
5645                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5646                                 )
5647                         },
5648                 }
5649         }
5650         #[allow(unused)]
5651         pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
5652                 match native {
5653                         nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5654                                 UnsignedGossipMessage::ChannelAnnouncement (
5655                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5656                                 )
5657                         },
5658                         nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5659                                 UnsignedGossipMessage::ChannelUpdate (
5660                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
5661                                 )
5662                         },
5663                         nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5664                                 UnsignedGossipMessage::NodeAnnouncement (
5665                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5666                                 )
5667                         },
5668                 }
5669         }
5670 }
5671 /// Frees any resources used by the UnsignedGossipMessage
5672 #[no_mangle]
5673 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
5674 /// Creates a copy of the UnsignedGossipMessage
5675 #[no_mangle]
5676 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
5677         orig.clone()
5678 }
5679 #[no_mangle]
5680 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
5681 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
5682         UnsignedGossipMessage::ChannelAnnouncement(a, )
5683 }
5684 #[no_mangle]
5685 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
5686 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
5687         UnsignedGossipMessage::ChannelUpdate(a, )
5688 }
5689 #[no_mangle]
5690 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
5691 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
5692         UnsignedGossipMessage::NodeAnnouncement(a, )
5693 }
5694 #[no_mangle]
5695 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
5696 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
5697         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5698 }
5699
5700 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
5701 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
5702
5703 /// The unsigned part of a [`node_announcement`] message.
5704 ///
5705 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
5706 #[must_use]
5707 #[repr(C)]
5708 pub struct UnsignedNodeAnnouncement {
5709         /// A pointer to the opaque Rust object.
5710
5711         /// Nearly everywhere, inner must be non-null, however in places where
5712         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5713         pub inner: *mut nativeUnsignedNodeAnnouncement,
5714         /// Indicates that this is the only struct which contains the same pointer.
5715
5716         /// Rust functions which take ownership of an object provided via an argument require
5717         /// this to be true and invalidate the object pointed to by inner.
5718         pub is_owned: bool,
5719 }
5720
5721 impl Drop for UnsignedNodeAnnouncement {
5722         fn drop(&mut self) {
5723                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
5724                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5725                 }
5726         }
5727 }
5728 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
5729 #[no_mangle]
5730 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
5731 #[allow(unused)]
5732 /// Used only if an object of this type is returned as a trait impl by a method
5733 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
5734         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
5735 }
5736 #[allow(unused)]
5737 impl UnsignedNodeAnnouncement {
5738         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
5739                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5740         }
5741         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
5742                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5743         }
5744         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5745         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
5746                 assert!(self.is_owned);
5747                 let ret = ObjOps::untweak_ptr(self.inner);
5748                 self.inner = core::ptr::null_mut();
5749                 ret
5750         }
5751 }
5752 /// The advertised features
5753 #[no_mangle]
5754 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
5755         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
5756         crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false }
5757 }
5758 /// The advertised features
5759 #[no_mangle]
5760 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
5761         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
5762 }
5763 /// A strictly monotonic announcement counter, with gaps allowed
5764 #[no_mangle]
5765 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
5766         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
5767         *inner_val
5768 }
5769 /// A strictly monotonic announcement counter, with gaps allowed
5770 #[no_mangle]
5771 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
5772         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
5773 }
5774 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5775 /// to this node).
5776 #[no_mangle]
5777 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
5778         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
5779         crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
5780 }
5781 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5782 /// to this node).
5783 #[no_mangle]
5784 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
5785         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
5786 }
5787 /// An RGB color for UI purposes
5788 #[no_mangle]
5789 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
5790         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
5791         inner_val
5792 }
5793 /// An RGB color for UI purposes
5794 #[no_mangle]
5795 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
5796         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
5797 }
5798 /// An alias, for UI purposes.
5799 ///
5800 /// This should be sanitized before use. There is no guarantee of uniqueness.
5801 #[no_mangle]
5802 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
5803         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
5804         crate::lightning::routing::gossip::NodeAlias { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeAlias<>) as *mut _) }, is_owned: false }
5805 }
5806 /// An alias, for UI purposes.
5807 ///
5808 /// This should be sanitized before use. There is no guarantee of uniqueness.
5809 #[no_mangle]
5810 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
5811         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
5812 }
5813 /// List of addresses on which this node is reachable
5814 ///
5815 /// Returns a copy of the field.
5816 #[no_mangle]
5817 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_NetAddressZ {
5818         let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
5819         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::NetAddress::native_into(item) }); };
5820         local_inner_val.into()
5821 }
5822 /// List of addresses on which this node is reachable
5823 #[no_mangle]
5824 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
5825         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
5826         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
5827 }
5828 impl Clone for UnsignedNodeAnnouncement {
5829         fn clone(&self) -> Self {
5830                 Self {
5831                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
5832                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5833                         is_owned: true,
5834                 }
5835         }
5836 }
5837 #[allow(unused)]
5838 /// Used only if an object of this type is returned as a trait impl by a method
5839 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
5840         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
5841 }
5842 #[no_mangle]
5843 /// Creates a copy of the UnsignedNodeAnnouncement
5844 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
5845         orig.clone()
5846 }
5847 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
5848 /// This ignores pointers and is_owned flags and looks at the values in fields.
5849 /// Two objects with NULL inner values will be considered "equal" here.
5850 #[no_mangle]
5851 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
5852         if a.inner == b.inner { return true; }
5853         if a.inner.is_null() || b.inner.is_null() { return false; }
5854         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5855 }
5856
5857 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
5858 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
5859
5860 /// A [`node_announcement`] message to be sent to or received from a peer.
5861 ///
5862 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
5863 #[must_use]
5864 #[repr(C)]
5865 pub struct NodeAnnouncement {
5866         /// A pointer to the opaque Rust object.
5867
5868         /// Nearly everywhere, inner must be non-null, however in places where
5869         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5870         pub inner: *mut nativeNodeAnnouncement,
5871         /// Indicates that this is the only struct which contains the same pointer.
5872
5873         /// Rust functions which take ownership of an object provided via an argument require
5874         /// this to be true and invalidate the object pointed to by inner.
5875         pub is_owned: bool,
5876 }
5877
5878 impl Drop for NodeAnnouncement {
5879         fn drop(&mut self) {
5880                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
5881                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5882                 }
5883         }
5884 }
5885 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
5886 #[no_mangle]
5887 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
5888 #[allow(unused)]
5889 /// Used only if an object of this type is returned as a trait impl by a method
5890 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
5891         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
5892 }
5893 #[allow(unused)]
5894 impl NodeAnnouncement {
5895         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
5896                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5897         }
5898         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
5899                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5900         }
5901         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5902         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
5903                 assert!(self.is_owned);
5904                 let ret = ObjOps::untweak_ptr(self.inner);
5905                 self.inner = core::ptr::null_mut();
5906                 ret
5907         }
5908 }
5909 /// The signature by the node key
5910 #[no_mangle]
5911 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
5912         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
5913         crate::c_types::Signature::from_rust(&inner_val)
5914 }
5915 /// The signature by the node key
5916 #[no_mangle]
5917 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
5918         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
5919 }
5920 /// The actual content of the announcement
5921 #[no_mangle]
5922 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
5923         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
5924         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedNodeAnnouncement<>) as *mut _) }, is_owned: false }
5925 }
5926 /// The actual content of the announcement
5927 #[no_mangle]
5928 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
5929         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
5930 }
5931 /// Constructs a new NodeAnnouncement given each field
5932 #[must_use]
5933 #[no_mangle]
5934 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
5935         NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
5936                 signature: signature_arg.into_rust(),
5937                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
5938         }), is_owned: true }
5939 }
5940 impl Clone for NodeAnnouncement {
5941         fn clone(&self) -> Self {
5942                 Self {
5943                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
5944                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5945                         is_owned: true,
5946                 }
5947         }
5948 }
5949 #[allow(unused)]
5950 /// Used only if an object of this type is returned as a trait impl by a method
5951 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
5952         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
5953 }
5954 #[no_mangle]
5955 /// Creates a copy of the NodeAnnouncement
5956 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
5957         orig.clone()
5958 }
5959 /// Checks if two NodeAnnouncements contain equal inner contents.
5960 /// This ignores pointers and is_owned flags and looks at the values in fields.
5961 /// Two objects with NULL inner values will be considered "equal" here.
5962 #[no_mangle]
5963 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
5964         if a.inner == b.inner { return true; }
5965         if a.inner.is_null() || b.inner.is_null() { return false; }
5966         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5967 }
5968
5969 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
5970 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
5971
5972 /// The unsigned part of a [`channel_announcement`] message.
5973 ///
5974 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
5975 #[must_use]
5976 #[repr(C)]
5977 pub struct UnsignedChannelAnnouncement {
5978         /// A pointer to the opaque Rust object.
5979
5980         /// Nearly everywhere, inner must be non-null, however in places where
5981         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5982         pub inner: *mut nativeUnsignedChannelAnnouncement,
5983         /// Indicates that this is the only struct which contains the same pointer.
5984
5985         /// Rust functions which take ownership of an object provided via an argument require
5986         /// this to be true and invalidate the object pointed to by inner.
5987         pub is_owned: bool,
5988 }
5989
5990 impl Drop for UnsignedChannelAnnouncement {
5991         fn drop(&mut self) {
5992                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
5993                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5994                 }
5995         }
5996 }
5997 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
5998 #[no_mangle]
5999 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
6000 #[allow(unused)]
6001 /// Used only if an object of this type is returned as a trait impl by a method
6002 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6003         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
6004 }
6005 #[allow(unused)]
6006 impl UnsignedChannelAnnouncement {
6007         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
6008                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6009         }
6010         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
6011                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6012         }
6013         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6014         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
6015                 assert!(self.is_owned);
6016                 let ret = ObjOps::untweak_ptr(self.inner);
6017                 self.inner = core::ptr::null_mut();
6018                 ret
6019         }
6020 }
6021 /// The advertised channel features
6022 #[no_mangle]
6023 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
6024         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6025         crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false }
6026 }
6027 /// The advertised channel features
6028 #[no_mangle]
6029 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
6030         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
6031 }
6032 /// The genesis hash of the blockchain where the channel is to be opened
6033 #[no_mangle]
6034 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
6035         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6036         inner_val.as_inner()
6037 }
6038 /// The genesis hash of the blockchain where the channel is to be opened
6039 #[no_mangle]
6040 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
6041         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6042 }
6043 /// The short channel ID
6044 #[no_mangle]
6045 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
6046         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6047         *inner_val
6048 }
6049 /// The short channel ID
6050 #[no_mangle]
6051 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
6052         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6053 }
6054 /// One of the two `node_id`s which are endpoints of this channel
6055 #[no_mangle]
6056 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6057         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
6058         crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
6059 }
6060 /// One of the two `node_id`s which are endpoints of this channel
6061 #[no_mangle]
6062 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6063         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
6064 }
6065 /// The other of the two `node_id`s which are endpoints of this channel
6066 #[no_mangle]
6067 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6068         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
6069         crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
6070 }
6071 /// The other of the two `node_id`s which are endpoints of this channel
6072 #[no_mangle]
6073 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6074         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
6075 }
6076 /// The funding key for the first node
6077 #[no_mangle]
6078 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6079         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
6080         crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
6081 }
6082 /// The funding key for the first node
6083 #[no_mangle]
6084 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6085         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
6086 }
6087 /// The funding key for the second node
6088 #[no_mangle]
6089 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6090         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
6091         crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
6092 }
6093 /// The funding key for the second node
6094 #[no_mangle]
6095 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6096         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
6097 }
6098 impl Clone for UnsignedChannelAnnouncement {
6099         fn clone(&self) -> Self {
6100                 Self {
6101                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6102                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6103                         is_owned: true,
6104                 }
6105         }
6106 }
6107 #[allow(unused)]
6108 /// Used only if an object of this type is returned as a trait impl by a method
6109 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6110         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
6111 }
6112 #[no_mangle]
6113 /// Creates a copy of the UnsignedChannelAnnouncement
6114 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
6115         orig.clone()
6116 }
6117 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
6118 /// This ignores pointers and is_owned flags and looks at the values in fields.
6119 /// Two objects with NULL inner values will be considered "equal" here.
6120 #[no_mangle]
6121 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
6122         if a.inner == b.inner { return true; }
6123         if a.inner.is_null() || b.inner.is_null() { return false; }
6124         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6125 }
6126
6127 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
6128 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
6129
6130 /// A [`channel_announcement`] message to be sent to or received from a peer.
6131 ///
6132 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
6133 #[must_use]
6134 #[repr(C)]
6135 pub struct ChannelAnnouncement {
6136         /// A pointer to the opaque Rust object.
6137
6138         /// Nearly everywhere, inner must be non-null, however in places where
6139         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6140         pub inner: *mut nativeChannelAnnouncement,
6141         /// Indicates that this is the only struct which contains the same pointer.
6142
6143         /// Rust functions which take ownership of an object provided via an argument require
6144         /// this to be true and invalidate the object pointed to by inner.
6145         pub is_owned: bool,
6146 }
6147
6148 impl Drop for ChannelAnnouncement {
6149         fn drop(&mut self) {
6150                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
6151                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6152                 }
6153         }
6154 }
6155 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
6156 #[no_mangle]
6157 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
6158 #[allow(unused)]
6159 /// Used only if an object of this type is returned as a trait impl by a method
6160 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6161         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
6162 }
6163 #[allow(unused)]
6164 impl ChannelAnnouncement {
6165         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
6166                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6167         }
6168         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
6169                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6170         }
6171         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6172         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
6173                 assert!(self.is_owned);
6174                 let ret = ObjOps::untweak_ptr(self.inner);
6175                 self.inner = core::ptr::null_mut();
6176                 ret
6177         }
6178 }
6179 /// Authentication of the announcement by the first public node
6180 #[no_mangle]
6181 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
6182         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
6183         crate::c_types::Signature::from_rust(&inner_val)
6184 }
6185 /// Authentication of the announcement by the first public node
6186 #[no_mangle]
6187 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
6188         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
6189 }
6190 /// Authentication of the announcement by the second public node
6191 #[no_mangle]
6192 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
6193         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
6194         crate::c_types::Signature::from_rust(&inner_val)
6195 }
6196 /// Authentication of the announcement by the second public node
6197 #[no_mangle]
6198 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
6199         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
6200 }
6201 /// Proof of funding UTXO ownership by the first public node
6202 #[no_mangle]
6203 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
6204         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
6205         crate::c_types::Signature::from_rust(&inner_val)
6206 }
6207 /// Proof of funding UTXO ownership by the first public node
6208 #[no_mangle]
6209 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
6210         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
6211 }
6212 /// Proof of funding UTXO ownership by the second public node
6213 #[no_mangle]
6214 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
6215         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
6216         crate::c_types::Signature::from_rust(&inner_val)
6217 }
6218 /// Proof of funding UTXO ownership by the second public node
6219 #[no_mangle]
6220 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
6221         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
6222 }
6223 /// The actual announcement
6224 #[no_mangle]
6225 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
6226         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6227         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }
6228 }
6229 /// The actual announcement
6230 #[no_mangle]
6231 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
6232         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6233 }
6234 /// Constructs a new ChannelAnnouncement given each field
6235 #[must_use]
6236 #[no_mangle]
6237 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::lightning::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
6238         ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
6239                 node_signature_1: node_signature_1_arg.into_rust(),
6240                 node_signature_2: node_signature_2_arg.into_rust(),
6241                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
6242                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
6243                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6244         }), is_owned: true }
6245 }
6246 impl Clone for ChannelAnnouncement {
6247         fn clone(&self) -> Self {
6248                 Self {
6249                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6250                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6251                         is_owned: true,
6252                 }
6253         }
6254 }
6255 #[allow(unused)]
6256 /// Used only if an object of this type is returned as a trait impl by a method
6257 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6258         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
6259 }
6260 #[no_mangle]
6261 /// Creates a copy of the ChannelAnnouncement
6262 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
6263         orig.clone()
6264 }
6265 /// Checks if two ChannelAnnouncements contain equal inner contents.
6266 /// This ignores pointers and is_owned flags and looks at the values in fields.
6267 /// Two objects with NULL inner values will be considered "equal" here.
6268 #[no_mangle]
6269 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
6270         if a.inner == b.inner { return true; }
6271         if a.inner.is_null() || b.inner.is_null() { return false; }
6272         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6273 }
6274
6275 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
6276 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
6277
6278 /// The unsigned part of a [`channel_update`] message.
6279 ///
6280 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6281 #[must_use]
6282 #[repr(C)]
6283 pub struct UnsignedChannelUpdate {
6284         /// A pointer to the opaque Rust object.
6285
6286         /// Nearly everywhere, inner must be non-null, however in places where
6287         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6288         pub inner: *mut nativeUnsignedChannelUpdate,
6289         /// Indicates that this is the only struct which contains the same pointer.
6290
6291         /// Rust functions which take ownership of an object provided via an argument require
6292         /// this to be true and invalidate the object pointed to by inner.
6293         pub is_owned: bool,
6294 }
6295
6296 impl Drop for UnsignedChannelUpdate {
6297         fn drop(&mut self) {
6298                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
6299                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6300                 }
6301         }
6302 }
6303 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
6304 #[no_mangle]
6305 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
6306 #[allow(unused)]
6307 /// Used only if an object of this type is returned as a trait impl by a method
6308 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
6309         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
6310 }
6311 #[allow(unused)]
6312 impl UnsignedChannelUpdate {
6313         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
6314                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6315         }
6316         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
6317                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6318         }
6319         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6320         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
6321                 assert!(self.is_owned);
6322                 let ret = ObjOps::untweak_ptr(self.inner);
6323                 self.inner = core::ptr::null_mut();
6324                 ret
6325         }
6326 }
6327 /// The genesis hash of the blockchain where the channel is to be opened
6328 #[no_mangle]
6329 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
6330         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6331         inner_val.as_inner()
6332 }
6333 /// The genesis hash of the blockchain where the channel is to be opened
6334 #[no_mangle]
6335 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
6336         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6337 }
6338 /// The short channel ID
6339 #[no_mangle]
6340 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
6341         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6342         *inner_val
6343 }
6344 /// The short channel ID
6345 #[no_mangle]
6346 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6347         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6348 }
6349 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6350 #[no_mangle]
6351 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
6352         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
6353         *inner_val
6354 }
6355 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6356 #[no_mangle]
6357 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6358         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
6359 }
6360 /// Channel flags
6361 #[no_mangle]
6362 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
6363         let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
6364         *inner_val
6365 }
6366 /// Channel flags
6367 #[no_mangle]
6368 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
6369         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
6370 }
6371 /// The number of blocks such that if:
6372 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6373 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6374 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6375 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6376 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6377 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6378 /// constructing the route.
6379 #[no_mangle]
6380 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
6381         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
6382         *inner_val
6383 }
6384 /// The number of blocks such that if:
6385 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6386 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6387 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6388 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6389 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6390 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6391 /// constructing the route.
6392 #[no_mangle]
6393 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
6394         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
6395 }
6396 /// The minimum HTLC size incoming to sender, in milli-satoshi
6397 #[no_mangle]
6398 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6399         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
6400         *inner_val
6401 }
6402 /// The minimum HTLC size incoming to sender, in milli-satoshi
6403 #[no_mangle]
6404 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6405         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
6406 }
6407 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6408 ///
6409 /// This used to be optional.
6410 #[no_mangle]
6411 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6412         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
6413         *inner_val
6414 }
6415 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6416 ///
6417 /// This used to be optional.
6418 #[no_mangle]
6419 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6420         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
6421 }
6422 /// The base HTLC fee charged by sender, in milli-satoshi
6423 #[no_mangle]
6424 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
6425         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
6426         *inner_val
6427 }
6428 /// The base HTLC fee charged by sender, in milli-satoshi
6429 #[no_mangle]
6430 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6431         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
6432 }
6433 /// The amount to fee multiplier, in micro-satoshi
6434 #[no_mangle]
6435 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
6436         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
6437         *inner_val
6438 }
6439 /// The amount to fee multiplier, in micro-satoshi
6440 #[no_mangle]
6441 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6442         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
6443 }
6444 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6445 /// to decode.
6446 ///
6447 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6448 ///
6449 /// Returns a copy of the field.
6450 #[no_mangle]
6451 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6452         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6453         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6454         local_inner_val.into()
6455 }
6456 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6457 /// to decode.
6458 ///
6459 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6460 #[no_mangle]
6461 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
6462         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6463         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6464 }
6465 /// Constructs a new UnsignedChannelUpdate given each field
6466 #[must_use]
6467 #[no_mangle]
6468 pub extern "C" fn UnsignedChannelUpdate_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut timestamp_arg: u32, mut flags_arg: u8, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelUpdate {
6469         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6470         UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
6471                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6472                 short_channel_id: short_channel_id_arg,
6473                 timestamp: timestamp_arg,
6474                 flags: flags_arg,
6475                 cltv_expiry_delta: cltv_expiry_delta_arg,
6476                 htlc_minimum_msat: htlc_minimum_msat_arg,
6477                 htlc_maximum_msat: htlc_maximum_msat_arg,
6478                 fee_base_msat: fee_base_msat_arg,
6479                 fee_proportional_millionths: fee_proportional_millionths_arg,
6480                 excess_data: local_excess_data_arg,
6481         }), is_owned: true }
6482 }
6483 impl Clone for UnsignedChannelUpdate {
6484         fn clone(&self) -> Self {
6485                 Self {
6486                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6487                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6488                         is_owned: true,
6489                 }
6490         }
6491 }
6492 #[allow(unused)]
6493 /// Used only if an object of this type is returned as a trait impl by a method
6494 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6495         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
6496 }
6497 #[no_mangle]
6498 /// Creates a copy of the UnsignedChannelUpdate
6499 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
6500         orig.clone()
6501 }
6502 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
6503 /// This ignores pointers and is_owned flags and looks at the values in fields.
6504 /// Two objects with NULL inner values will be considered "equal" here.
6505 #[no_mangle]
6506 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
6507         if a.inner == b.inner { return true; }
6508         if a.inner.is_null() || b.inner.is_null() { return false; }
6509         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6510 }
6511
6512 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
6513 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
6514
6515 /// A [`channel_update`] message to be sent to or received from a peer.
6516 ///
6517 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6518 #[must_use]
6519 #[repr(C)]
6520 pub struct ChannelUpdate {
6521         /// A pointer to the opaque Rust object.
6522
6523         /// Nearly everywhere, inner must be non-null, however in places where
6524         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6525         pub inner: *mut nativeChannelUpdate,
6526         /// Indicates that this is the only struct which contains the same pointer.
6527
6528         /// Rust functions which take ownership of an object provided via an argument require
6529         /// this to be true and invalidate the object pointed to by inner.
6530         pub is_owned: bool,
6531 }
6532
6533 impl Drop for ChannelUpdate {
6534         fn drop(&mut self) {
6535                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
6536                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6537                 }
6538         }
6539 }
6540 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
6541 #[no_mangle]
6542 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
6543 #[allow(unused)]
6544 /// Used only if an object of this type is returned as a trait impl by a method
6545 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
6546         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
6547 }
6548 #[allow(unused)]
6549 impl ChannelUpdate {
6550         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
6551                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6552         }
6553         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
6554                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6555         }
6556         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6557         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
6558                 assert!(self.is_owned);
6559                 let ret = ObjOps::untweak_ptr(self.inner);
6560                 self.inner = core::ptr::null_mut();
6561                 ret
6562         }
6563 }
6564 /// A signature of the channel update
6565 #[no_mangle]
6566 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
6567         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
6568         crate::c_types::Signature::from_rust(&inner_val)
6569 }
6570 /// A signature of the channel update
6571 #[no_mangle]
6572 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
6573         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
6574 }
6575 /// The actual channel update
6576 #[no_mangle]
6577 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
6578         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6579         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedChannelUpdate<>) as *mut _) }, is_owned: false }
6580 }
6581 /// The actual channel update
6582 #[no_mangle]
6583 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
6584         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6585 }
6586 /// Constructs a new ChannelUpdate given each field
6587 #[must_use]
6588 #[no_mangle]
6589 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
6590         ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
6591                 signature: signature_arg.into_rust(),
6592                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6593         }), is_owned: true }
6594 }
6595 impl Clone for ChannelUpdate {
6596         fn clone(&self) -> Self {
6597                 Self {
6598                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6599                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6600                         is_owned: true,
6601                 }
6602         }
6603 }
6604 #[allow(unused)]
6605 /// Used only if an object of this type is returned as a trait impl by a method
6606 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6607         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
6608 }
6609 #[no_mangle]
6610 /// Creates a copy of the ChannelUpdate
6611 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
6612         orig.clone()
6613 }
6614 /// Checks if two ChannelUpdates contain equal inner contents.
6615 /// This ignores pointers and is_owned flags and looks at the values in fields.
6616 /// Two objects with NULL inner values will be considered "equal" here.
6617 #[no_mangle]
6618 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
6619         if a.inner == b.inner { return true; }
6620         if a.inner.is_null() || b.inner.is_null() { return false; }
6621         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6622 }
6623
6624 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
6625 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
6626
6627 /// A [`query_channel_range`] message is used to query a peer for channel
6628 /// UTXOs in a range of blocks. The recipient of a query makes a best
6629 /// effort to reply to the query using one or more [`ReplyChannelRange`]
6630 /// messages.
6631 ///
6632 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6633 #[must_use]
6634 #[repr(C)]
6635 pub struct QueryChannelRange {
6636         /// A pointer to the opaque Rust object.
6637
6638         /// Nearly everywhere, inner must be non-null, however in places where
6639         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6640         pub inner: *mut nativeQueryChannelRange,
6641         /// Indicates that this is the only struct which contains the same pointer.
6642
6643         /// Rust functions which take ownership of an object provided via an argument require
6644         /// this to be true and invalidate the object pointed to by inner.
6645         pub is_owned: bool,
6646 }
6647
6648 impl Drop for QueryChannelRange {
6649         fn drop(&mut self) {
6650                 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
6651                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6652                 }
6653         }
6654 }
6655 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
6656 #[no_mangle]
6657 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
6658 #[allow(unused)]
6659 /// Used only if an object of this type is returned as a trait impl by a method
6660 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
6661         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
6662 }
6663 #[allow(unused)]
6664 impl QueryChannelRange {
6665         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
6666                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6667         }
6668         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
6669                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6670         }
6671         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6672         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
6673                 assert!(self.is_owned);
6674                 let ret = ObjOps::untweak_ptr(self.inner);
6675                 self.inner = core::ptr::null_mut();
6676                 ret
6677         }
6678 }
6679 /// The genesis hash of the blockchain being queried
6680 #[no_mangle]
6681 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
6682         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6683         inner_val.as_inner()
6684 }
6685 /// The genesis hash of the blockchain being queried
6686 #[no_mangle]
6687 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
6688         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6689 }
6690 /// The height of the first block for the channel UTXOs being queried
6691 #[no_mangle]
6692 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
6693         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
6694         *inner_val
6695 }
6696 /// The height of the first block for the channel UTXOs being queried
6697 #[no_mangle]
6698 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
6699         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
6700 }
6701 /// The number of blocks to include in the query results
6702 #[no_mangle]
6703 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
6704         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
6705         *inner_val
6706 }
6707 /// The number of blocks to include in the query results
6708 #[no_mangle]
6709 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
6710         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
6711 }
6712 /// Constructs a new QueryChannelRange given each field
6713 #[must_use]
6714 #[no_mangle]
6715 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 {
6716         QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
6717                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6718                 first_blocknum: first_blocknum_arg,
6719                 number_of_blocks: number_of_blocks_arg,
6720         }), is_owned: true }
6721 }
6722 impl Clone for QueryChannelRange {
6723         fn clone(&self) -> Self {
6724                 Self {
6725                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
6726                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6727                         is_owned: true,
6728                 }
6729         }
6730 }
6731 #[allow(unused)]
6732 /// Used only if an object of this type is returned as a trait impl by a method
6733 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
6734         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
6735 }
6736 #[no_mangle]
6737 /// Creates a copy of the QueryChannelRange
6738 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
6739         orig.clone()
6740 }
6741 /// Checks if two QueryChannelRanges contain equal inner contents.
6742 /// This ignores pointers and is_owned flags and looks at the values in fields.
6743 /// Two objects with NULL inner values will be considered "equal" here.
6744 #[no_mangle]
6745 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
6746         if a.inner == b.inner { return true; }
6747         if a.inner.is_null() || b.inner.is_null() { return false; }
6748         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6749 }
6750
6751 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
6752 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
6753
6754 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
6755 /// message.
6756 ///
6757 /// Multiple `reply_channel_range` messages can be sent in reply
6758 /// to a single [`QueryChannelRange`] message. The query recipient makes a
6759 /// best effort to respond based on their local network view which may
6760 /// not be a perfect view of the network. The `short_channel_id`s in the
6761 /// reply are encoded. We only support `encoding_type=0` uncompressed
6762 /// serialization and do not support `encoding_type=1` zlib serialization.
6763 ///
6764 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6765 #[must_use]
6766 #[repr(C)]
6767 pub struct ReplyChannelRange {
6768         /// A pointer to the opaque Rust object.
6769
6770         /// Nearly everywhere, inner must be non-null, however in places where
6771         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6772         pub inner: *mut nativeReplyChannelRange,
6773         /// Indicates that this is the only struct which contains the same pointer.
6774
6775         /// Rust functions which take ownership of an object provided via an argument require
6776         /// this to be true and invalidate the object pointed to by inner.
6777         pub is_owned: bool,
6778 }
6779
6780 impl Drop for ReplyChannelRange {
6781         fn drop(&mut self) {
6782                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
6783                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6784                 }
6785         }
6786 }
6787 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
6788 #[no_mangle]
6789 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
6790 #[allow(unused)]
6791 /// Used only if an object of this type is returned as a trait impl by a method
6792 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
6793         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
6794 }
6795 #[allow(unused)]
6796 impl ReplyChannelRange {
6797         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
6798                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6799         }
6800         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
6801                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6802         }
6803         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6804         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
6805                 assert!(self.is_owned);
6806                 let ret = ObjOps::untweak_ptr(self.inner);
6807                 self.inner = core::ptr::null_mut();
6808                 ret
6809         }
6810 }
6811 /// The genesis hash of the blockchain being queried
6812 #[no_mangle]
6813 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
6814         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6815         inner_val.as_inner()
6816 }
6817 /// The genesis hash of the blockchain being queried
6818 #[no_mangle]
6819 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
6820         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6821 }
6822 /// The height of the first block in the range of the reply
6823 #[no_mangle]
6824 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
6825         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
6826         *inner_val
6827 }
6828 /// The height of the first block in the range of the reply
6829 #[no_mangle]
6830 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
6831         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
6832 }
6833 /// The number of blocks included in the range of the reply
6834 #[no_mangle]
6835 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
6836         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
6837         *inner_val
6838 }
6839 /// The number of blocks included in the range of the reply
6840 #[no_mangle]
6841 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
6842         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
6843 }
6844 /// True when this is the final reply for a query
6845 #[no_mangle]
6846 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
6847         let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
6848         *inner_val
6849 }
6850 /// True when this is the final reply for a query
6851 #[no_mangle]
6852 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
6853         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
6854 }
6855 /// The `short_channel_id`s in the channel range
6856 ///
6857 /// Returns a copy of the field.
6858 #[no_mangle]
6859 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
6860         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
6861         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6862         local_inner_val.into()
6863 }
6864 /// The `short_channel_id`s in the channel range
6865 #[no_mangle]
6866 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
6867         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6868         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
6869 }
6870 /// Constructs a new ReplyChannelRange given each field
6871 #[must_use]
6872 #[no_mangle]
6873 pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut sync_complete_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange {
6874         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 }); };
6875         ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
6876                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6877                 first_blocknum: first_blocknum_arg,
6878                 number_of_blocks: number_of_blocks_arg,
6879                 sync_complete: sync_complete_arg,
6880                 short_channel_ids: local_short_channel_ids_arg,
6881         }), is_owned: true }
6882 }
6883 impl Clone for ReplyChannelRange {
6884         fn clone(&self) -> Self {
6885                 Self {
6886                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
6887                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6888                         is_owned: true,
6889                 }
6890         }
6891 }
6892 #[allow(unused)]
6893 /// Used only if an object of this type is returned as a trait impl by a method
6894 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
6895         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
6896 }
6897 #[no_mangle]
6898 /// Creates a copy of the ReplyChannelRange
6899 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
6900         orig.clone()
6901 }
6902 /// Checks if two ReplyChannelRanges contain equal inner contents.
6903 /// This ignores pointers and is_owned flags and looks at the values in fields.
6904 /// Two objects with NULL inner values will be considered "equal" here.
6905 #[no_mangle]
6906 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
6907         if a.inner == b.inner { return true; }
6908         if a.inner.is_null() || b.inner.is_null() { return false; }
6909         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6910 }
6911
6912 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
6913 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
6914
6915 /// A [`query_short_channel_ids`] message is used to query a peer for
6916 /// routing gossip messages related to one or more `short_channel_id`s.
6917 ///
6918 /// The query recipient will reply with the latest, if available,
6919 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
6920 /// it maintains for the requested `short_channel_id`s followed by a
6921 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
6922 /// this query are encoded. We only support `encoding_type=0` uncompressed
6923 /// serialization and do not support `encoding_type=1` zlib serialization.
6924 ///
6925 /// [`query_short_channel_ids`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
6926 #[must_use]
6927 #[repr(C)]
6928 pub struct QueryShortChannelIds {
6929         /// A pointer to the opaque Rust object.
6930
6931         /// Nearly everywhere, inner must be non-null, however in places where
6932         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6933         pub inner: *mut nativeQueryShortChannelIds,
6934         /// Indicates that this is the only struct which contains the same pointer.
6935
6936         /// Rust functions which take ownership of an object provided via an argument require
6937         /// this to be true and invalidate the object pointed to by inner.
6938         pub is_owned: bool,
6939 }
6940
6941 impl Drop for QueryShortChannelIds {
6942         fn drop(&mut self) {
6943                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
6944                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6945                 }
6946         }
6947 }
6948 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
6949 #[no_mangle]
6950 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
6951 #[allow(unused)]
6952 /// Used only if an object of this type is returned as a trait impl by a method
6953 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
6954         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
6955 }
6956 #[allow(unused)]
6957 impl QueryShortChannelIds {
6958         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
6959                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6960         }
6961         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
6962                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6963         }
6964         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6965         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
6966                 assert!(self.is_owned);
6967                 let ret = ObjOps::untweak_ptr(self.inner);
6968                 self.inner = core::ptr::null_mut();
6969                 ret
6970         }
6971 }
6972 /// The genesis hash of the blockchain being queried
6973 #[no_mangle]
6974 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
6975         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6976         inner_val.as_inner()
6977 }
6978 /// The genesis hash of the blockchain being queried
6979 #[no_mangle]
6980 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
6981         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6982 }
6983 /// The short_channel_ids that are being queried
6984 ///
6985 /// Returns a copy of the field.
6986 #[no_mangle]
6987 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
6988         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
6989         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6990         local_inner_val.into()
6991 }
6992 /// The short_channel_ids that are being queried
6993 #[no_mangle]
6994 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
6995         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6996         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
6997 }
6998 /// Constructs a new QueryShortChannelIds given each field
6999 #[must_use]
7000 #[no_mangle]
7001 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 {
7002         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 }); };
7003         QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
7004                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7005                 short_channel_ids: local_short_channel_ids_arg,
7006         }), is_owned: true }
7007 }
7008 impl Clone for QueryShortChannelIds {
7009         fn clone(&self) -> Self {
7010                 Self {
7011                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
7012                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7013                         is_owned: true,
7014                 }
7015         }
7016 }
7017 #[allow(unused)]
7018 /// Used only if an object of this type is returned as a trait impl by a method
7019 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
7020         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
7021 }
7022 #[no_mangle]
7023 /// Creates a copy of the QueryShortChannelIds
7024 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
7025         orig.clone()
7026 }
7027 /// Checks if two QueryShortChannelIdss contain equal inner contents.
7028 /// This ignores pointers and is_owned flags and looks at the values in fields.
7029 /// Two objects with NULL inner values will be considered "equal" here.
7030 #[no_mangle]
7031 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
7032         if a.inner == b.inner { return true; }
7033         if a.inner.is_null() || b.inner.is_null() { return false; }
7034         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7035 }
7036
7037 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
7038 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
7039
7040 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
7041 /// message. The query recipient makes a best
7042 /// effort to respond based on their local network view which may not be
7043 /// a perfect view of the network.
7044 ///
7045 /// [`reply_short_channel_ids_end`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
7046 #[must_use]
7047 #[repr(C)]
7048 pub struct ReplyShortChannelIdsEnd {
7049         /// A pointer to the opaque Rust object.
7050
7051         /// Nearly everywhere, inner must be non-null, however in places where
7052         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7053         pub inner: *mut nativeReplyShortChannelIdsEnd,
7054         /// Indicates that this is the only struct which contains the same pointer.
7055
7056         /// Rust functions which take ownership of an object provided via an argument require
7057         /// this to be true and invalidate the object pointed to by inner.
7058         pub is_owned: bool,
7059 }
7060
7061 impl Drop for ReplyShortChannelIdsEnd {
7062         fn drop(&mut self) {
7063                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
7064                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7065                 }
7066         }
7067 }
7068 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
7069 #[no_mangle]
7070 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
7071 #[allow(unused)]
7072 /// Used only if an object of this type is returned as a trait impl by a method
7073 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
7074         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
7075 }
7076 #[allow(unused)]
7077 impl ReplyShortChannelIdsEnd {
7078         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
7079                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7080         }
7081         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
7082                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7083         }
7084         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7085         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
7086                 assert!(self.is_owned);
7087                 let ret = ObjOps::untweak_ptr(self.inner);
7088                 self.inner = core::ptr::null_mut();
7089                 ret
7090         }
7091 }
7092 /// The genesis hash of the blockchain that was queried
7093 #[no_mangle]
7094 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
7095         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7096         inner_val.as_inner()
7097 }
7098 /// The genesis hash of the blockchain that was queried
7099 #[no_mangle]
7100 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
7101         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
7102 }
7103 /// Indicates if the query recipient maintains up-to-date channel
7104 /// information for the `chain_hash`
7105 #[no_mangle]
7106 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
7107         let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
7108         *inner_val
7109 }
7110 /// Indicates if the query recipient maintains up-to-date channel
7111 /// information for the `chain_hash`
7112 #[no_mangle]
7113 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
7114         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
7115 }
7116 /// Constructs a new ReplyShortChannelIdsEnd given each field
7117 #[must_use]
7118 #[no_mangle]
7119 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
7120         ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
7121                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7122                 full_information: full_information_arg,
7123         }), is_owned: true }
7124 }
7125 impl Clone for ReplyShortChannelIdsEnd {
7126         fn clone(&self) -> Self {
7127                 Self {
7128                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
7129                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7130                         is_owned: true,
7131                 }
7132         }
7133 }
7134 #[allow(unused)]
7135 /// Used only if an object of this type is returned as a trait impl by a method
7136 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
7137         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
7138 }
7139 #[no_mangle]
7140 /// Creates a copy of the ReplyShortChannelIdsEnd
7141 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
7142         orig.clone()
7143 }
7144 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
7145 /// This ignores pointers and is_owned flags and looks at the values in fields.
7146 /// Two objects with NULL inner values will be considered "equal" here.
7147 #[no_mangle]
7148 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
7149         if a.inner == b.inner { return true; }
7150         if a.inner.is_null() || b.inner.is_null() { return false; }
7151         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7152 }
7153
7154 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
7155 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
7156
7157 /// A [`gossip_timestamp_filter`] message is used by a node to request
7158 /// gossip relay for messages in the requested time range when the
7159 /// `gossip_queries` feature has been negotiated.
7160 ///
7161 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
7162 #[must_use]
7163 #[repr(C)]
7164 pub struct GossipTimestampFilter {
7165         /// A pointer to the opaque Rust object.
7166
7167         /// Nearly everywhere, inner must be non-null, however in places where
7168         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7169         pub inner: *mut nativeGossipTimestampFilter,
7170         /// Indicates that this is the only struct which contains the same pointer.
7171
7172         /// Rust functions which take ownership of an object provided via an argument require
7173         /// this to be true and invalidate the object pointed to by inner.
7174         pub is_owned: bool,
7175 }
7176
7177 impl Drop for GossipTimestampFilter {
7178         fn drop(&mut self) {
7179                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
7180                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7181                 }
7182         }
7183 }
7184 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
7185 #[no_mangle]
7186 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
7187 #[allow(unused)]
7188 /// Used only if an object of this type is returned as a trait impl by a method
7189 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
7190         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
7191 }
7192 #[allow(unused)]
7193 impl GossipTimestampFilter {
7194         pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
7195                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7196         }
7197         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
7198                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7199         }
7200         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7201         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
7202                 assert!(self.is_owned);
7203                 let ret = ObjOps::untweak_ptr(self.inner);
7204                 self.inner = core::ptr::null_mut();
7205                 ret
7206         }
7207 }
7208 /// The genesis hash of the blockchain for channel and node information
7209 #[no_mangle]
7210 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
7211         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7212         inner_val.as_inner()
7213 }
7214 /// The genesis hash of the blockchain for channel and node information
7215 #[no_mangle]
7216 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
7217         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
7218 }
7219 /// The starting unix timestamp
7220 #[no_mangle]
7221 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
7222         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
7223         *inner_val
7224 }
7225 /// The starting unix timestamp
7226 #[no_mangle]
7227 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7228         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
7229 }
7230 /// The range of information in seconds
7231 #[no_mangle]
7232 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
7233         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
7234         *inner_val
7235 }
7236 /// The range of information in seconds
7237 #[no_mangle]
7238 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7239         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
7240 }
7241 /// Constructs a new GossipTimestampFilter given each field
7242 #[must_use]
7243 #[no_mangle]
7244 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 {
7245         GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
7246                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7247                 first_timestamp: first_timestamp_arg,
7248                 timestamp_range: timestamp_range_arg,
7249         }), is_owned: true }
7250 }
7251 impl Clone for GossipTimestampFilter {
7252         fn clone(&self) -> Self {
7253                 Self {
7254                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
7255                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7256                         is_owned: true,
7257                 }
7258         }
7259 }
7260 #[allow(unused)]
7261 /// Used only if an object of this type is returned as a trait impl by a method
7262 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
7263         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
7264 }
7265 #[no_mangle]
7266 /// Creates a copy of the GossipTimestampFilter
7267 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
7268         orig.clone()
7269 }
7270 /// Checks if two GossipTimestampFilters contain equal inner contents.
7271 /// This ignores pointers and is_owned flags and looks at the values in fields.
7272 /// Two objects with NULL inner values will be considered "equal" here.
7273 #[no_mangle]
7274 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
7275         if a.inner == b.inner { return true; }
7276         if a.inner.is_null() || b.inner.is_null() { return false; }
7277         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7278 }
7279 /// Used to put an error message in a [`LightningError`].
7280 #[derive(Clone)]
7281 #[must_use]
7282 #[repr(C)]
7283 pub enum ErrorAction {
7284         /// The peer took some action which made us think they were useless. Disconnect them.
7285         DisconnectPeer {
7286                 /// An error message which we should make an effort to send before we disconnect.
7287                 ///
7288                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
7289                 msg: crate::lightning::ln::msgs::ErrorMessage,
7290         },
7291         /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
7292         DisconnectPeerWithWarning {
7293                 /// A warning message which we should make an effort to send before we disconnect.
7294                 msg: crate::lightning::ln::msgs::WarningMessage,
7295         },
7296         /// The peer did something harmless that we weren't able to process, just log and ignore
7297         IgnoreError,
7298         /// The peer did something harmless that we weren't able to meaningfully process.
7299         /// If the error is logged, log it at the given level.
7300         IgnoreAndLog(
7301                 crate::lightning::util::logger::Level),
7302         /// The peer provided us with a gossip message which we'd already seen. In most cases this
7303         /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
7304         /// our own channel announcements.
7305         IgnoreDuplicateGossip,
7306         /// The peer did something incorrect. Tell them.
7307         SendErrorMessage {
7308                 /// The message to send.
7309                 msg: crate::lightning::ln::msgs::ErrorMessage,
7310         },
7311         /// The peer did something incorrect. Tell them without closing any channels.
7312         SendWarningMessage {
7313                 /// The message to send.
7314                 msg: crate::lightning::ln::msgs::WarningMessage,
7315                 /// The peer may have done something harmless that we weren't able to meaningfully process,
7316                 /// though we should still tell them about it.
7317                 /// If this event is logged, log it at the given level.
7318                 log_level: crate::lightning::util::logger::Level,
7319         },
7320 }
7321 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
7322 pub(crate) type nativeErrorAction = ErrorActionImport;
7323
7324 impl ErrorAction {
7325         #[allow(unused)]
7326         pub(crate) fn to_native(&self) -> nativeErrorAction {
7327                 match self {
7328                         ErrorAction::DisconnectPeer {ref msg, } => {
7329                                 let mut msg_nonref = Clone::clone(msg);
7330                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
7331                                 nativeErrorAction::DisconnectPeer {
7332                                         msg: local_msg_nonref,
7333                                 }
7334                         },
7335                         ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7336                                 let mut msg_nonref = Clone::clone(msg);
7337                                 nativeErrorAction::DisconnectPeerWithWarning {
7338                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7339                                 }
7340                         },
7341                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7342                         ErrorAction::IgnoreAndLog (ref a, ) => {
7343                                 let mut a_nonref = Clone::clone(a);
7344                                 nativeErrorAction::IgnoreAndLog (
7345                                         a_nonref.into_native(),
7346                                 )
7347                         },
7348                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7349                         ErrorAction::SendErrorMessage {ref msg, } => {
7350                                 let mut msg_nonref = Clone::clone(msg);
7351                                 nativeErrorAction::SendErrorMessage {
7352                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7353                                 }
7354                         },
7355                         ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7356                                 let mut msg_nonref = Clone::clone(msg);
7357                                 let mut log_level_nonref = Clone::clone(log_level);
7358                                 nativeErrorAction::SendWarningMessage {
7359                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7360                                         log_level: log_level_nonref.into_native(),
7361                                 }
7362                         },
7363                 }
7364         }
7365         #[allow(unused)]
7366         pub(crate) fn into_native(self) -> nativeErrorAction {
7367                 match self {
7368                         ErrorAction::DisconnectPeer {mut msg, } => {
7369                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
7370                                 nativeErrorAction::DisconnectPeer {
7371                                         msg: local_msg,
7372                                 }
7373                         },
7374                         ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7375                                 nativeErrorAction::DisconnectPeerWithWarning {
7376                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
7377                                 }
7378                         },
7379                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7380                         ErrorAction::IgnoreAndLog (mut a, ) => {
7381                                 nativeErrorAction::IgnoreAndLog (
7382                                         a.into_native(),
7383                                 )
7384                         },
7385                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7386                         ErrorAction::SendErrorMessage {mut msg, } => {
7387                                 nativeErrorAction::SendErrorMessage {
7388                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
7389                                 }
7390                         },
7391                         ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7392                                 nativeErrorAction::SendWarningMessage {
7393                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
7394                                         log_level: log_level.into_native(),
7395                                 }
7396                         },
7397                 }
7398         }
7399         #[allow(unused)]
7400         pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
7401                 match native {
7402                         nativeErrorAction::DisconnectPeer {ref msg, } => {
7403                                 let mut msg_nonref = Clone::clone(msg);
7404                                 let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true };
7405                                 ErrorAction::DisconnectPeer {
7406                                         msg: local_msg_nonref,
7407                                 }
7408                         },
7409                         nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7410                                 let mut msg_nonref = Clone::clone(msg);
7411                                 ErrorAction::DisconnectPeerWithWarning {
7412                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7413                                 }
7414                         },
7415                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7416                         nativeErrorAction::IgnoreAndLog (ref a, ) => {
7417                                 let mut a_nonref = Clone::clone(a);
7418                                 ErrorAction::IgnoreAndLog (
7419                                         crate::lightning::util::logger::Level::native_into(a_nonref),
7420                                 )
7421                         },
7422                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7423                         nativeErrorAction::SendErrorMessage {ref msg, } => {
7424                                 let mut msg_nonref = Clone::clone(msg);
7425                                 ErrorAction::SendErrorMessage {
7426                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7427                                 }
7428                         },
7429                         nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7430                                 let mut msg_nonref = Clone::clone(msg);
7431                                 let mut log_level_nonref = Clone::clone(log_level);
7432                                 ErrorAction::SendWarningMessage {
7433                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7434                                         log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
7435                                 }
7436                         },
7437                 }
7438         }
7439         #[allow(unused)]
7440         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
7441                 match native {
7442                         nativeErrorAction::DisconnectPeer {mut msg, } => {
7443                                 let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true };
7444                                 ErrorAction::DisconnectPeer {
7445                                         msg: local_msg,
7446                                 }
7447                         },
7448                         nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7449                                 ErrorAction::DisconnectPeerWithWarning {
7450                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7451                                 }
7452                         },
7453                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7454                         nativeErrorAction::IgnoreAndLog (mut a, ) => {
7455                                 ErrorAction::IgnoreAndLog (
7456                                         crate::lightning::util::logger::Level::native_into(a),
7457                                 )
7458                         },
7459                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7460                         nativeErrorAction::SendErrorMessage {mut msg, } => {
7461                                 ErrorAction::SendErrorMessage {
7462                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7463                                 }
7464                         },
7465                         nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7466                                 ErrorAction::SendWarningMessage {
7467                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7468                                         log_level: crate::lightning::util::logger::Level::native_into(log_level),
7469                                 }
7470                         },
7471                 }
7472         }
7473 }
7474 /// Frees any resources used by the ErrorAction
7475 #[no_mangle]
7476 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
7477 /// Creates a copy of the ErrorAction
7478 #[no_mangle]
7479 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
7480         orig.clone()
7481 }
7482 #[no_mangle]
7483 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
7484 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7485         ErrorAction::DisconnectPeer {
7486                 msg,
7487         }
7488 }
7489 #[no_mangle]
7490 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
7491 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
7492         ErrorAction::DisconnectPeerWithWarning {
7493                 msg,
7494         }
7495 }
7496 #[no_mangle]
7497 /// Utility method to constructs a new IgnoreError-variant ErrorAction
7498 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
7499         ErrorAction::IgnoreError}
7500 #[no_mangle]
7501 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
7502 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
7503         ErrorAction::IgnoreAndLog(a, )
7504 }
7505 #[no_mangle]
7506 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
7507 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
7508         ErrorAction::IgnoreDuplicateGossip}
7509 #[no_mangle]
7510 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
7511 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7512         ErrorAction::SendErrorMessage {
7513                 msg,
7514         }
7515 }
7516 #[no_mangle]
7517 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
7518 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
7519         ErrorAction::SendWarningMessage {
7520                 msg,
7521                 log_level,
7522         }
7523 }
7524
7525 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
7526 pub(crate) type nativeLightningError = nativeLightningErrorImport;
7527
7528 /// An Err type for failure to process messages.
7529 #[must_use]
7530 #[repr(C)]
7531 pub struct LightningError {
7532         /// A pointer to the opaque Rust object.
7533
7534         /// Nearly everywhere, inner must be non-null, however in places where
7535         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7536         pub inner: *mut nativeLightningError,
7537         /// Indicates that this is the only struct which contains the same pointer.
7538
7539         /// Rust functions which take ownership of an object provided via an argument require
7540         /// this to be true and invalidate the object pointed to by inner.
7541         pub is_owned: bool,
7542 }
7543
7544 impl Drop for LightningError {
7545         fn drop(&mut self) {
7546                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
7547                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7548                 }
7549         }
7550 }
7551 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
7552 #[no_mangle]
7553 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
7554 #[allow(unused)]
7555 /// Used only if an object of this type is returned as a trait impl by a method
7556 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
7557         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
7558 }
7559 #[allow(unused)]
7560 impl LightningError {
7561         pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
7562                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7563         }
7564         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
7565                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7566         }
7567         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7568         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
7569                 assert!(self.is_owned);
7570                 let ret = ObjOps::untweak_ptr(self.inner);
7571                 self.inner = core::ptr::null_mut();
7572                 ret
7573         }
7574 }
7575 /// A human-readable message describing the error
7576 #[no_mangle]
7577 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
7578         let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
7579         inner_val.as_str().into()
7580 }
7581 /// A human-readable message describing the error
7582 #[no_mangle]
7583 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
7584         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
7585 }
7586 /// The action which should be taken against the offending peer.
7587 #[no_mangle]
7588 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
7589         let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
7590         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
7591 }
7592 /// The action which should be taken against the offending peer.
7593 #[no_mangle]
7594 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
7595         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
7596 }
7597 /// Constructs a new LightningError given each field
7598 #[must_use]
7599 #[no_mangle]
7600 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
7601         LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
7602                 err: err_arg.into_string(),
7603                 action: action_arg.into_native(),
7604         }), is_owned: true }
7605 }
7606 impl Clone for LightningError {
7607         fn clone(&self) -> Self {
7608                 Self {
7609                         inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
7610                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7611                         is_owned: true,
7612                 }
7613         }
7614 }
7615 #[allow(unused)]
7616 /// Used only if an object of this type is returned as a trait impl by a method
7617 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
7618         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
7619 }
7620 #[no_mangle]
7621 /// Creates a copy of the LightningError
7622 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
7623         orig.clone()
7624 }
7625
7626 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
7627 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
7628
7629 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
7630 /// transaction updates if they were pending.
7631 #[must_use]
7632 #[repr(C)]
7633 pub struct CommitmentUpdate {
7634         /// A pointer to the opaque Rust object.
7635
7636         /// Nearly everywhere, inner must be non-null, however in places where
7637         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7638         pub inner: *mut nativeCommitmentUpdate,
7639         /// Indicates that this is the only struct which contains the same pointer.
7640
7641         /// Rust functions which take ownership of an object provided via an argument require
7642         /// this to be true and invalidate the object pointed to by inner.
7643         pub is_owned: bool,
7644 }
7645
7646 impl Drop for CommitmentUpdate {
7647         fn drop(&mut self) {
7648                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
7649                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7650                 }
7651         }
7652 }
7653 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
7654 #[no_mangle]
7655 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
7656 #[allow(unused)]
7657 /// Used only if an object of this type is returned as a trait impl by a method
7658 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
7659         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
7660 }
7661 #[allow(unused)]
7662 impl CommitmentUpdate {
7663         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
7664                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7665         }
7666         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
7667                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7668         }
7669         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7670         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
7671                 assert!(self.is_owned);
7672                 let ret = ObjOps::untweak_ptr(self.inner);
7673                 self.inner = core::ptr::null_mut();
7674                 ret
7675         }
7676 }
7677 /// `update_add_htlc` messages which should be sent
7678 #[no_mangle]
7679 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
7680         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
7681         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false } }); };
7682         local_inner_val.into()
7683 }
7684 /// `update_add_htlc` messages which should be sent
7685 #[no_mangle]
7686 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
7687         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7688         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
7689 }
7690 /// `update_fulfill_htlc` messages which should be sent
7691 #[no_mangle]
7692 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
7693         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
7694         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false } }); };
7695         local_inner_val.into()
7696 }
7697 /// `update_fulfill_htlc` messages which should be sent
7698 #[no_mangle]
7699 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
7700         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7701         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
7702 }
7703 /// `update_fail_htlc` messages which should be sent
7704 #[no_mangle]
7705 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
7706         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
7707         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false } }); };
7708         local_inner_val.into()
7709 }
7710 /// `update_fail_htlc` messages which should be sent
7711 #[no_mangle]
7712 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
7713         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7714         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
7715 }
7716 /// `update_fail_malformed_htlc` messages which should be sent
7717 #[no_mangle]
7718 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
7719         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
7720         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false } }); };
7721         local_inner_val.into()
7722 }
7723 /// `update_fail_malformed_htlc` messages which should be sent
7724 #[no_mangle]
7725 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
7726         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7727         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
7728 }
7729 /// An `update_fee` message which should be sent
7730 ///
7731 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
7732 #[no_mangle]
7733 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
7734         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
7735         let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::UpdateFee<>) as *mut _ }, is_owned: false };
7736         local_inner_val
7737 }
7738 /// An `update_fee` message which should be sent
7739 ///
7740 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
7741 #[no_mangle]
7742 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
7743         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
7744         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
7745 }
7746 /// A `commitment_signed` message which should be sent
7747 #[no_mangle]
7748 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
7749         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
7750         crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false }
7751 }
7752 /// A `commitment_signed` message which should be sent
7753 #[no_mangle]
7754 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
7755         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
7756 }
7757 /// Constructs a new CommitmentUpdate given each field
7758 #[must_use]
7759 #[no_mangle]
7760 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::lightning::ln::msgs::UpdateFee, mut commitment_signed_arg: crate::lightning::ln::msgs::CommitmentSigned) -> CommitmentUpdate {
7761         let mut local_update_add_htlcs_arg = Vec::new(); for mut item in update_add_htlcs_arg.into_rust().drain(..) { local_update_add_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7762         let mut local_update_fulfill_htlcs_arg = Vec::new(); for mut item in update_fulfill_htlcs_arg.into_rust().drain(..) { local_update_fulfill_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7763         let mut local_update_fail_htlcs_arg = Vec::new(); for mut item in update_fail_htlcs_arg.into_rust().drain(..) { local_update_fail_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7764         let mut local_update_fail_malformed_htlcs_arg = Vec::new(); for mut item in update_fail_malformed_htlcs_arg.into_rust().drain(..) { local_update_fail_malformed_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7765         let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_inner()) } }) };
7766         CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
7767                 update_add_htlcs: local_update_add_htlcs_arg,
7768                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
7769                 update_fail_htlcs: local_update_fail_htlcs_arg,
7770                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
7771                 update_fee: local_update_fee_arg,
7772                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
7773         }), is_owned: true }
7774 }
7775 impl Clone for CommitmentUpdate {
7776         fn clone(&self) -> Self {
7777                 Self {
7778                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7779                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7780                         is_owned: true,
7781                 }
7782         }
7783 }
7784 #[allow(unused)]
7785 /// Used only if an object of this type is returned as a trait impl by a method
7786 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7787         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
7788 }
7789 #[no_mangle]
7790 /// Creates a copy of the CommitmentUpdate
7791 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
7792         orig.clone()
7793 }
7794 /// Checks if two CommitmentUpdates contain equal inner contents.
7795 /// This ignores pointers and is_owned flags and looks at the values in fields.
7796 /// Two objects with NULL inner values will be considered "equal" here.
7797 #[no_mangle]
7798 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
7799         if a.inner == b.inner { return true; }
7800         if a.inner.is_null() || b.inner.is_null() { return false; }
7801         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7802 }
7803 /// A trait to describe an object which can receive channel messages.
7804 ///
7805 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
7806 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
7807 #[repr(C)]
7808 pub struct ChannelMessageHandler {
7809         /// An opaque pointer which is passed to your function implementations as an argument.
7810         /// This has no meaning in the LDK, and can be NULL or any other value.
7811         pub this_arg: *mut c_void,
7812         /// Handle an incoming `open_channel` message from the given peer.
7813         pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel),
7814         /// Handle an incoming `open_channel2` message from the given peer.
7815         pub handle_open_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2),
7816         /// Handle an incoming `accept_channel` message from the given peer.
7817         pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel),
7818         /// Handle an incoming `accept_channel2` message from the given peer.
7819         pub handle_accept_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2),
7820         /// Handle an incoming `funding_created` message from the given peer.
7821         pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated),
7822         /// Handle an incoming `funding_signed` message from the given peer.
7823         pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned),
7824         /// Handle an incoming `channel_ready` message from the given peer.
7825         pub handle_channel_ready: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady),
7826         /// Handle an incoming `shutdown` message from the given peer.
7827         pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
7828         /// Handle an incoming `closing_signed` message from the given peer.
7829         pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned),
7830         /// Handle an incoming `tx_add_input message` from the given peer.
7831         pub handle_tx_add_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput),
7832         /// Handle an incoming `tx_add_output` message from the given peer.
7833         pub handle_tx_add_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput),
7834         /// Handle an incoming `tx_remove_input` message from the given peer.
7835         pub handle_tx_remove_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput),
7836         /// Handle an incoming `tx_remove_output` message from the given peer.
7837         pub handle_tx_remove_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput),
7838         /// Handle an incoming `tx_complete message` from the given peer.
7839         pub handle_tx_complete: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete),
7840         /// Handle an incoming `tx_signatures` message from the given peer.
7841         pub handle_tx_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures),
7842         /// Handle an incoming `tx_init_rbf` message from the given peer.
7843         pub handle_tx_init_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf),
7844         /// Handle an incoming `tx_ack_rbf` message from the given peer.
7845         pub handle_tx_ack_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf),
7846         /// Handle an incoming `tx_abort message` from the given peer.
7847         pub handle_tx_abort: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort),
7848         /// Handle an incoming `update_add_htlc` message from the given peer.
7849         pub handle_update_add_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC),
7850         /// Handle an incoming `update_fulfill_htlc` message from the given peer.
7851         pub handle_update_fulfill_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC),
7852         /// Handle an incoming `update_fail_htlc` message from the given peer.
7853         pub handle_update_fail_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC),
7854         /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
7855         pub handle_update_fail_malformed_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC),
7856         /// Handle an incoming `commitment_signed` message from the given peer.
7857         pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned),
7858         /// Handle an incoming `revoke_and_ack` message from the given peer.
7859         pub handle_revoke_and_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK),
7860         /// Handle an incoming `update_fee` message from the given peer.
7861         pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee),
7862         /// Handle an incoming `announcement_signatures` message from the given peer.
7863         pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures),
7864         /// Indicates a connection to the peer failed/an existing connection was lost.
7865         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
7866         /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
7867         ///
7868         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
7869         /// with us. Implementors should be somewhat conservative about doing so, however, as other
7870         /// message handlers may still wish to communicate with this peer.
7871         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
7872         /// Handle an incoming `channel_reestablish` message from the given peer.
7873         pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish),
7874         /// Handle an incoming `channel_update` message from the given peer.
7875         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate),
7876         /// Handle an incoming `error` message from the given peer.
7877         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
7878         /// Gets the node feature flags which this handler itself supports. All available handlers are
7879         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
7880         /// which are broadcasted in our [`NodeAnnouncement`] message.
7881         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
7882         /// Gets the init feature flags which should be sent to the given peer. All available handlers
7883         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
7884         /// which are sent in our [`Init`] message.
7885         ///
7886         /// Note that this method is called before [`Self::peer_connected`].
7887         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
7888         /// Gets the genesis hashes for this `ChannelMessageHandler` indicating which chains it supports.
7889         ///
7890         /// If it's `None`, then no particular network chain hash compatibility will be enforced when
7891         /// connecting to peers.
7892         pub get_genesis_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ChainHashZZ,
7893         /// Implementation of MessageSendEventsProvider for this object.
7894         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
7895         /// Frees any resources associated with this object given its this_arg pointer.
7896         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
7897         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
7898 }
7899 unsafe impl Send for ChannelMessageHandler {}
7900 unsafe impl Sync for ChannelMessageHandler {}
7901 #[no_mangle]
7902 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
7903         ChannelMessageHandler {
7904                 this_arg: orig.this_arg,
7905                 handle_open_channel: Clone::clone(&orig.handle_open_channel),
7906                 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
7907                 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
7908                 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
7909                 handle_funding_created: Clone::clone(&orig.handle_funding_created),
7910                 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
7911                 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
7912                 handle_shutdown: Clone::clone(&orig.handle_shutdown),
7913                 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
7914                 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
7915                 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
7916                 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
7917                 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
7918                 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
7919                 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
7920                 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
7921                 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
7922                 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
7923                 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
7924                 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
7925                 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
7926                 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
7927                 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
7928                 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
7929                 handle_update_fee: Clone::clone(&orig.handle_update_fee),
7930                 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
7931                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
7932                 peer_connected: Clone::clone(&orig.peer_connected),
7933                 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
7934                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
7935                 handle_error: Clone::clone(&orig.handle_error),
7936                 provided_node_features: Clone::clone(&orig.provided_node_features),
7937                 provided_init_features: Clone::clone(&orig.provided_init_features),
7938                 get_genesis_hashes: Clone::clone(&orig.get_genesis_hashes),
7939                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
7940                 free: Clone::clone(&orig.free),
7941         }
7942 }
7943 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
7944         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
7945                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
7946                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
7947                 local_ret
7948         }
7949 }
7950
7951 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
7952 impl rustChannelMessageHandler for ChannelMessageHandler {
7953         fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
7954                 (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false })
7955         }
7956         fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
7957                 (self.handle_open_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannelV2<>) as *mut _) }, is_owned: false })
7958         }
7959         fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
7960                 (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false })
7961         }
7962         fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
7963                 (self.handle_accept_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannelV2<>) as *mut _) }, is_owned: false })
7964         }
7965         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
7966                 (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingCreated<>) as *mut _) }, is_owned: false })
7967         }
7968         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
7969                 (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingSigned<>) as *mut _) }, is_owned: false })
7970         }
7971         fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
7972                 (self.handle_channel_ready)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReady { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReady<>) as *mut _) }, is_owned: false })
7973         }
7974         fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
7975                 (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false })
7976         }
7977         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
7978                 (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ClosingSigned<>) as *mut _) }, is_owned: false })
7979         }
7980         fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
7981                 (self.handle_tx_add_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddInput<>) as *mut _) }, is_owned: false })
7982         }
7983         fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
7984                 (self.handle_tx_add_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddOutput<>) as *mut _) }, is_owned: false })
7985         }
7986         fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
7987                 (self.handle_tx_remove_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveInput<>) as *mut _) }, is_owned: false })
7988         }
7989         fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
7990                 (self.handle_tx_remove_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveOutput<>) as *mut _) }, is_owned: false })
7991         }
7992         fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
7993                 (self.handle_tx_complete)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxComplete { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxComplete<>) as *mut _) }, is_owned: false })
7994         }
7995         fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
7996                 (self.handle_tx_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxSignatures<>) as *mut _) }, is_owned: false })
7997         }
7998         fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
7999                 (self.handle_tx_init_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxInitRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxInitRbf<>) as *mut _) }, is_owned: false })
8000         }
8001         fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
8002                 (self.handle_tx_ack_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAckRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAckRbf<>) as *mut _) }, is_owned: false })
8003         }
8004         fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
8005                 (self.handle_tx_abort)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAbort { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAbort<>) as *mut _) }, is_owned: false })
8006         }
8007         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
8008                 (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false })
8009         }
8010         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
8011                 (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false })
8012         }
8013         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
8014                 (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false })
8015         }
8016         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
8017                 (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false })
8018         }
8019         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
8020                 (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false })
8021         }
8022         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
8023                 (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::RevokeAndACK<>) as *mut _) }, is_owned: false })
8024         }
8025         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
8026                 (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFee<>) as *mut _) }, is_owned: false })
8027         }
8028         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
8029                 (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AnnouncementSignatures<>) as *mut _) }, is_owned: false })
8030         }
8031         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8032                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8033         }
8034         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8035                 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
8036                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
8037                 local_ret
8038         }
8039         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
8040                 (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReestablish<>) as *mut _) }, is_owned: false })
8041         }
8042         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
8043                 (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false })
8044         }
8045         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
8046                 (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false })
8047         }
8048         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8049                 let mut ret = (self.provided_node_features)(self.this_arg);
8050                 *unsafe { Box::from_raw(ret.take_inner()) }
8051         }
8052         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8053                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8054                 *unsafe { Box::from_raw(ret.take_inner()) }
8055         }
8056         fn get_genesis_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
8057                 let mut ret = (self.get_genesis_hashes)(self.this_arg);
8058                 let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { let mut local_ret_0 = Vec::new(); for mut item in { ret_opt.take() }.into_rust().drain(..) { local_ret_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_ret_0 }})} };
8059                 local_ret
8060         }
8061 }
8062
8063 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8064 // directly as a Deref trait in higher-level structs:
8065 impl core::ops::Deref for ChannelMessageHandler {
8066         type Target = Self;
8067         fn deref(&self) -> &Self {
8068                 self
8069         }
8070 }
8071 /// Calls the free function if one is set
8072 #[no_mangle]
8073 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
8074 impl Drop for ChannelMessageHandler {
8075         fn drop(&mut self) {
8076                 if let Some(f) = self.free {
8077                         f(self.this_arg);
8078                 }
8079         }
8080 }
8081 /// A trait to describe an object which can receive routing messages.
8082 ///
8083 /// # Implementor DoS Warnings
8084 ///
8085 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
8086 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
8087 /// repeated disk I/O for queries accessing different parts of the network graph.
8088 #[repr(C)]
8089 pub struct RoutingMessageHandler {
8090         /// An opaque pointer which is passed to your function implementations as an argument.
8091         /// This has no meaning in the LDK, and can be NULL or any other value.
8092         pub this_arg: *mut c_void,
8093         /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
8094         /// `false` or returning an `Err` otherwise.
8095         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8096         /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
8097         /// or returning an `Err` otherwise.
8098         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8099         /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
8100         /// `false` or returning an `Err` otherwise.
8101         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8102         /// Gets channel announcements and updates required to dump our routing table to a remote node,
8103         /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
8104         /// for a single channel.
8105         pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
8106         /// Gets a node announcement required to dump our routing table to a remote node, starting at
8107         /// the node *after* the provided pubkey and including up to one announcement immediately
8108         /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
8109         /// If `None` is provided for `starting_point`, we start at the first node.
8110         ///
8111         /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
8112         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
8113         pub get_next_node_announcement: extern "C" fn (this_arg: *const c_void, starting_point: crate::lightning::routing::gossip::NodeId) -> crate::lightning::ln::msgs::NodeAnnouncement,
8114         /// Called when a connection is established with a peer. This can be used to
8115         /// perform routing table synchronization using a strategy defined by the
8116         /// implementor.
8117         ///
8118         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8119         /// with us. Implementors should be somewhat conservative about doing so, however, as other
8120         /// message handlers may still wish to communicate with this peer.
8121         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
8122         /// Handles the reply of a query we initiated to learn about channels
8123         /// for a given range of blocks. We can expect to receive one or more
8124         /// replies to a single query.
8125         pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
8126         /// Handles the reply of a query we initiated asking for routing gossip
8127         /// messages for a list of channels. We should receive this message when
8128         /// a node has completed its best effort to send us the pertaining routing
8129         /// gossip messages.
8130         pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
8131         /// Handles when a peer asks us to send a list of `short_channel_id`s
8132         /// for the requested range of blocks.
8133         pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
8134         /// Handles when a peer asks us to send routing gossip messages for a
8135         /// list of `short_channel_id`s.
8136         pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
8137         /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
8138         /// pending some async action. While there is no guarantee of the rate of future messages, the
8139         /// caller should seek to reduce the rate of new gossip messages handled, especially
8140         /// [`ChannelAnnouncement`]s.
8141         pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
8142         /// Gets the node feature flags which this handler itself supports. All available handlers are
8143         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8144         /// which are broadcasted in our [`NodeAnnouncement`] message.
8145         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8146         /// Gets the init feature flags which should be sent to the given peer. All available handlers
8147         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8148         /// which are sent in our [`Init`] message.
8149         ///
8150         /// Note that this method is called before [`Self::peer_connected`].
8151         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8152         /// Implementation of MessageSendEventsProvider for this object.
8153         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
8154         /// Frees any resources associated with this object given its this_arg pointer.
8155         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8156         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8157 }
8158 unsafe impl Send for RoutingMessageHandler {}
8159 unsafe impl Sync for RoutingMessageHandler {}
8160 #[no_mangle]
8161 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
8162         RoutingMessageHandler {
8163                 this_arg: orig.this_arg,
8164                 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
8165                 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
8166                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
8167                 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
8168                 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
8169                 peer_connected: Clone::clone(&orig.peer_connected),
8170                 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
8171                 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
8172                 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
8173                 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
8174                 processing_queue_high: Clone::clone(&orig.processing_queue_high),
8175                 provided_node_features: Clone::clone(&orig.provided_node_features),
8176                 provided_init_features: Clone::clone(&orig.provided_init_features),
8177                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
8178                 free: Clone::clone(&orig.free),
8179         }
8180 }
8181 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
8182         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
8183                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
8184                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
8185                 local_ret
8186         }
8187 }
8188
8189 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
8190 impl rustRoutingMessageHandler for RoutingMessageHandler {
8191         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8192                 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _) }, is_owned: false });
8193                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
8194                 local_ret
8195         }
8196         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8197                 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelAnnouncement<>) as *mut _) }, is_owned: false });
8198                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
8199                 local_ret
8200         }
8201         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
8202                 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false });
8203                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
8204                 local_ret
8205         }
8206         fn get_next_channel_announcement(&self, mut starting_point: u64) -> Option<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
8207                 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
8208                 let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = ret.take().to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }) } else { None };
8209                 local_ret
8210         }
8211         fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
8212                 let mut local_starting_point = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if starting_point.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (starting_point.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false };
8213                 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
8214                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8215                 local_ret
8216         }
8217         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8218                 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
8219                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
8220                 local_ret
8221         }
8222         fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8223                 let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true });
8224                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
8225                 local_ret
8226         }
8227         fn handle_reply_short_channel_ids_end(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> {
8228                 let mut ret = (self.handle_reply_short_channel_ids_end)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(msg), is_owned: true });
8229                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
8230                 local_ret
8231         }
8232         fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8233                 let mut ret = (self.handle_query_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true });
8234                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
8235                 local_ret
8236         }
8237         fn handle_query_short_channel_ids(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
8238                 let mut ret = (self.handle_query_short_channel_ids)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true });
8239                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
8240                 local_ret
8241         }
8242         fn processing_queue_high(&self) -> bool {
8243                 let mut ret = (self.processing_queue_high)(self.this_arg);
8244                 ret
8245         }
8246         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8247                 let mut ret = (self.provided_node_features)(self.this_arg);
8248                 *unsafe { Box::from_raw(ret.take_inner()) }
8249         }
8250         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8251                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8252                 *unsafe { Box::from_raw(ret.take_inner()) }
8253         }
8254 }
8255
8256 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8257 // directly as a Deref trait in higher-level structs:
8258 impl core::ops::Deref for RoutingMessageHandler {
8259         type Target = Self;
8260         fn deref(&self) -> &Self {
8261                 self
8262         }
8263 }
8264 /// Calls the free function if one is set
8265 #[no_mangle]
8266 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
8267 impl Drop for RoutingMessageHandler {
8268         fn drop(&mut self) {
8269                 if let Some(f) = self.free {
8270                         f(self.this_arg);
8271                 }
8272         }
8273 }
8274 /// A trait to describe an object that can receive onion messages.
8275 #[repr(C)]
8276 pub struct OnionMessageHandler {
8277         /// An opaque pointer which is passed to your function implementations as an argument.
8278         /// This has no meaning in the LDK, and can be NULL or any other value.
8279         pub this_arg: *mut c_void,
8280         /// Handle an incoming `onion_message` message from the given peer.
8281         pub handle_onion_message: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage),
8282         /// Called when a connection is established with a peer. Can be used to track which peers
8283         /// advertise onion message support and are online.
8284         ///
8285         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8286         /// with us. Implementors should be somewhat conservative about doing so, however, as other
8287         /// message handlers may still wish to communicate with this peer.
8288         pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
8289         /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
8290         /// drop and refuse to forward onion messages to this peer.
8291         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
8292         /// Gets the node feature flags which this handler itself supports. All available handlers are
8293         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8294         /// which are broadcasted in our [`NodeAnnouncement`] message.
8295         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8296         /// Gets the init feature flags which should be sent to the given peer. All available handlers
8297         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8298         /// which are sent in our [`Init`] message.
8299         ///
8300         /// Note that this method is called before [`Self::peer_connected`].
8301         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8302         /// Implementation of OnionMessageProvider for this object.
8303         pub OnionMessageProvider: crate::lightning::events::OnionMessageProvider,
8304         /// Frees any resources associated with this object given its this_arg pointer.
8305         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8306         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8307 }
8308 unsafe impl Send for OnionMessageHandler {}
8309 unsafe impl Sync for OnionMessageHandler {}
8310 #[no_mangle]
8311 pub(crate) extern "C" fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
8312         OnionMessageHandler {
8313                 this_arg: orig.this_arg,
8314                 handle_onion_message: Clone::clone(&orig.handle_onion_message),
8315                 peer_connected: Clone::clone(&orig.peer_connected),
8316                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
8317                 provided_node_features: Clone::clone(&orig.provided_node_features),
8318                 provided_init_features: Clone::clone(&orig.provided_init_features),
8319                 OnionMessageProvider: crate::lightning::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider),
8320                 free: Clone::clone(&orig.free),
8321         }
8322 }
8323 impl lightning::events::OnionMessageProvider for OnionMessageHandler {
8324         fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
8325                 let mut ret = (self.OnionMessageProvider.next_onion_message_for_peer)(self.OnionMessageProvider.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
8326                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8327                 local_ret
8328         }
8329 }
8330
8331 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
8332 impl rustOnionMessageHandler for OnionMessageHandler {
8333         fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
8334                 (self.handle_onion_message)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id), &crate::lightning::ln::msgs::OnionMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OnionMessage<>) as *mut _) }, is_owned: false })
8335         }
8336         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8337                 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
8338                 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
8339                 local_ret
8340         }
8341         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8342                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8343         }
8344         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8345                 let mut ret = (self.provided_node_features)(self.this_arg);
8346                 *unsafe { Box::from_raw(ret.take_inner()) }
8347         }
8348         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8349                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8350                 *unsafe { Box::from_raw(ret.take_inner()) }
8351         }
8352 }
8353
8354 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8355 // directly as a Deref trait in higher-level structs:
8356 impl core::ops::Deref for OnionMessageHandler {
8357         type Target = Self;
8358         fn deref(&self) -> &Self {
8359                 self
8360         }
8361 }
8362 /// Calls the free function if one is set
8363 #[no_mangle]
8364 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
8365 impl Drop for OnionMessageHandler {
8366         fn drop(&mut self) {
8367                 if let Some(f) = self.free {
8368                         f(self.this_arg);
8369                 }
8370         }
8371 }
8372 mod fuzzy_internal_msgs {
8373
8374 use alloc::str::FromStr;
8375 use core::ffi::c_void;
8376 use core::convert::Infallible;
8377 use bitcoin::hashes::Hash;
8378 use crate::c_types::*;
8379 #[cfg(feature="no-std")]
8380 use alloc::{vec::Vec, boxed::Box};
8381
8382 }
8383 #[no_mangle]
8384 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
8385 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
8386         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8387 }
8388 #[no_mangle]
8389 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8390         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
8391 }
8392 #[no_mangle]
8393 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
8394 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
8395         let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8396         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8397         local_res
8398 }
8399 #[no_mangle]
8400 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
8401 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
8402         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8403 }
8404 #[no_mangle]
8405 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8406         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
8407 }
8408 #[no_mangle]
8409 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
8410 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
8411         let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8412         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8413         local_res
8414 }
8415 #[no_mangle]
8416 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
8417 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
8418         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8419 }
8420 #[no_mangle]
8421 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8422         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
8423 }
8424 #[no_mangle]
8425 /// Read a TxAddInput from a byte array, created by TxAddInput_write
8426 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
8427         let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8428         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8429         local_res
8430 }
8431 #[no_mangle]
8432 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
8433 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
8434         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8435 }
8436 #[no_mangle]
8437 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8438         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
8439 }
8440 #[no_mangle]
8441 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
8442 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
8443         let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8444         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8445         local_res
8446 }
8447 #[no_mangle]
8448 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
8449 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
8450         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8451 }
8452 #[no_mangle]
8453 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8454         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
8455 }
8456 #[no_mangle]
8457 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
8458 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
8459         let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8460         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8461         local_res
8462 }
8463 #[no_mangle]
8464 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
8465 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
8466         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8467 }
8468 #[no_mangle]
8469 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8470         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
8471 }
8472 #[no_mangle]
8473 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
8474 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
8475         let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8476         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8477         local_res
8478 }
8479 #[no_mangle]
8480 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
8481 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
8482         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8483 }
8484 #[no_mangle]
8485 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8486         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
8487 }
8488 #[no_mangle]
8489 /// Read a TxComplete from a byte array, created by TxComplete_write
8490 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
8491         let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8492         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8493         local_res
8494 }
8495 #[no_mangle]
8496 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
8497 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
8498         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8499 }
8500 #[no_mangle]
8501 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8502         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
8503 }
8504 #[no_mangle]
8505 /// Read a TxSignatures from a byte array, created by TxSignatures_write
8506 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
8507         let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8508         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8509         local_res
8510 }
8511 #[no_mangle]
8512 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
8513 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
8514         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8515 }
8516 #[no_mangle]
8517 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8518         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
8519 }
8520 #[no_mangle]
8521 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
8522 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
8523         let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8524         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8525         local_res
8526 }
8527 #[no_mangle]
8528 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
8529 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
8530         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8531 }
8532 #[no_mangle]
8533 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8534         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
8535 }
8536 #[no_mangle]
8537 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
8538 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
8539         let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8540         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8541         local_res
8542 }
8543 #[no_mangle]
8544 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
8545 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
8546         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8547 }
8548 #[no_mangle]
8549 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8550         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
8551 }
8552 #[no_mangle]
8553 /// Read a TxAbort from a byte array, created by TxAbort_write
8554 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
8555         let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8556         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8557         local_res
8558 }
8559 #[no_mangle]
8560 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
8561 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
8562         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8563 }
8564 #[no_mangle]
8565 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8566         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
8567 }
8568 #[no_mangle]
8569 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
8570 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
8571         let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8572         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8573         local_res
8574 }
8575 #[no_mangle]
8576 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
8577 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
8578         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8579 }
8580 #[no_mangle]
8581 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8582         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
8583 }
8584 #[no_mangle]
8585 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
8586 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
8587         let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8588         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8589         local_res
8590 }
8591 #[no_mangle]
8592 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
8593 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
8594         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8595 }
8596 #[no_mangle]
8597 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8598         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
8599 }
8600 #[no_mangle]
8601 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
8602 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
8603         let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8604         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8605         local_res
8606 }
8607 #[no_mangle]
8608 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
8609 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
8610         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8611 }
8612 #[no_mangle]
8613 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8614         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
8615 }
8616 #[no_mangle]
8617 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
8618 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
8619         let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8620         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8621         local_res
8622 }
8623 #[no_mangle]
8624 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
8625 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
8626         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8627 }
8628 #[no_mangle]
8629 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8630         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
8631 }
8632 #[no_mangle]
8633 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
8634 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
8635         let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8636         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::CommitmentSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8637         local_res
8638 }
8639 #[no_mangle]
8640 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
8641 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
8642         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8643 }
8644 #[no_mangle]
8645 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8646         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
8647 }
8648 #[no_mangle]
8649 /// Read a FundingCreated from a byte array, created by FundingCreated_write
8650 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
8651         let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8652         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8653         local_res
8654 }
8655 #[no_mangle]
8656 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
8657 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
8658         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8659 }
8660 #[no_mangle]
8661 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8662         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
8663 }
8664 #[no_mangle]
8665 /// Read a FundingSigned from a byte array, created by FundingSigned_write
8666 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
8667         let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8668         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8669         local_res
8670 }
8671 #[no_mangle]
8672 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
8673 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
8674         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8675 }
8676 #[no_mangle]
8677 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8678         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
8679 }
8680 #[no_mangle]
8681 /// Read a ChannelReady from a byte array, created by ChannelReady_write
8682 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
8683         let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8684         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8685         local_res
8686 }
8687 #[no_mangle]
8688 /// Serialize the Init object into a byte array which can be read by Init_read
8689 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
8690         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8691 }
8692 #[no_mangle]
8693 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8694         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
8695 }
8696 #[no_mangle]
8697 /// Read a Init from a byte array, created by Init_write
8698 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
8699         let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8700         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Init { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8701         local_res
8702 }
8703 #[no_mangle]
8704 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
8705 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
8706         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8707 }
8708 #[no_mangle]
8709 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8710         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
8711 }
8712 #[no_mangle]
8713 /// Read a OpenChannel from a byte array, created by OpenChannel_write
8714 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
8715         let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8716         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8717         local_res
8718 }
8719 #[no_mangle]
8720 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
8721 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
8722         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8723 }
8724 #[no_mangle]
8725 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8726         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
8727 }
8728 #[no_mangle]
8729 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
8730 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
8731         let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8732         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8733         local_res
8734 }
8735 #[no_mangle]
8736 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
8737 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
8738         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8739 }
8740 #[no_mangle]
8741 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8742         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
8743 }
8744 #[no_mangle]
8745 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
8746 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
8747         let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8748         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8749         local_res
8750 }
8751 #[no_mangle]
8752 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
8753 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
8754         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8755 }
8756 #[no_mangle]
8757 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8758         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
8759 }
8760 #[no_mangle]
8761 /// Read a Shutdown from a byte array, created by Shutdown_write
8762 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
8763         let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8764         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8765         local_res
8766 }
8767 #[no_mangle]
8768 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
8769 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
8770         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8771 }
8772 #[no_mangle]
8773 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8774         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
8775 }
8776 #[no_mangle]
8777 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
8778 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
8779         let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8780         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8781         local_res
8782 }
8783 #[no_mangle]
8784 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
8785 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
8786         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8787 }
8788 #[no_mangle]
8789 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8790         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
8791 }
8792 #[no_mangle]
8793 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
8794 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
8795         let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8796         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8797         local_res
8798 }
8799 #[no_mangle]
8800 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
8801 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
8802         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8803 }
8804 #[no_mangle]
8805 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8806         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
8807 }
8808 #[no_mangle]
8809 /// Read a UpdateFee from a byte array, created by UpdateFee_write
8810 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
8811         let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8812         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFee { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8813         local_res
8814 }
8815 #[no_mangle]
8816 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
8817 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
8818         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8819 }
8820 #[no_mangle]
8821 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8822         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
8823 }
8824 #[no_mangle]
8825 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
8826 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
8827         let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8828         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8829         local_res
8830 }
8831 #[no_mangle]
8832 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
8833 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
8834         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8835 }
8836 #[no_mangle]
8837 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8838         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
8839 }
8840 #[no_mangle]
8841 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
8842 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
8843         let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8844         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8845         local_res
8846 }
8847 #[no_mangle]
8848 /// Read a OnionMessage from a byte array, created by OnionMessage_write
8849 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
8850         let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8851         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8852         local_res
8853 }
8854 #[no_mangle]
8855 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
8856 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
8857         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8858 }
8859 #[no_mangle]
8860 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8861         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
8862 }
8863 #[no_mangle]
8864 /// Serialize the Ping object into a byte array which can be read by Ping_read
8865 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
8866         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8867 }
8868 #[no_mangle]
8869 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8870         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
8871 }
8872 #[no_mangle]
8873 /// Read a Ping from a byte array, created by Ping_write
8874 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
8875         let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8876         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Ping { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8877         local_res
8878 }
8879 #[no_mangle]
8880 /// Serialize the Pong object into a byte array which can be read by Pong_read
8881 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
8882         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8883 }
8884 #[no_mangle]
8885 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8886         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
8887 }
8888 #[no_mangle]
8889 /// Read a Pong from a byte array, created by Pong_write
8890 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
8891         let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8892         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Pong { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8893         local_res
8894 }
8895 #[no_mangle]
8896 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
8897 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
8898         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8899 }
8900 #[no_mangle]
8901 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8902         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
8903 }
8904 #[no_mangle]
8905 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
8906 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
8907         let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8908         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8909         local_res
8910 }
8911 #[no_mangle]
8912 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
8913 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
8914         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8915 }
8916 #[no_mangle]
8917 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8918         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
8919 }
8920 #[no_mangle]
8921 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
8922 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
8923         let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8924         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8925         local_res
8926 }
8927 #[no_mangle]
8928 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
8929 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
8930         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8931 }
8932 #[no_mangle]
8933 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8934         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
8935 }
8936 #[no_mangle]
8937 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
8938 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
8939         let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8940         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8941         local_res
8942 }
8943 #[no_mangle]
8944 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
8945 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
8946         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8947 }
8948 #[no_mangle]
8949 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8950         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
8951 }
8952 #[no_mangle]
8953 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
8954 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
8955         let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8956         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8957         local_res
8958 }
8959 #[no_mangle]
8960 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
8961 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
8962         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8963 }
8964 #[no_mangle]
8965 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8966         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
8967 }
8968 #[no_mangle]
8969 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
8970 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
8971         let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8972         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8973         local_res
8974 }
8975 #[no_mangle]
8976 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
8977 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
8978         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8979 }
8980 #[no_mangle]
8981 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8982         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
8983 }
8984 #[no_mangle]
8985 /// Read a WarningMessage from a byte array, created by WarningMessage_write
8986 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
8987         let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8988         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8989         local_res
8990 }
8991 #[no_mangle]
8992 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
8993 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
8994         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8995 }
8996 #[no_mangle]
8997 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8998         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
8999 }
9000 #[no_mangle]
9001 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
9002 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
9003         let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9004         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
9005         local_res
9006 }
9007 #[no_mangle]
9008 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
9009 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9010         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9011 }
9012 #[no_mangle]
9013 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9014         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
9015 }
9016 #[no_mangle]
9017 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
9018 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
9019         let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9020         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
9021         local_res
9022 }
9023 #[no_mangle]
9024 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
9025 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
9026         let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9027         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
9028         local_res
9029 }
9030 #[no_mangle]
9031 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
9032 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
9033         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9034 }
9035 #[no_mangle]
9036 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9037         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
9038 }
9039 #[no_mangle]
9040 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
9041 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
9042         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9043 }
9044 #[no_mangle]
9045 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9046         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
9047 }
9048 #[no_mangle]
9049 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
9050 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
9051         let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9052         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
9053         local_res
9054 }
9055 /// Calculates the overflow safe ending block height for the query.
9056 ///
9057 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
9058 #[must_use]
9059 #[no_mangle]
9060 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
9061         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
9062         ret
9063 }
9064
9065 #[no_mangle]
9066 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
9067 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
9068         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9069 }
9070 #[no_mangle]
9071 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9072         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
9073 }
9074 #[no_mangle]
9075 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
9076 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
9077         let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9078         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
9079         local_res
9080 }
9081 #[no_mangle]
9082 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
9083 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
9084         let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9085         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
9086         local_res
9087 }
9088 #[no_mangle]
9089 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
9090 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
9091         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9092 }
9093 #[no_mangle]
9094 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9095         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
9096 }
9097 #[no_mangle]
9098 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
9099 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
9100         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9101 }
9102 #[no_mangle]
9103 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9104         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
9105 }
9106 #[no_mangle]
9107 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
9108 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
9109         let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9110         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
9111         local_res
9112 }