a28511b59a27c1e8a076ca07f84c449e01fc61f2
[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 alloc::string::String;
28 use core::ffi::c_void;
29 use core::convert::Infallible;
30 use bitcoin::hashes::Hash;
31 use crate::c_types::*;
32 #[cfg(feature="no-std")]
33 use alloc::{vec::Vec, boxed::Box};
34
35 /// An error in decoding a message or struct.
36 #[derive(Clone)]
37 #[must_use]
38 #[repr(C)]
39 pub enum DecodeError {
40         /// A version byte specified something we don't know how to handle.
41         ///
42         /// Includes unknown realm byte in an onion hop data packet.
43         UnknownVersion,
44         /// Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type)
45         UnknownRequiredFeature,
46         /// Value was invalid.
47         ///
48         /// For example, a byte which was supposed to be a bool was something other than a 0
49         /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
50         /// syntactically incorrect, etc.
51         InvalidValue,
52         /// The buffer to be read was too short.
53         ShortRead,
54         /// A length descriptor in the packet didn't describe the later data correctly.
55         BadLengthDescriptor,
56         /// Error from [`std::io`].
57         Io(
58                 crate::c_types::IOError),
59         /// The message included zlib-compressed values, which we don't support.
60         UnsupportedCompression,
61 }
62 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
63 pub(crate) type nativeDecodeError = DecodeErrorImport;
64
65 impl DecodeError {
66         #[allow(unused)]
67         pub(crate) fn to_native(&self) -> nativeDecodeError {
68                 match self {
69                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
70                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
71                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
72                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
73                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
74                         DecodeError::Io (ref a, ) => {
75                                 let mut a_nonref = Clone::clone(a);
76                                 nativeDecodeError::Io (
77                                         a_nonref.to_rust_kind(),
78                                 )
79                         },
80                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
81                 }
82         }
83         #[allow(unused)]
84         pub(crate) fn into_native(self) -> nativeDecodeError {
85                 match self {
86                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
87                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
88                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
89                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
90                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
91                         DecodeError::Io (mut a, ) => {
92                                 nativeDecodeError::Io (
93                                         a.to_rust_kind(),
94                                 )
95                         },
96                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
97                 }
98         }
99         #[allow(unused)]
100         pub(crate) fn from_native(native: &nativeDecodeError) -> Self {
101                 match native {
102                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
103                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
104                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
105                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
106                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
107                         nativeDecodeError::Io (ref a, ) => {
108                                 let mut a_nonref = Clone::clone(a);
109                                 DecodeError::Io (
110                                         crate::c_types::IOError::from_rust_kind(a_nonref),
111                                 )
112                         },
113                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
114                 }
115         }
116         #[allow(unused)]
117         pub(crate) fn native_into(native: nativeDecodeError) -> Self {
118                 match native {
119                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
120                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
121                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
122                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
123                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
124                         nativeDecodeError::Io (mut a, ) => {
125                                 DecodeError::Io (
126                                         crate::c_types::IOError::from_rust_kind(a),
127                                 )
128                         },
129                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
130                 }
131         }
132 }
133 /// Frees any resources used by the DecodeError
134 #[no_mangle]
135 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
136 /// Creates a copy of the DecodeError
137 #[no_mangle]
138 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
139         orig.clone()
140 }
141 #[allow(unused)]
142 /// Used only if an object of this type is returned as a trait impl by a method
143 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
144         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const DecodeError)).clone() })) as *mut c_void
145 }
146 #[allow(unused)]
147 /// Used only if an object of this type is returned as a trait impl by a method
148 pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
149         let _ = unsafe { Box::from_raw(this_ptr as *mut DecodeError) };
150 }
151 #[no_mangle]
152 /// Utility method to constructs a new UnknownVersion-variant DecodeError
153 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
154         DecodeError::UnknownVersion}
155 #[no_mangle]
156 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
157 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
158         DecodeError::UnknownRequiredFeature}
159 #[no_mangle]
160 /// Utility method to constructs a new InvalidValue-variant DecodeError
161 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
162         DecodeError::InvalidValue}
163 #[no_mangle]
164 /// Utility method to constructs a new ShortRead-variant DecodeError
165 pub extern "C" fn DecodeError_short_read() -> DecodeError {
166         DecodeError::ShortRead}
167 #[no_mangle]
168 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
169 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
170         DecodeError::BadLengthDescriptor}
171 #[no_mangle]
172 /// Utility method to constructs a new Io-variant DecodeError
173 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
174         DecodeError::Io(a, )
175 }
176 #[no_mangle]
177 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
178 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
179         DecodeError::UnsupportedCompression}
180 /// Checks if two DecodeErrors contain equal inner contents.
181 /// This ignores pointers and is_owned flags and looks at the values in fields.
182 #[no_mangle]
183 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
184         if &a.to_native() == &b.to_native() { true } else { false }
185 }
186
187 use lightning::ln::msgs::Init as nativeInitImport;
188 pub(crate) type nativeInit = nativeInitImport;
189
190 /// An [`init`] message to be sent to or received from a peer.
191 ///
192 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
193 #[must_use]
194 #[repr(C)]
195 pub struct Init {
196         /// A pointer to the opaque Rust object.
197
198         /// Nearly everywhere, inner must be non-null, however in places where
199         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
200         pub inner: *mut nativeInit,
201         /// Indicates that this is the only struct which contains the same pointer.
202
203         /// Rust functions which take ownership of an object provided via an argument require
204         /// this to be true and invalidate the object pointed to by inner.
205         pub is_owned: bool,
206 }
207
208 impl Drop for Init {
209         fn drop(&mut self) {
210                 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
211                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
212                 }
213         }
214 }
215 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
216 #[no_mangle]
217 pub extern "C" fn Init_free(this_obj: Init) { }
218 #[allow(unused)]
219 /// Used only if an object of this type is returned as a trait impl by a method
220 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
221         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
222 }
223 #[allow(unused)]
224 impl Init {
225         pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
226                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
227         }
228         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
229                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
230         }
231         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
232         pub(crate) fn take_inner(mut self) -> *mut nativeInit {
233                 assert!(self.is_owned);
234                 let ret = ObjOps::untweak_ptr(self.inner);
235                 self.inner = core::ptr::null_mut();
236                 ret
237         }
238 }
239 /// The relevant features which the sender supports.
240 #[no_mangle]
241 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
242         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
243         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 }
244 }
245 /// The relevant features which the sender supports.
246 #[no_mangle]
247 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
248         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
249 }
250 /// Indicates chains the sender is interested in.
251 ///
252 /// If there are no common chains, the connection will be closed.
253 ///
254 /// Returns a copy of the field.
255 #[no_mangle]
256 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
257         let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
258         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::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() }) };
259         local_inner_val
260 }
261 /// Indicates chains the sender is interested in.
262 ///
263 /// If there are no common chains, the connection will be closed.
264 #[no_mangle]
265 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ) {
266         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 }})} };
267         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
268 }
269 /// The receipient's network address.
270 ///
271 /// This adds the option to report a remote IP address back to a connecting peer using the init
272 /// message. A node can decide to use that information to discover a potential update to its
273 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
274 /// the new address.
275 #[no_mangle]
276 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_SocketAddressZ {
277         let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
278         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_SocketAddressZ::None } else { crate::c_types::derived::COption_SocketAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::msgs::SocketAddress::native_into((*inner_val.as_ref().unwrap()).clone()) }) };
279         local_inner_val
280 }
281 /// The receipient's network address.
282 ///
283 /// This adds the option to report a remote IP address back to a connecting peer using the init
284 /// message. A node can decide to use that information to discover a potential update to its
285 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
286 /// the new address.
287 #[no_mangle]
288 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_SocketAddressZ) {
289         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
290         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
291 }
292 /// Constructs a new Init given each field
293 #[must_use]
294 #[no_mangle]
295 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ, mut remote_network_address_arg: crate::c_types::derived::COption_SocketAddressZ) -> Init {
296         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 }})} };
297         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() }})} };
298         Init { inner: ObjOps::heap_alloc(nativeInit {
299                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
300                 networks: local_networks_arg,
301                 remote_network_address: local_remote_network_address_arg,
302         }), is_owned: true }
303 }
304 impl Clone for Init {
305         fn clone(&self) -> Self {
306                 Self {
307                         inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
308                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
309                         is_owned: true,
310                 }
311         }
312 }
313 #[allow(unused)]
314 /// Used only if an object of this type is returned as a trait impl by a method
315 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
316         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInit)).clone() })) as *mut c_void
317 }
318 #[no_mangle]
319 /// Creates a copy of the Init
320 pub extern "C" fn Init_clone(orig: &Init) -> Init {
321         orig.clone()
322 }
323 /// Checks if two Inits contain equal inner contents.
324 /// This ignores pointers and is_owned flags and looks at the values in fields.
325 /// Two objects with NULL inner values will be considered "equal" here.
326 #[no_mangle]
327 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
328         if a.inner == b.inner { return true; }
329         if a.inner.is_null() || b.inner.is_null() { return false; }
330         if a.get_native_ref() == b.get_native_ref() { true } else { false }
331 }
332
333 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
334 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
335
336 /// An [`error`] message to be sent to or received from a peer.
337 ///
338 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
339 #[must_use]
340 #[repr(C)]
341 pub struct ErrorMessage {
342         /// A pointer to the opaque Rust object.
343
344         /// Nearly everywhere, inner must be non-null, however in places where
345         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
346         pub inner: *mut nativeErrorMessage,
347         /// Indicates that this is the only struct which contains the same pointer.
348
349         /// Rust functions which take ownership of an object provided via an argument require
350         /// this to be true and invalidate the object pointed to by inner.
351         pub is_owned: bool,
352 }
353
354 impl Drop for ErrorMessage {
355         fn drop(&mut self) {
356                 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
357                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
358                 }
359         }
360 }
361 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
362 #[no_mangle]
363 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
364 #[allow(unused)]
365 /// Used only if an object of this type is returned as a trait impl by a method
366 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
367         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
368 }
369 #[allow(unused)]
370 impl ErrorMessage {
371         pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
372                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
373         }
374         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
375                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
376         }
377         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
378         pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
379                 assert!(self.is_owned);
380                 let ret = ObjOps::untweak_ptr(self.inner);
381                 self.inner = core::ptr::null_mut();
382                 ret
383         }
384 }
385 /// The channel ID involved in the error.
386 ///
387 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
388 /// with the sending peer should be closed.
389 #[no_mangle]
390 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
391         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
392         &inner_val.0
393 }
394 /// The channel ID involved in the error.
395 ///
396 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
397 /// with the sending peer should be closed.
398 #[no_mangle]
399 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
400         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
401 }
402 /// A possibly human-readable error description.
403 ///
404 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
405 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
406 /// the terminal emulator or the logging subsystem.
407 #[no_mangle]
408 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
409         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
410         inner_val.as_str().into()
411 }
412 /// A possibly human-readable error description.
413 ///
414 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
415 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
416 /// the terminal emulator or the logging subsystem.
417 #[no_mangle]
418 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
419         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
420 }
421 /// Constructs a new ErrorMessage given each field
422 #[must_use]
423 #[no_mangle]
424 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
425         ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
426                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
427                 data: data_arg.into_string(),
428         }), is_owned: true }
429 }
430 impl Clone for ErrorMessage {
431         fn clone(&self) -> Self {
432                 Self {
433                         inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
434                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
435                         is_owned: true,
436                 }
437         }
438 }
439 #[allow(unused)]
440 /// Used only if an object of this type is returned as a trait impl by a method
441 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
442         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeErrorMessage)).clone() })) as *mut c_void
443 }
444 #[no_mangle]
445 /// Creates a copy of the ErrorMessage
446 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
447         orig.clone()
448 }
449 /// Checks if two ErrorMessages contain equal inner contents.
450 /// This ignores pointers and is_owned flags and looks at the values in fields.
451 /// Two objects with NULL inner values will be considered "equal" here.
452 #[no_mangle]
453 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
454         if a.inner == b.inner { return true; }
455         if a.inner.is_null() || b.inner.is_null() { return false; }
456         if a.get_native_ref() == b.get_native_ref() { true } else { false }
457 }
458
459 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
460 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
461
462 /// A [`warning`] message to be sent to or received from a peer.
463 ///
464 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
465 #[must_use]
466 #[repr(C)]
467 pub struct WarningMessage {
468         /// A pointer to the opaque Rust object.
469
470         /// Nearly everywhere, inner must be non-null, however in places where
471         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
472         pub inner: *mut nativeWarningMessage,
473         /// Indicates that this is the only struct which contains the same pointer.
474
475         /// Rust functions which take ownership of an object provided via an argument require
476         /// this to be true and invalidate the object pointed to by inner.
477         pub is_owned: bool,
478 }
479
480 impl Drop for WarningMessage {
481         fn drop(&mut self) {
482                 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
483                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
484                 }
485         }
486 }
487 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
488 #[no_mangle]
489 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
490 #[allow(unused)]
491 /// Used only if an object of this type is returned as a trait impl by a method
492 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
493         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
494 }
495 #[allow(unused)]
496 impl WarningMessage {
497         pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
498                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
499         }
500         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
501                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
502         }
503         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
504         pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
505                 assert!(self.is_owned);
506                 let ret = ObjOps::untweak_ptr(self.inner);
507                 self.inner = core::ptr::null_mut();
508                 ret
509         }
510 }
511 /// The channel ID involved in the warning.
512 ///
513 /// All-0s indicates a warning unrelated to a specific channel.
514 #[no_mangle]
515 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
516         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
517         &inner_val.0
518 }
519 /// The channel ID involved in the warning.
520 ///
521 /// All-0s indicates a warning unrelated to a specific channel.
522 #[no_mangle]
523 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
524         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
525 }
526 /// A possibly human-readable warning description.
527 ///
528 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
529 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
530 /// the terminal emulator or the logging subsystem.
531 #[no_mangle]
532 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
533         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
534         inner_val.as_str().into()
535 }
536 /// A possibly human-readable warning description.
537 ///
538 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
539 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
540 /// the terminal emulator or the logging subsystem.
541 #[no_mangle]
542 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
543         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
544 }
545 /// Constructs a new WarningMessage given each field
546 #[must_use]
547 #[no_mangle]
548 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
549         WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
550                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
551                 data: data_arg.into_string(),
552         }), is_owned: true }
553 }
554 impl Clone for WarningMessage {
555         fn clone(&self) -> Self {
556                 Self {
557                         inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
558                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
559                         is_owned: true,
560                 }
561         }
562 }
563 #[allow(unused)]
564 /// Used only if an object of this type is returned as a trait impl by a method
565 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
566         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeWarningMessage)).clone() })) as *mut c_void
567 }
568 #[no_mangle]
569 /// Creates a copy of the WarningMessage
570 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
571         orig.clone()
572 }
573 /// Checks if two WarningMessages contain equal inner contents.
574 /// This ignores pointers and is_owned flags and looks at the values in fields.
575 /// Two objects with NULL inner values will be considered "equal" here.
576 #[no_mangle]
577 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
578         if a.inner == b.inner { return true; }
579         if a.inner.is_null() || b.inner.is_null() { return false; }
580         if a.get_native_ref() == b.get_native_ref() { true } else { false }
581 }
582
583 use lightning::ln::msgs::Ping as nativePingImport;
584 pub(crate) type nativePing = nativePingImport;
585
586 /// A [`ping`] message to be sent to or received from a peer.
587 ///
588 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
589 #[must_use]
590 #[repr(C)]
591 pub struct Ping {
592         /// A pointer to the opaque Rust object.
593
594         /// Nearly everywhere, inner must be non-null, however in places where
595         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
596         pub inner: *mut nativePing,
597         /// Indicates that this is the only struct which contains the same pointer.
598
599         /// Rust functions which take ownership of an object provided via an argument require
600         /// this to be true and invalidate the object pointed to by inner.
601         pub is_owned: bool,
602 }
603
604 impl Drop for Ping {
605         fn drop(&mut self) {
606                 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
607                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
608                 }
609         }
610 }
611 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
612 #[no_mangle]
613 pub extern "C" fn Ping_free(this_obj: Ping) { }
614 #[allow(unused)]
615 /// Used only if an object of this type is returned as a trait impl by a method
616 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
617         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
618 }
619 #[allow(unused)]
620 impl Ping {
621         pub(crate) fn get_native_ref(&self) -> &'static nativePing {
622                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
623         }
624         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
625                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
626         }
627         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
628         pub(crate) fn take_inner(mut self) -> *mut nativePing {
629                 assert!(self.is_owned);
630                 let ret = ObjOps::untweak_ptr(self.inner);
631                 self.inner = core::ptr::null_mut();
632                 ret
633         }
634 }
635 /// The desired response length.
636 #[no_mangle]
637 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
638         let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
639         *inner_val
640 }
641 /// The desired response length.
642 #[no_mangle]
643 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
644         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
645 }
646 /// The ping packet size.
647 ///
648 /// This field is not sent on the wire. byteslen zeros are sent.
649 #[no_mangle]
650 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
651         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
652         *inner_val
653 }
654 /// The ping packet size.
655 ///
656 /// This field is not sent on the wire. byteslen zeros are sent.
657 #[no_mangle]
658 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
659         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
660 }
661 /// Constructs a new Ping given each field
662 #[must_use]
663 #[no_mangle]
664 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
665         Ping { inner: ObjOps::heap_alloc(nativePing {
666                 ponglen: ponglen_arg,
667                 byteslen: byteslen_arg,
668         }), is_owned: true }
669 }
670 impl Clone for Ping {
671         fn clone(&self) -> Self {
672                 Self {
673                         inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
674                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
675                         is_owned: true,
676                 }
677         }
678 }
679 #[allow(unused)]
680 /// Used only if an object of this type is returned as a trait impl by a method
681 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
682         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePing)).clone() })) as *mut c_void
683 }
684 #[no_mangle]
685 /// Creates a copy of the Ping
686 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
687         orig.clone()
688 }
689 /// Checks if two Pings contain equal inner contents.
690 /// This ignores pointers and is_owned flags and looks at the values in fields.
691 /// Two objects with NULL inner values will be considered "equal" here.
692 #[no_mangle]
693 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
694         if a.inner == b.inner { return true; }
695         if a.inner.is_null() || b.inner.is_null() { return false; }
696         if a.get_native_ref() == b.get_native_ref() { true } else { false }
697 }
698
699 use lightning::ln::msgs::Pong as nativePongImport;
700 pub(crate) type nativePong = nativePongImport;
701
702 /// A [`pong`] message to be sent to or received from a peer.
703 ///
704 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
705 #[must_use]
706 #[repr(C)]
707 pub struct Pong {
708         /// A pointer to the opaque Rust object.
709
710         /// Nearly everywhere, inner must be non-null, however in places where
711         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
712         pub inner: *mut nativePong,
713         /// Indicates that this is the only struct which contains the same pointer.
714
715         /// Rust functions which take ownership of an object provided via an argument require
716         /// this to be true and invalidate the object pointed to by inner.
717         pub is_owned: bool,
718 }
719
720 impl Drop for Pong {
721         fn drop(&mut self) {
722                 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
723                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
724                 }
725         }
726 }
727 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
728 #[no_mangle]
729 pub extern "C" fn Pong_free(this_obj: Pong) { }
730 #[allow(unused)]
731 /// Used only if an object of this type is returned as a trait impl by a method
732 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
733         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
734 }
735 #[allow(unused)]
736 impl Pong {
737         pub(crate) fn get_native_ref(&self) -> &'static nativePong {
738                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
739         }
740         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
741                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
742         }
743         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
744         pub(crate) fn take_inner(mut self) -> *mut nativePong {
745                 assert!(self.is_owned);
746                 let ret = ObjOps::untweak_ptr(self.inner);
747                 self.inner = core::ptr::null_mut();
748                 ret
749         }
750 }
751 /// The pong packet size.
752 ///
753 /// This field is not sent on the wire. byteslen zeros are sent.
754 #[no_mangle]
755 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
756         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
757         *inner_val
758 }
759 /// The pong packet size.
760 ///
761 /// This field is not sent on the wire. byteslen zeros are sent.
762 #[no_mangle]
763 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
764         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
765 }
766 /// Constructs a new Pong given each field
767 #[must_use]
768 #[no_mangle]
769 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
770         Pong { inner: ObjOps::heap_alloc(nativePong {
771                 byteslen: byteslen_arg,
772         }), is_owned: true }
773 }
774 impl Clone for Pong {
775         fn clone(&self) -> Self {
776                 Self {
777                         inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
778                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
779                         is_owned: true,
780                 }
781         }
782 }
783 #[allow(unused)]
784 /// Used only if an object of this type is returned as a trait impl by a method
785 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
786         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePong)).clone() })) as *mut c_void
787 }
788 #[no_mangle]
789 /// Creates a copy of the Pong
790 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
791         orig.clone()
792 }
793 /// Checks if two Pongs contain equal inner contents.
794 /// This ignores pointers and is_owned flags and looks at the values in fields.
795 /// Two objects with NULL inner values will be considered "equal" here.
796 #[no_mangle]
797 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
798         if a.inner == b.inner { return true; }
799         if a.inner.is_null() || b.inner.is_null() { return false; }
800         if a.get_native_ref() == b.get_native_ref() { true } else { false }
801 }
802
803 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
804 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
805
806 /// An [`open_channel`] message to be sent to or received from a peer.
807 ///
808 /// Used in V1 channel establishment
809 ///
810 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
811 #[must_use]
812 #[repr(C)]
813 pub struct OpenChannel {
814         /// A pointer to the opaque Rust object.
815
816         /// Nearly everywhere, inner must be non-null, however in places where
817         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
818         pub inner: *mut nativeOpenChannel,
819         /// Indicates that this is the only struct which contains the same pointer.
820
821         /// Rust functions which take ownership of an object provided via an argument require
822         /// this to be true and invalidate the object pointed to by inner.
823         pub is_owned: bool,
824 }
825
826 impl Drop for OpenChannel {
827         fn drop(&mut self) {
828                 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
829                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
830                 }
831         }
832 }
833 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
834 #[no_mangle]
835 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
836 #[allow(unused)]
837 /// Used only if an object of this type is returned as a trait impl by a method
838 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
839         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
840 }
841 #[allow(unused)]
842 impl OpenChannel {
843         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
844                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
845         }
846         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
847                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
848         }
849         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
850         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
851                 assert!(self.is_owned);
852                 let ret = ObjOps::untweak_ptr(self.inner);
853                 self.inner = core::ptr::null_mut();
854                 ret
855         }
856 }
857 /// The genesis hash of the blockchain where the channel is to be opened
858 #[no_mangle]
859 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
860         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
861         inner_val.as_bytes()
862 }
863 /// The genesis hash of the blockchain where the channel is to be opened
864 #[no_mangle]
865 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
866         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
867 }
868 /// A temporary channel ID, until the funding outpoint is announced
869 #[no_mangle]
870 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
871         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
872         &inner_val.0
873 }
874 /// A temporary channel ID, until the funding outpoint is announced
875 #[no_mangle]
876 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
877         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
878 }
879 /// The channel value
880 #[no_mangle]
881 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
882         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
883         *inner_val
884 }
885 /// The channel value
886 #[no_mangle]
887 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
888         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
889 }
890 /// The amount to push to the counterparty as part of the open, in milli-satoshi
891 #[no_mangle]
892 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
893         let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
894         *inner_val
895 }
896 /// The amount to push to the counterparty as part of the open, in milli-satoshi
897 #[no_mangle]
898 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
899         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
900 }
901 /// The threshold below which outputs on transactions broadcast by sender will be omitted
902 #[no_mangle]
903 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
904         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
905         *inner_val
906 }
907 /// The threshold below which outputs on transactions broadcast by sender will be omitted
908 #[no_mangle]
909 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
910         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
911 }
912 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
913 #[no_mangle]
914 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
915         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
916         *inner_val
917 }
918 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
919 #[no_mangle]
920 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
921         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
922 }
923 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
924 #[no_mangle]
925 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
926         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
927         *inner_val
928 }
929 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
930 #[no_mangle]
931 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
932         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
933 }
934 /// The minimum HTLC size incoming to sender, in milli-satoshi
935 #[no_mangle]
936 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
937         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
938         *inner_val
939 }
940 /// The minimum HTLC size incoming to sender, in milli-satoshi
941 #[no_mangle]
942 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
943         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
944 }
945 /// The feerate per 1000-weight of sender generated transactions, until updated by
946 /// [`UpdateFee`]
947 #[no_mangle]
948 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
949         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
950         *inner_val
951 }
952 /// The feerate per 1000-weight of sender generated transactions, until updated by
953 /// [`UpdateFee`]
954 #[no_mangle]
955 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
956         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
957 }
958 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
959 /// they broadcast a commitment transaction
960 #[no_mangle]
961 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
962         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
963         *inner_val
964 }
965 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
966 /// they broadcast a commitment transaction
967 #[no_mangle]
968 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
969         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
970 }
971 /// The maximum number of inbound HTLCs towards sender
972 #[no_mangle]
973 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
974         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
975         *inner_val
976 }
977 /// The maximum number of inbound HTLCs towards sender
978 #[no_mangle]
979 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
980         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
981 }
982 /// The sender's key controlling the funding transaction
983 #[no_mangle]
984 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
985         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
986         crate::c_types::PublicKey::from_rust(&inner_val)
987 }
988 /// The sender's key controlling the funding transaction
989 #[no_mangle]
990 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
991         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
992 }
993 /// Used to derive a revocation key for transactions broadcast by counterparty
994 #[no_mangle]
995 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
996         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
997         crate::c_types::PublicKey::from_rust(&inner_val)
998 }
999 /// Used to derive a revocation key for transactions broadcast by counterparty
1000 #[no_mangle]
1001 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1002         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1003 }
1004 /// A payment key to sender for transactions broadcast by counterparty
1005 #[no_mangle]
1006 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1007         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1008         crate::c_types::PublicKey::from_rust(&inner_val)
1009 }
1010 /// A payment key to sender for transactions broadcast by counterparty
1011 #[no_mangle]
1012 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1013         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1014 }
1015 /// Used to derive a payment key to sender for transactions broadcast by sender
1016 #[no_mangle]
1017 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1018         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1019         crate::c_types::PublicKey::from_rust(&inner_val)
1020 }
1021 /// Used to derive a payment key to sender for transactions broadcast by sender
1022 #[no_mangle]
1023 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1024         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1025 }
1026 /// Used to derive an HTLC payment key to sender
1027 #[no_mangle]
1028 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1029         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1030         crate::c_types::PublicKey::from_rust(&inner_val)
1031 }
1032 /// Used to derive an HTLC payment key to sender
1033 #[no_mangle]
1034 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1035         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1036 }
1037 /// The first to-be-broadcast-by-sender transaction's per commitment point
1038 #[no_mangle]
1039 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1040         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1041         crate::c_types::PublicKey::from_rust(&inner_val)
1042 }
1043 /// The first to-be-broadcast-by-sender transaction's per commitment point
1044 #[no_mangle]
1045 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1046         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1047 }
1048 /// The channel flags to be used
1049 #[no_mangle]
1050 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
1051         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1052         *inner_val
1053 }
1054 /// The channel flags to be used
1055 #[no_mangle]
1056 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
1057         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1058 }
1059 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1060 #[no_mangle]
1061 pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1062         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1063         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1064         local_inner_val
1065 }
1066 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1067 #[no_mangle]
1068 pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1069         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()) }})} };
1070         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1071 }
1072 /// The channel type that this channel will represent
1073 ///
1074 /// If this is `None`, we derive the channel type from the intersection of our
1075 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1076 ///
1077 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1078 #[no_mangle]
1079 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1080         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1081         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 };
1082         local_inner_val
1083 }
1084 /// The channel type that this channel will represent
1085 ///
1086 /// If this is `None`, we derive the channel type from the intersection of our
1087 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1088 ///
1089 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1090 #[no_mangle]
1091 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1092         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1093         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1094 }
1095 /// Constructs a new OpenChannel given each field
1096 ///
1097 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1098 #[must_use]
1099 #[no_mangle]
1100 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_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> OpenChannel {
1101         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()) }})} };
1102         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()) } }) };
1103         OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1104                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
1105                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1106                 funding_satoshis: funding_satoshis_arg,
1107                 push_msat: push_msat_arg,
1108                 dust_limit_satoshis: dust_limit_satoshis_arg,
1109                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1110                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1111                 htlc_minimum_msat: htlc_minimum_msat_arg,
1112                 feerate_per_kw: feerate_per_kw_arg,
1113                 to_self_delay: to_self_delay_arg,
1114                 max_accepted_htlcs: max_accepted_htlcs_arg,
1115                 funding_pubkey: funding_pubkey_arg.into_rust(),
1116                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1117                 payment_point: payment_point_arg.into_rust(),
1118                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1119                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1120                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1121                 channel_flags: channel_flags_arg,
1122                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1123                 channel_type: local_channel_type_arg,
1124         }), is_owned: true }
1125 }
1126 impl Clone for OpenChannel {
1127         fn clone(&self) -> Self {
1128                 Self {
1129                         inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1130                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1131                         is_owned: true,
1132                 }
1133         }
1134 }
1135 #[allow(unused)]
1136 /// Used only if an object of this type is returned as a trait impl by a method
1137 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1138         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannel)).clone() })) as *mut c_void
1139 }
1140 #[no_mangle]
1141 /// Creates a copy of the OpenChannel
1142 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1143         orig.clone()
1144 }
1145 /// Checks if two OpenChannels contain equal inner contents.
1146 /// This ignores pointers and is_owned flags and looks at the values in fields.
1147 /// Two objects with NULL inner values will be considered "equal" here.
1148 #[no_mangle]
1149 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1150         if a.inner == b.inner { return true; }
1151         if a.inner.is_null() || b.inner.is_null() { return false; }
1152         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1153 }
1154
1155 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1156 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1157
1158 /// An open_channel2 message to be sent by or received from the channel initiator.
1159 ///
1160 /// Used in V2 channel establishment
1161 ///
1162 #[must_use]
1163 #[repr(C)]
1164 pub struct OpenChannelV2 {
1165         /// A pointer to the opaque Rust object.
1166
1167         /// Nearly everywhere, inner must be non-null, however in places where
1168         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1169         pub inner: *mut nativeOpenChannelV2,
1170         /// Indicates that this is the only struct which contains the same pointer.
1171
1172         /// Rust functions which take ownership of an object provided via an argument require
1173         /// this to be true and invalidate the object pointed to by inner.
1174         pub is_owned: bool,
1175 }
1176
1177 impl Drop for OpenChannelV2 {
1178         fn drop(&mut self) {
1179                 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1180                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1181                 }
1182         }
1183 }
1184 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1185 #[no_mangle]
1186 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1187 #[allow(unused)]
1188 /// Used only if an object of this type is returned as a trait impl by a method
1189 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1190         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1191 }
1192 #[allow(unused)]
1193 impl OpenChannelV2 {
1194         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1195                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1196         }
1197         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1198                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1199         }
1200         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1201         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1202                 assert!(self.is_owned);
1203                 let ret = ObjOps::untweak_ptr(self.inner);
1204                 self.inner = core::ptr::null_mut();
1205                 ret
1206         }
1207 }
1208 /// The genesis hash of the blockchain where the channel is to be opened
1209 #[no_mangle]
1210 pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1211         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
1212         inner_val.as_bytes()
1213 }
1214 /// The genesis hash of the blockchain where the channel is to be opened
1215 #[no_mangle]
1216 pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1217         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
1218 }
1219 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1220 #[no_mangle]
1221 pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1222         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1223         &inner_val.0
1224 }
1225 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1226 #[no_mangle]
1227 pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1228         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1229 }
1230 /// The feerate for the funding transaction set by the channel initiator
1231 #[no_mangle]
1232 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1233         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1234         *inner_val
1235 }
1236 /// The feerate for the funding transaction set by the channel initiator
1237 #[no_mangle]
1238 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1239         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1240 }
1241 /// The feerate for the commitment transaction set by the channel initiator
1242 #[no_mangle]
1243 pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1244         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1245         *inner_val
1246 }
1247 /// The feerate for the commitment transaction set by the channel initiator
1248 #[no_mangle]
1249 pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1250         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1251 }
1252 /// Part of the channel value contributed by the channel initiator
1253 #[no_mangle]
1254 pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1255         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1256         *inner_val
1257 }
1258 /// Part of the channel value contributed by the channel initiator
1259 #[no_mangle]
1260 pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1261         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1262 }
1263 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1264 /// omitted
1265 #[no_mangle]
1266 pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1267         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1268         *inner_val
1269 }
1270 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1271 /// omitted
1272 #[no_mangle]
1273 pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1274         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1275 }
1276 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1277 #[no_mangle]
1278 pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 {
1279         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1280         *inner_val
1281 }
1282 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1283 #[no_mangle]
1284 pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1285         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1286 }
1287 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1288 #[no_mangle]
1289 pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 {
1290         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1291         *inner_val
1292 }
1293 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1294 #[no_mangle]
1295 pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1296         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1297 }
1298 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1299 /// broadcast a commitment transaction
1300 #[no_mangle]
1301 pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 {
1302         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1303         *inner_val
1304 }
1305 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1306 /// broadcast a commitment transaction
1307 #[no_mangle]
1308 pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) {
1309         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1310 }
1311 /// The maximum number of inbound HTLCs towards channel initiator
1312 #[no_mangle]
1313 pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 {
1314         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1315         *inner_val
1316 }
1317 /// The maximum number of inbound HTLCs towards channel initiator
1318 #[no_mangle]
1319 pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) {
1320         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1321 }
1322 /// The locktime for the funding transaction
1323 #[no_mangle]
1324 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1325         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1326         *inner_val
1327 }
1328 /// The locktime for the funding transaction
1329 #[no_mangle]
1330 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1331         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1332 }
1333 /// The channel initiator's key controlling the funding transaction
1334 #[no_mangle]
1335 pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1336         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1337         crate::c_types::PublicKey::from_rust(&inner_val)
1338 }
1339 /// The channel initiator's key controlling the funding transaction
1340 #[no_mangle]
1341 pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1342         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1343 }
1344 /// Used to derive a revocation key for transactions broadcast by counterparty
1345 #[no_mangle]
1346 pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1347         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1348         crate::c_types::PublicKey::from_rust(&inner_val)
1349 }
1350 /// Used to derive a revocation key for transactions broadcast by counterparty
1351 #[no_mangle]
1352 pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1353         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1354 }
1355 /// A payment key to channel initiator for transactions broadcast by counterparty
1356 #[no_mangle]
1357 pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1358         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1359         crate::c_types::PublicKey::from_rust(&inner_val)
1360 }
1361 /// A payment key to channel initiator for transactions broadcast by counterparty
1362 #[no_mangle]
1363 pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1364         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1365 }
1366 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1367 /// initiator
1368 #[no_mangle]
1369 pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1370         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1371         crate::c_types::PublicKey::from_rust(&inner_val)
1372 }
1373 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1374 /// initiator
1375 #[no_mangle]
1376 pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1377         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1378 }
1379 /// Used to derive an HTLC payment key to channel initiator
1380 #[no_mangle]
1381 pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1382         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1383         crate::c_types::PublicKey::from_rust(&inner_val)
1384 }
1385 /// Used to derive an HTLC payment key to channel initiator
1386 #[no_mangle]
1387 pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1388         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1389 }
1390 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1391 #[no_mangle]
1392 pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1393         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1394         crate::c_types::PublicKey::from_rust(&inner_val)
1395 }
1396 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1397 #[no_mangle]
1398 pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1399         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1400 }
1401 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1402 #[no_mangle]
1403 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1404         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1405         crate::c_types::PublicKey::from_rust(&inner_val)
1406 }
1407 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1408 #[no_mangle]
1409 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1410         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1411 }
1412 /// Channel flags
1413 #[no_mangle]
1414 pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 {
1415         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1416         *inner_val
1417 }
1418 /// Channel flags
1419 #[no_mangle]
1420 pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) {
1421         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1422 }
1423 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1424 /// collaboratively close
1425 #[no_mangle]
1426 pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
1427         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1428         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1429         local_inner_val
1430 }
1431 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1432 /// collaboratively close
1433 #[no_mangle]
1434 pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1435         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()) }})} };
1436         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1437 }
1438 /// The channel type that this channel will represent. If none is set, we derive the channel
1439 /// type from the intersection of our feature bits with our counterparty's feature bits from
1440 /// the Init message.
1441 ///
1442 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1443 #[no_mangle]
1444 pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
1445         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1446         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 };
1447         local_inner_val
1448 }
1449 /// The channel type that this channel will represent. If none is set, we derive the channel
1450 /// type from the intersection of our feature bits with our counterparty's feature bits from
1451 /// the Init message.
1452 ///
1453 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1454 #[no_mangle]
1455 pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1456         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1457         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1458 }
1459 /// Optionally, a requirement that only confirmed inputs can be added
1460 #[no_mangle]
1461 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1462         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1463         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 /*  { () /**/ } */ };
1464         local_inner_val
1465 }
1466 /// Optionally, a requirement that only confirmed inputs can be added
1467 #[no_mangle]
1468 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1469         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1470         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1471 }
1472 /// Constructs a new OpenChannelV2 given each field
1473 ///
1474 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1475 #[must_use]
1476 #[no_mangle]
1477 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_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 {
1478         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()) }})} };
1479         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()) } }) };
1480         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1481         OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1482                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
1483                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1484                 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1485                 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1486                 funding_satoshis: funding_satoshis_arg,
1487                 dust_limit_satoshis: dust_limit_satoshis_arg,
1488                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1489                 htlc_minimum_msat: htlc_minimum_msat_arg,
1490                 to_self_delay: to_self_delay_arg,
1491                 max_accepted_htlcs: max_accepted_htlcs_arg,
1492                 locktime: locktime_arg,
1493                 funding_pubkey: funding_pubkey_arg.into_rust(),
1494                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1495                 payment_basepoint: payment_basepoint_arg.into_rust(),
1496                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1497                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1498                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1499                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1500                 channel_flags: channel_flags_arg,
1501                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1502                 channel_type: local_channel_type_arg,
1503                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1504         }), is_owned: true }
1505 }
1506 impl Clone for OpenChannelV2 {
1507         fn clone(&self) -> Self {
1508                 Self {
1509                         inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1510                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1511                         is_owned: true,
1512                 }
1513         }
1514 }
1515 #[allow(unused)]
1516 /// Used only if an object of this type is returned as a trait impl by a method
1517 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1518         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannelV2)).clone() })) as *mut c_void
1519 }
1520 #[no_mangle]
1521 /// Creates a copy of the OpenChannelV2
1522 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1523         orig.clone()
1524 }
1525 /// Checks if two OpenChannelV2s contain equal inner contents.
1526 /// This ignores pointers and is_owned flags and looks at the values in fields.
1527 /// Two objects with NULL inner values will be considered "equal" here.
1528 #[no_mangle]
1529 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1530         if a.inner == b.inner { return true; }
1531         if a.inner.is_null() || b.inner.is_null() { return false; }
1532         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1533 }
1534
1535 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1536 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1537
1538 /// An [`accept_channel`] message to be sent to or received from a peer.
1539 ///
1540 /// Used in V1 channel establishment
1541 ///
1542 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1543 #[must_use]
1544 #[repr(C)]
1545 pub struct AcceptChannel {
1546         /// A pointer to the opaque Rust object.
1547
1548         /// Nearly everywhere, inner must be non-null, however in places where
1549         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1550         pub inner: *mut nativeAcceptChannel,
1551         /// Indicates that this is the only struct which contains the same pointer.
1552
1553         /// Rust functions which take ownership of an object provided via an argument require
1554         /// this to be true and invalidate the object pointed to by inner.
1555         pub is_owned: bool,
1556 }
1557
1558 impl Drop for AcceptChannel {
1559         fn drop(&mut self) {
1560                 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1561                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1562                 }
1563         }
1564 }
1565 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1566 #[no_mangle]
1567 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1568 #[allow(unused)]
1569 /// Used only if an object of this type is returned as a trait impl by a method
1570 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1571         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1572 }
1573 #[allow(unused)]
1574 impl AcceptChannel {
1575         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1576                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1577         }
1578         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1579                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1580         }
1581         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1582         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1583                 assert!(self.is_owned);
1584                 let ret = ObjOps::untweak_ptr(self.inner);
1585                 self.inner = core::ptr::null_mut();
1586                 ret
1587         }
1588 }
1589 /// A temporary channel ID, until the funding outpoint is announced
1590 #[no_mangle]
1591 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1592         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1593         &inner_val.0
1594 }
1595 /// A temporary channel ID, until the funding outpoint is announced
1596 #[no_mangle]
1597 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1598         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1599 }
1600 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1601 #[no_mangle]
1602 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1603         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1604         *inner_val
1605 }
1606 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1607 #[no_mangle]
1608 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1609         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1610 }
1611 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1612 #[no_mangle]
1613 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1614         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1615         *inner_val
1616 }
1617 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1618 #[no_mangle]
1619 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1620         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1621 }
1622 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1623 #[no_mangle]
1624 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1625         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1626         *inner_val
1627 }
1628 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1629 #[no_mangle]
1630 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1631         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1632 }
1633 /// The minimum HTLC size incoming to sender, in milli-satoshi
1634 #[no_mangle]
1635 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1636         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1637         *inner_val
1638 }
1639 /// The minimum HTLC size incoming to sender, in milli-satoshi
1640 #[no_mangle]
1641 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1642         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1643 }
1644 /// Minimum depth of the funding transaction before the channel is considered open
1645 #[no_mangle]
1646 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1647         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1648         *inner_val
1649 }
1650 /// Minimum depth of the funding transaction before the channel is considered open
1651 #[no_mangle]
1652 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1653         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1654 }
1655 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1656 #[no_mangle]
1657 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1658         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1659         *inner_val
1660 }
1661 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1662 #[no_mangle]
1663 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1664         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1665 }
1666 /// The maximum number of inbound HTLCs towards sender
1667 #[no_mangle]
1668 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1669         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1670         *inner_val
1671 }
1672 /// The maximum number of inbound HTLCs towards sender
1673 #[no_mangle]
1674 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1675         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1676 }
1677 /// The sender's key controlling the funding transaction
1678 #[no_mangle]
1679 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1680         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1681         crate::c_types::PublicKey::from_rust(&inner_val)
1682 }
1683 /// The sender's key controlling the funding transaction
1684 #[no_mangle]
1685 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1686         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1687 }
1688 /// Used to derive a revocation key for transactions broadcast by counterparty
1689 #[no_mangle]
1690 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1691         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1692         crate::c_types::PublicKey::from_rust(&inner_val)
1693 }
1694 /// Used to derive a revocation key for transactions broadcast by counterparty
1695 #[no_mangle]
1696 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1697         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1698 }
1699 /// A payment key to sender for transactions broadcast by counterparty
1700 #[no_mangle]
1701 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1702         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1703         crate::c_types::PublicKey::from_rust(&inner_val)
1704 }
1705 /// A payment key to sender for transactions broadcast by counterparty
1706 #[no_mangle]
1707 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1708         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1709 }
1710 /// Used to derive a payment key to sender for transactions broadcast by sender
1711 #[no_mangle]
1712 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1713         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1714         crate::c_types::PublicKey::from_rust(&inner_val)
1715 }
1716 /// Used to derive a payment key to sender for transactions broadcast by sender
1717 #[no_mangle]
1718 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1719         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1720 }
1721 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1722 #[no_mangle]
1723 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1724         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1725         crate::c_types::PublicKey::from_rust(&inner_val)
1726 }
1727 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1728 #[no_mangle]
1729 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1730         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1731 }
1732 /// The first to-be-broadcast-by-sender transaction's per commitment point
1733 #[no_mangle]
1734 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1735         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1736         crate::c_types::PublicKey::from_rust(&inner_val)
1737 }
1738 /// The first to-be-broadcast-by-sender transaction's per commitment point
1739 #[no_mangle]
1740 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1741         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1742 }
1743 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1744 #[no_mangle]
1745 pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1746         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1747         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1748         local_inner_val
1749 }
1750 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1751 #[no_mangle]
1752 pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1753         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()) }})} };
1754         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1755 }
1756 /// The channel type that this channel will represent.
1757 ///
1758 /// If this is `None`, we derive the channel type from the intersection of
1759 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1760 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1761 ///
1762 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1763 #[no_mangle]
1764 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1765         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1766         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 };
1767         local_inner_val
1768 }
1769 /// The channel type that this channel will represent.
1770 ///
1771 /// If this is `None`, we derive the channel type from the intersection of
1772 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1773 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1774 ///
1775 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1776 #[no_mangle]
1777 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1778         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1779         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1780 }
1781 /// Constructs a new AcceptChannel given each field
1782 ///
1783 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1784 #[must_use]
1785 #[no_mangle]
1786 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_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> AcceptChannel {
1787         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()) }})} };
1788         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()) } }) };
1789         AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1790                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1791                 dust_limit_satoshis: dust_limit_satoshis_arg,
1792                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1793                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1794                 htlc_minimum_msat: htlc_minimum_msat_arg,
1795                 minimum_depth: minimum_depth_arg,
1796                 to_self_delay: to_self_delay_arg,
1797                 max_accepted_htlcs: max_accepted_htlcs_arg,
1798                 funding_pubkey: funding_pubkey_arg.into_rust(),
1799                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1800                 payment_point: payment_point_arg.into_rust(),
1801                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1802                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1803                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1804                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1805                 channel_type: local_channel_type_arg,
1806         }), is_owned: true }
1807 }
1808 impl Clone for AcceptChannel {
1809         fn clone(&self) -> Self {
1810                 Self {
1811                         inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1812                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1813                         is_owned: true,
1814                 }
1815         }
1816 }
1817 #[allow(unused)]
1818 /// Used only if an object of this type is returned as a trait impl by a method
1819 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1820         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannel)).clone() })) as *mut c_void
1821 }
1822 #[no_mangle]
1823 /// Creates a copy of the AcceptChannel
1824 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1825         orig.clone()
1826 }
1827 /// Checks if two AcceptChannels contain equal inner contents.
1828 /// This ignores pointers and is_owned flags and looks at the values in fields.
1829 /// Two objects with NULL inner values will be considered "equal" here.
1830 #[no_mangle]
1831 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1832         if a.inner == b.inner { return true; }
1833         if a.inner.is_null() || b.inner.is_null() { return false; }
1834         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1835 }
1836
1837 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1838 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1839
1840 /// An accept_channel2 message to be sent by or received from the channel accepter.
1841 ///
1842 /// Used in V2 channel establishment
1843 ///
1844 #[must_use]
1845 #[repr(C)]
1846 pub struct AcceptChannelV2 {
1847         /// A pointer to the opaque Rust object.
1848
1849         /// Nearly everywhere, inner must be non-null, however in places where
1850         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1851         pub inner: *mut nativeAcceptChannelV2,
1852         /// Indicates that this is the only struct which contains the same pointer.
1853
1854         /// Rust functions which take ownership of an object provided via an argument require
1855         /// this to be true and invalidate the object pointed to by inner.
1856         pub is_owned: bool,
1857 }
1858
1859 impl Drop for AcceptChannelV2 {
1860         fn drop(&mut self) {
1861                 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
1862                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1863                 }
1864         }
1865 }
1866 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
1867 #[no_mangle]
1868 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
1869 #[allow(unused)]
1870 /// Used only if an object of this type is returned as a trait impl by a method
1871 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
1872         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
1873 }
1874 #[allow(unused)]
1875 impl AcceptChannelV2 {
1876         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
1877                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1878         }
1879         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
1880                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1881         }
1882         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1883         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
1884                 assert!(self.is_owned);
1885                 let ret = ObjOps::untweak_ptr(self.inner);
1886                 self.inner = core::ptr::null_mut();
1887                 ret
1888         }
1889 }
1890 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1891 #[no_mangle]
1892 pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] {
1893         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1894         &inner_val.0
1895 }
1896 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1897 #[no_mangle]
1898 pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1899         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1900 }
1901 /// Part of the channel value contributed by the channel acceptor
1902 #[no_mangle]
1903 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1904         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1905         *inner_val
1906 }
1907 /// Part of the channel value contributed by the channel acceptor
1908 #[no_mangle]
1909 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1910         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1911 }
1912 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1913 /// omitted
1914 #[no_mangle]
1915 pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1916         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1917         *inner_val
1918 }
1919 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1920 /// omitted
1921 #[no_mangle]
1922 pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1923         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1924 }
1925 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1926 #[no_mangle]
1927 pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 {
1928         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1929         *inner_val
1930 }
1931 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1932 #[no_mangle]
1933 pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1934         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1935 }
1936 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1937 #[no_mangle]
1938 pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 {
1939         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1940         *inner_val
1941 }
1942 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1943 #[no_mangle]
1944 pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1945         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1946 }
1947 /// Minimum depth of the funding transaction before the channel is considered open
1948 #[no_mangle]
1949 pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 {
1950         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1951         *inner_val
1952 }
1953 /// Minimum depth of the funding transaction before the channel is considered open
1954 #[no_mangle]
1955 pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) {
1956         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1957 }
1958 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1959 /// broadcast a commitment transaction
1960 #[no_mangle]
1961 pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 {
1962         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1963         *inner_val
1964 }
1965 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1966 /// broadcast a commitment transaction
1967 #[no_mangle]
1968 pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1969         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1970 }
1971 /// The maximum number of inbound HTLCs towards channel acceptor
1972 #[no_mangle]
1973 pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 {
1974         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1975         *inner_val
1976 }
1977 /// The maximum number of inbound HTLCs towards channel acceptor
1978 #[no_mangle]
1979 pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1980         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1981 }
1982 /// The channel acceptor's key controlling the funding transaction
1983 #[no_mangle]
1984 pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1985         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1986         crate::c_types::PublicKey::from_rust(&inner_val)
1987 }
1988 /// The channel acceptor's key controlling the funding transaction
1989 #[no_mangle]
1990 pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1991         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1992 }
1993 /// Used to derive a revocation key for transactions broadcast by counterparty
1994 #[no_mangle]
1995 pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1996         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1997         crate::c_types::PublicKey::from_rust(&inner_val)
1998 }
1999 /// Used to derive a revocation key for transactions broadcast by counterparty
2000 #[no_mangle]
2001 pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2002         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
2003 }
2004 /// A payment key to channel acceptor for transactions broadcast by counterparty
2005 #[no_mangle]
2006 pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2007         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
2008         crate::c_types::PublicKey::from_rust(&inner_val)
2009 }
2010 /// A payment key to channel acceptor for transactions broadcast by counterparty
2011 #[no_mangle]
2012 pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2013         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
2014 }
2015 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2016 /// acceptor
2017 #[no_mangle]
2018 pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2019         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
2020         crate::c_types::PublicKey::from_rust(&inner_val)
2021 }
2022 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2023 /// acceptor
2024 #[no_mangle]
2025 pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2026         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
2027 }
2028 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2029 #[no_mangle]
2030 pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2031         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
2032         crate::c_types::PublicKey::from_rust(&inner_val)
2033 }
2034 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2035 #[no_mangle]
2036 pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2037         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
2038 }
2039 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2040 #[no_mangle]
2041 pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2042         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
2043         crate::c_types::PublicKey::from_rust(&inner_val)
2044 }
2045 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2046 #[no_mangle]
2047 pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2048         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
2049 }
2050 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2051 #[no_mangle]
2052 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2053         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2054         crate::c_types::PublicKey::from_rust(&inner_val)
2055 }
2056 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2057 #[no_mangle]
2058 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2059         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2060 }
2061 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2062 /// collaboratively close
2063 #[no_mangle]
2064 pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
2065         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
2066         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
2067         local_inner_val
2068 }
2069 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2070 /// collaboratively close
2071 #[no_mangle]
2072 pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
2073         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()) }})} };
2074         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
2075 }
2076 /// The channel type that this channel will represent. If none is set, we derive the channel
2077 /// type from the intersection of our feature bits with our counterparty's feature bits from
2078 /// the Init message.
2079 ///
2080 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2081 ///
2082 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2083 #[no_mangle]
2084 pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
2085         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
2086         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 };
2087         local_inner_val
2088 }
2089 /// The channel type that this channel will represent. If none is set, we derive the channel
2090 /// type from the intersection of our feature bits with our counterparty's feature bits from
2091 /// the Init message.
2092 ///
2093 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2094 ///
2095 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
2096 #[no_mangle]
2097 pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
2098         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2099         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
2100 }
2101 /// Optionally, a requirement that only confirmed inputs can be added
2102 #[no_mangle]
2103 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2104         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2105         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 /*  { () /**/ } */ };
2106         local_inner_val
2107 }
2108 /// Optionally, a requirement that only confirmed inputs can be added
2109 #[no_mangle]
2110 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2111         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2112         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2113 }
2114 /// Constructs a new AcceptChannelV2 given each field
2115 ///
2116 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
2117 #[must_use]
2118 #[no_mangle]
2119 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_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 {
2120         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()) }})} };
2121         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()) } }) };
2122         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2123         AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2124                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2125                 funding_satoshis: funding_satoshis_arg,
2126                 dust_limit_satoshis: dust_limit_satoshis_arg,
2127                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
2128                 htlc_minimum_msat: htlc_minimum_msat_arg,
2129                 minimum_depth: minimum_depth_arg,
2130                 to_self_delay: to_self_delay_arg,
2131                 max_accepted_htlcs: max_accepted_htlcs_arg,
2132                 funding_pubkey: funding_pubkey_arg.into_rust(),
2133                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
2134                 payment_basepoint: payment_basepoint_arg.into_rust(),
2135                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
2136                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
2137                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
2138                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2139                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
2140                 channel_type: local_channel_type_arg,
2141                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2142         }), is_owned: true }
2143 }
2144 impl Clone for AcceptChannelV2 {
2145         fn clone(&self) -> Self {
2146                 Self {
2147                         inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2148                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2149                         is_owned: true,
2150                 }
2151         }
2152 }
2153 #[allow(unused)]
2154 /// Used only if an object of this type is returned as a trait impl by a method
2155 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2156         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannelV2)).clone() })) as *mut c_void
2157 }
2158 #[no_mangle]
2159 /// Creates a copy of the AcceptChannelV2
2160 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2161         orig.clone()
2162 }
2163 /// Checks if two AcceptChannelV2s contain equal inner contents.
2164 /// This ignores pointers and is_owned flags and looks at the values in fields.
2165 /// Two objects with NULL inner values will be considered "equal" here.
2166 #[no_mangle]
2167 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2168         if a.inner == b.inner { return true; }
2169         if a.inner.is_null() || b.inner.is_null() { return false; }
2170         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2171 }
2172
2173 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2174 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2175
2176 /// A [`funding_created`] message to be sent to or received from a peer.
2177 ///
2178 /// Used in V1 channel establishment
2179 ///
2180 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2181 #[must_use]
2182 #[repr(C)]
2183 pub struct FundingCreated {
2184         /// A pointer to the opaque Rust object.
2185
2186         /// Nearly everywhere, inner must be non-null, however in places where
2187         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2188         pub inner: *mut nativeFundingCreated,
2189         /// Indicates that this is the only struct which contains the same pointer.
2190
2191         /// Rust functions which take ownership of an object provided via an argument require
2192         /// this to be true and invalidate the object pointed to by inner.
2193         pub is_owned: bool,
2194 }
2195
2196 impl Drop for FundingCreated {
2197         fn drop(&mut self) {
2198                 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2199                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2200                 }
2201         }
2202 }
2203 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2204 #[no_mangle]
2205 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2206 #[allow(unused)]
2207 /// Used only if an object of this type is returned as a trait impl by a method
2208 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2209         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2210 }
2211 #[allow(unused)]
2212 impl FundingCreated {
2213         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2214                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2215         }
2216         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2217                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2218         }
2219         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2220         pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2221                 assert!(self.is_owned);
2222                 let ret = ObjOps::untweak_ptr(self.inner);
2223                 self.inner = core::ptr::null_mut();
2224                 ret
2225         }
2226 }
2227 /// A temporary channel ID, until the funding is established
2228 #[no_mangle]
2229 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
2230         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2231         &inner_val.0
2232 }
2233 /// A temporary channel ID, until the funding is established
2234 #[no_mangle]
2235 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2236         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
2237 }
2238 /// The funding transaction ID
2239 #[no_mangle]
2240 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2241         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2242         inner_val.as_inner()
2243 }
2244 /// The funding transaction ID
2245 #[no_mangle]
2246 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2247         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2248 }
2249 /// The specific output index funding this channel
2250 #[no_mangle]
2251 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2252         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2253         *inner_val
2254 }
2255 /// The specific output index funding this channel
2256 #[no_mangle]
2257 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2258         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2259 }
2260 /// The signature of the channel initiator (funder) on the initial commitment transaction
2261 #[no_mangle]
2262 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::ECDSASignature {
2263         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2264         crate::c_types::ECDSASignature::from_rust(&inner_val)
2265 }
2266 /// The signature of the channel initiator (funder) on the initial commitment transaction
2267 #[no_mangle]
2268 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::ECDSASignature) {
2269         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2270 }
2271 /// Constructs a new FundingCreated given each field
2272 #[must_use]
2273 #[no_mangle]
2274 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::ECDSASignature) -> FundingCreated {
2275         FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2276                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2277                 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2278                 funding_output_index: funding_output_index_arg,
2279                 signature: signature_arg.into_rust(),
2280         }), is_owned: true }
2281 }
2282 impl Clone for FundingCreated {
2283         fn clone(&self) -> Self {
2284                 Self {
2285                         inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2286                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2287                         is_owned: true,
2288                 }
2289         }
2290 }
2291 #[allow(unused)]
2292 /// Used only if an object of this type is returned as a trait impl by a method
2293 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2294         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingCreated)).clone() })) as *mut c_void
2295 }
2296 #[no_mangle]
2297 /// Creates a copy of the FundingCreated
2298 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2299         orig.clone()
2300 }
2301 /// Checks if two FundingCreateds contain equal inner contents.
2302 /// This ignores pointers and is_owned flags and looks at the values in fields.
2303 /// Two objects with NULL inner values will be considered "equal" here.
2304 #[no_mangle]
2305 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2306         if a.inner == b.inner { return true; }
2307         if a.inner.is_null() || b.inner.is_null() { return false; }
2308         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2309 }
2310
2311 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2312 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2313
2314 /// A [`funding_signed`] message to be sent to or received from a peer.
2315 ///
2316 /// Used in V1 channel establishment
2317 ///
2318 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2319 #[must_use]
2320 #[repr(C)]
2321 pub struct FundingSigned {
2322         /// A pointer to the opaque Rust object.
2323
2324         /// Nearly everywhere, inner must be non-null, however in places where
2325         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2326         pub inner: *mut nativeFundingSigned,
2327         /// Indicates that this is the only struct which contains the same pointer.
2328
2329         /// Rust functions which take ownership of an object provided via an argument require
2330         /// this to be true and invalidate the object pointed to by inner.
2331         pub is_owned: bool,
2332 }
2333
2334 impl Drop for FundingSigned {
2335         fn drop(&mut self) {
2336                 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2337                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2338                 }
2339         }
2340 }
2341 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2342 #[no_mangle]
2343 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2344 #[allow(unused)]
2345 /// Used only if an object of this type is returned as a trait impl by a method
2346 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2347         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2348 }
2349 #[allow(unused)]
2350 impl FundingSigned {
2351         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2352                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2353         }
2354         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2355                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2356         }
2357         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2358         pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2359                 assert!(self.is_owned);
2360                 let ret = ObjOps::untweak_ptr(self.inner);
2361                 self.inner = core::ptr::null_mut();
2362                 ret
2363         }
2364 }
2365 /// The channel ID
2366 #[no_mangle]
2367 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
2368         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2369         &inner_val.0
2370 }
2371 /// The channel ID
2372 #[no_mangle]
2373 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2374         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2375 }
2376 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2377 #[no_mangle]
2378 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::ECDSASignature {
2379         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2380         crate::c_types::ECDSASignature::from_rust(&inner_val)
2381 }
2382 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2383 #[no_mangle]
2384 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::ECDSASignature) {
2385         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2386 }
2387 /// Constructs a new FundingSigned given each field
2388 #[must_use]
2389 #[no_mangle]
2390 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned {
2391         FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2392                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2393                 signature: signature_arg.into_rust(),
2394         }), is_owned: true }
2395 }
2396 impl Clone for FundingSigned {
2397         fn clone(&self) -> Self {
2398                 Self {
2399                         inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2400                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2401                         is_owned: true,
2402                 }
2403         }
2404 }
2405 #[allow(unused)]
2406 /// Used only if an object of this type is returned as a trait impl by a method
2407 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2408         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingSigned)).clone() })) as *mut c_void
2409 }
2410 #[no_mangle]
2411 /// Creates a copy of the FundingSigned
2412 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2413         orig.clone()
2414 }
2415 /// Checks if two FundingSigneds contain equal inner contents.
2416 /// This ignores pointers and is_owned flags and looks at the values in fields.
2417 /// Two objects with NULL inner values will be considered "equal" here.
2418 #[no_mangle]
2419 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2420         if a.inner == b.inner { return true; }
2421         if a.inner.is_null() || b.inner.is_null() { return false; }
2422         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2423 }
2424
2425 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2426 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2427
2428 /// A [`channel_ready`] message to be sent to or received from a peer.
2429 ///
2430 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2431 #[must_use]
2432 #[repr(C)]
2433 pub struct ChannelReady {
2434         /// A pointer to the opaque Rust object.
2435
2436         /// Nearly everywhere, inner must be non-null, however in places where
2437         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2438         pub inner: *mut nativeChannelReady,
2439         /// Indicates that this is the only struct which contains the same pointer.
2440
2441         /// Rust functions which take ownership of an object provided via an argument require
2442         /// this to be true and invalidate the object pointed to by inner.
2443         pub is_owned: bool,
2444 }
2445
2446 impl Drop for ChannelReady {
2447         fn drop(&mut self) {
2448                 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2449                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2450                 }
2451         }
2452 }
2453 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2454 #[no_mangle]
2455 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2456 #[allow(unused)]
2457 /// Used only if an object of this type is returned as a trait impl by a method
2458 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2459         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2460 }
2461 #[allow(unused)]
2462 impl ChannelReady {
2463         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2464                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2465         }
2466         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2467                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2468         }
2469         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2470         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2471                 assert!(self.is_owned);
2472                 let ret = ObjOps::untweak_ptr(self.inner);
2473                 self.inner = core::ptr::null_mut();
2474                 ret
2475         }
2476 }
2477 /// The channel ID
2478 #[no_mangle]
2479 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
2480         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2481         &inner_val.0
2482 }
2483 /// The channel ID
2484 #[no_mangle]
2485 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
2486         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2487 }
2488 /// The per-commitment point of the second commitment transaction
2489 #[no_mangle]
2490 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2491         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2492         crate::c_types::PublicKey::from_rust(&inner_val)
2493 }
2494 /// The per-commitment point of the second commitment transaction
2495 #[no_mangle]
2496 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2497         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2498 }
2499 /// If set, provides a `short_channel_id` alias for this channel.
2500 ///
2501 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2502 /// messages' recipient.
2503 #[no_mangle]
2504 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2505         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2506         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() }) };
2507         local_inner_val
2508 }
2509 /// If set, provides a `short_channel_id` alias for this channel.
2510 ///
2511 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2512 /// messages' recipient.
2513 #[no_mangle]
2514 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2515         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2516         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2517 }
2518 /// Constructs a new ChannelReady given each field
2519 #[must_use]
2520 #[no_mangle]
2521 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 {
2522         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 };
2523         ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2524                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2525                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2526                 short_channel_id_alias: local_short_channel_id_alias_arg,
2527         }), is_owned: true }
2528 }
2529 impl Clone for ChannelReady {
2530         fn clone(&self) -> Self {
2531                 Self {
2532                         inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2533                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2534                         is_owned: true,
2535                 }
2536         }
2537 }
2538 #[allow(unused)]
2539 /// Used only if an object of this type is returned as a trait impl by a method
2540 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2541         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReady)).clone() })) as *mut c_void
2542 }
2543 #[no_mangle]
2544 /// Creates a copy of the ChannelReady
2545 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2546         orig.clone()
2547 }
2548 /// Checks if two ChannelReadys contain equal inner contents.
2549 /// This ignores pointers and is_owned flags and looks at the values in fields.
2550 /// Two objects with NULL inner values will be considered "equal" here.
2551 #[no_mangle]
2552 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2553         if a.inner == b.inner { return true; }
2554         if a.inner.is_null() || b.inner.is_null() { return false; }
2555         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2556 }
2557
2558 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
2559 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
2560
2561 /// A tx_add_input message for adding an input during interactive transaction construction
2562 ///
2563 #[must_use]
2564 #[repr(C)]
2565 pub struct TxAddInput {
2566         /// A pointer to the opaque Rust object.
2567
2568         /// Nearly everywhere, inner must be non-null, however in places where
2569         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2570         pub inner: *mut nativeTxAddInput,
2571         /// Indicates that this is the only struct which contains the same pointer.
2572
2573         /// Rust functions which take ownership of an object provided via an argument require
2574         /// this to be true and invalidate the object pointed to by inner.
2575         pub is_owned: bool,
2576 }
2577
2578 impl Drop for TxAddInput {
2579         fn drop(&mut self) {
2580                 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
2581                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2582                 }
2583         }
2584 }
2585 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
2586 #[no_mangle]
2587 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
2588 #[allow(unused)]
2589 /// Used only if an object of this type is returned as a trait impl by a method
2590 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
2591         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
2592 }
2593 #[allow(unused)]
2594 impl TxAddInput {
2595         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
2596                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2597         }
2598         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
2599                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2600         }
2601         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2602         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
2603                 assert!(self.is_owned);
2604                 let ret = ObjOps::untweak_ptr(self.inner);
2605                 self.inner = core::ptr::null_mut();
2606                 ret
2607         }
2608 }
2609 /// The channel ID
2610 #[no_mangle]
2611 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] {
2612         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2613         &inner_val.0
2614 }
2615 /// The channel ID
2616 #[no_mangle]
2617 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) {
2618         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2619 }
2620 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2621 /// non-initiators.
2622 #[no_mangle]
2623 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
2624         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2625         *inner_val
2626 }
2627 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2628 /// non-initiators.
2629 #[no_mangle]
2630 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
2631         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2632 }
2633 /// Serialized transaction that contains the output this input spends to verify that it is non
2634 /// malleable.
2635 #[no_mangle]
2636 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
2637         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
2638         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 }
2639 }
2640 /// Serialized transaction that contains the output this input spends to verify that it is non
2641 /// malleable.
2642 #[no_mangle]
2643 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
2644         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
2645 }
2646 /// The index of the output being spent
2647 #[no_mangle]
2648 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
2649         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
2650         *inner_val
2651 }
2652 /// The index of the output being spent
2653 #[no_mangle]
2654 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
2655         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
2656 }
2657 /// The sequence number of this input
2658 #[no_mangle]
2659 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
2660         let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
2661         *inner_val
2662 }
2663 /// The sequence number of this input
2664 #[no_mangle]
2665 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
2666         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
2667 }
2668 /// Constructs a new TxAddInput given each field
2669 #[must_use]
2670 #[no_mangle]
2671 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 {
2672         TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
2673                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2674                 serial_id: serial_id_arg,
2675                 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
2676                 prevtx_out: prevtx_out_arg,
2677                 sequence: sequence_arg,
2678         }), is_owned: true }
2679 }
2680 impl Clone for TxAddInput {
2681         fn clone(&self) -> Self {
2682                 Self {
2683                         inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2684                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2685                         is_owned: true,
2686                 }
2687         }
2688 }
2689 #[allow(unused)]
2690 /// Used only if an object of this type is returned as a trait impl by a method
2691 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2692         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddInput)).clone() })) as *mut c_void
2693 }
2694 #[no_mangle]
2695 /// Creates a copy of the TxAddInput
2696 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
2697         orig.clone()
2698 }
2699 /// Checks if two TxAddInputs contain equal inner contents.
2700 /// This ignores pointers and is_owned flags and looks at the values in fields.
2701 /// Two objects with NULL inner values will be considered "equal" here.
2702 #[no_mangle]
2703 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
2704         if a.inner == b.inner { return true; }
2705         if a.inner.is_null() || b.inner.is_null() { return false; }
2706         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2707 }
2708
2709 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
2710 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
2711
2712 /// A tx_add_output message for adding an output during interactive transaction construction.
2713 ///
2714 #[must_use]
2715 #[repr(C)]
2716 pub struct TxAddOutput {
2717         /// A pointer to the opaque Rust object.
2718
2719         /// Nearly everywhere, inner must be non-null, however in places where
2720         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2721         pub inner: *mut nativeTxAddOutput,
2722         /// Indicates that this is the only struct which contains the same pointer.
2723
2724         /// Rust functions which take ownership of an object provided via an argument require
2725         /// this to be true and invalidate the object pointed to by inner.
2726         pub is_owned: bool,
2727 }
2728
2729 impl Drop for TxAddOutput {
2730         fn drop(&mut self) {
2731                 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
2732                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2733                 }
2734         }
2735 }
2736 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
2737 #[no_mangle]
2738 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
2739 #[allow(unused)]
2740 /// Used only if an object of this type is returned as a trait impl by a method
2741 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
2742         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
2743 }
2744 #[allow(unused)]
2745 impl TxAddOutput {
2746         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
2747                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2748         }
2749         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
2750                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2751         }
2752         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2753         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
2754                 assert!(self.is_owned);
2755                 let ret = ObjOps::untweak_ptr(self.inner);
2756                 self.inner = core::ptr::null_mut();
2757                 ret
2758         }
2759 }
2760 /// The channel ID
2761 #[no_mangle]
2762 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] {
2763         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2764         &inner_val.0
2765 }
2766 /// The channel ID
2767 #[no_mangle]
2768 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) {
2769         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2770 }
2771 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2772 /// non-initiators.
2773 #[no_mangle]
2774 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
2775         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2776         *inner_val
2777 }
2778 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2779 /// non-initiators.
2780 #[no_mangle]
2781 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
2782         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2783 }
2784 /// The satoshi value of the output
2785 #[no_mangle]
2786 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
2787         let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
2788         *inner_val
2789 }
2790 /// The satoshi value of the output
2791 #[no_mangle]
2792 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
2793         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
2794 }
2795 /// The scriptPubKey for the output
2796 #[no_mangle]
2797 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::u8slice {
2798         let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
2799         crate::c_types::u8slice::from_slice(&inner_val[..])
2800 }
2801 /// The scriptPubKey for the output
2802 #[no_mangle]
2803 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
2804         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::Script::from(val.into_rust());
2805 }
2806 /// Constructs a new TxAddOutput given each field
2807 #[must_use]
2808 #[no_mangle]
2809 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 {
2810         TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
2811                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2812                 serial_id: serial_id_arg,
2813                 sats: sats_arg,
2814                 script: ::bitcoin::blockdata::script::Script::from(script_arg.into_rust()),
2815         }), is_owned: true }
2816 }
2817 impl Clone for TxAddOutput {
2818         fn clone(&self) -> Self {
2819                 Self {
2820                         inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
2821                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2822                         is_owned: true,
2823                 }
2824         }
2825 }
2826 #[allow(unused)]
2827 /// Used only if an object of this type is returned as a trait impl by a method
2828 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2829         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddOutput)).clone() })) as *mut c_void
2830 }
2831 #[no_mangle]
2832 /// Creates a copy of the TxAddOutput
2833 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
2834         orig.clone()
2835 }
2836 /// Checks if two TxAddOutputs contain equal inner contents.
2837 /// This ignores pointers and is_owned flags and looks at the values in fields.
2838 /// Two objects with NULL inner values will be considered "equal" here.
2839 #[no_mangle]
2840 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
2841         if a.inner == b.inner { return true; }
2842         if a.inner.is_null() || b.inner.is_null() { return false; }
2843         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2844 }
2845
2846 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
2847 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
2848
2849 /// A tx_remove_input message for removing an input during interactive transaction construction.
2850 ///
2851 #[must_use]
2852 #[repr(C)]
2853 pub struct TxRemoveInput {
2854         /// A pointer to the opaque Rust object.
2855
2856         /// Nearly everywhere, inner must be non-null, however in places where
2857         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2858         pub inner: *mut nativeTxRemoveInput,
2859         /// Indicates that this is the only struct which contains the same pointer.
2860
2861         /// Rust functions which take ownership of an object provided via an argument require
2862         /// this to be true and invalidate the object pointed to by inner.
2863         pub is_owned: bool,
2864 }
2865
2866 impl Drop for TxRemoveInput {
2867         fn drop(&mut self) {
2868                 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
2869                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2870                 }
2871         }
2872 }
2873 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
2874 #[no_mangle]
2875 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
2876 #[allow(unused)]
2877 /// Used only if an object of this type is returned as a trait impl by a method
2878 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
2879         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
2880 }
2881 #[allow(unused)]
2882 impl TxRemoveInput {
2883         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
2884                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2885         }
2886         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
2887                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2888         }
2889         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2890         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
2891                 assert!(self.is_owned);
2892                 let ret = ObjOps::untweak_ptr(self.inner);
2893                 self.inner = core::ptr::null_mut();
2894                 ret
2895         }
2896 }
2897 /// The channel ID
2898 #[no_mangle]
2899 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] {
2900         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2901         &inner_val.0
2902 }
2903 /// The channel ID
2904 #[no_mangle]
2905 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) {
2906         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2907 }
2908 /// The serial ID of the input to be removed
2909 #[no_mangle]
2910 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
2911         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2912         *inner_val
2913 }
2914 /// The serial ID of the input to be removed
2915 #[no_mangle]
2916 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
2917         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2918 }
2919 /// Constructs a new TxRemoveInput given each field
2920 #[must_use]
2921 #[no_mangle]
2922 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput {
2923         TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
2924                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2925                 serial_id: serial_id_arg,
2926         }), is_owned: true }
2927 }
2928 impl Clone for TxRemoveInput {
2929         fn clone(&self) -> Self {
2930                 Self {
2931                         inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2932                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2933                         is_owned: true,
2934                 }
2935         }
2936 }
2937 #[allow(unused)]
2938 /// Used only if an object of this type is returned as a trait impl by a method
2939 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2940         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveInput)).clone() })) as *mut c_void
2941 }
2942 #[no_mangle]
2943 /// Creates a copy of the TxRemoveInput
2944 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
2945         orig.clone()
2946 }
2947 /// Checks if two TxRemoveInputs contain equal inner contents.
2948 /// This ignores pointers and is_owned flags and looks at the values in fields.
2949 /// Two objects with NULL inner values will be considered "equal" here.
2950 #[no_mangle]
2951 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
2952         if a.inner == b.inner { return true; }
2953         if a.inner.is_null() || b.inner.is_null() { return false; }
2954         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2955 }
2956
2957 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
2958 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
2959
2960 /// A tx_remove_output message for removing an output during interactive transaction construction.
2961 ///
2962 #[must_use]
2963 #[repr(C)]
2964 pub struct TxRemoveOutput {
2965         /// A pointer to the opaque Rust object.
2966
2967         /// Nearly everywhere, inner must be non-null, however in places where
2968         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2969         pub inner: *mut nativeTxRemoveOutput,
2970         /// Indicates that this is the only struct which contains the same pointer.
2971
2972         /// Rust functions which take ownership of an object provided via an argument require
2973         /// this to be true and invalidate the object pointed to by inner.
2974         pub is_owned: bool,
2975 }
2976
2977 impl Drop for TxRemoveOutput {
2978         fn drop(&mut self) {
2979                 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
2980                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2981                 }
2982         }
2983 }
2984 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
2985 #[no_mangle]
2986 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
2987 #[allow(unused)]
2988 /// Used only if an object of this type is returned as a trait impl by a method
2989 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
2990         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
2991 }
2992 #[allow(unused)]
2993 impl TxRemoveOutput {
2994         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
2995                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2996         }
2997         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
2998                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2999         }
3000         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3001         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
3002                 assert!(self.is_owned);
3003                 let ret = ObjOps::untweak_ptr(self.inner);
3004                 self.inner = core::ptr::null_mut();
3005                 ret
3006         }
3007 }
3008 /// The channel ID
3009 #[no_mangle]
3010 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] {
3011         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3012         &inner_val.0
3013 }
3014 /// The channel ID
3015 #[no_mangle]
3016 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) {
3017         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3018 }
3019 /// The serial ID of the output to be removed
3020 #[no_mangle]
3021 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3022         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3023         *inner_val
3024 }
3025 /// The serial ID of the output to be removed
3026 #[no_mangle]
3027 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3028         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3029 }
3030 /// Constructs a new TxRemoveOutput given each field
3031 #[must_use]
3032 #[no_mangle]
3033 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput {
3034         TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3035                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3036                 serial_id: serial_id_arg,
3037         }), is_owned: true }
3038 }
3039 impl Clone for TxRemoveOutput {
3040         fn clone(&self) -> Self {
3041                 Self {
3042                         inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3043                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3044                         is_owned: true,
3045                 }
3046         }
3047 }
3048 #[allow(unused)]
3049 /// Used only if an object of this type is returned as a trait impl by a method
3050 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3051         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveOutput)).clone() })) as *mut c_void
3052 }
3053 #[no_mangle]
3054 /// Creates a copy of the TxRemoveOutput
3055 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3056         orig.clone()
3057 }
3058 /// Checks if two TxRemoveOutputs contain equal inner contents.
3059 /// This ignores pointers and is_owned flags and looks at the values in fields.
3060 /// Two objects with NULL inner values will be considered "equal" here.
3061 #[no_mangle]
3062 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3063         if a.inner == b.inner { return true; }
3064         if a.inner.is_null() || b.inner.is_null() { return false; }
3065         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3066 }
3067
3068 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3069 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3070
3071 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3072 /// interactive transaction construction.
3073 ///
3074 #[must_use]
3075 #[repr(C)]
3076 pub struct TxComplete {
3077         /// A pointer to the opaque Rust object.
3078
3079         /// Nearly everywhere, inner must be non-null, however in places where
3080         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3081         pub inner: *mut nativeTxComplete,
3082         /// Indicates that this is the only struct which contains the same pointer.
3083
3084         /// Rust functions which take ownership of an object provided via an argument require
3085         /// this to be true and invalidate the object pointed to by inner.
3086         pub is_owned: bool,
3087 }
3088
3089 impl Drop for TxComplete {
3090         fn drop(&mut self) {
3091                 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3092                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3093                 }
3094         }
3095 }
3096 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3097 #[no_mangle]
3098 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3099 #[allow(unused)]
3100 /// Used only if an object of this type is returned as a trait impl by a method
3101 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3102         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3103 }
3104 #[allow(unused)]
3105 impl TxComplete {
3106         pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3107                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3108         }
3109         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3110                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3111         }
3112         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3113         pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3114                 assert!(self.is_owned);
3115                 let ret = ObjOps::untweak_ptr(self.inner);
3116                 self.inner = core::ptr::null_mut();
3117                 ret
3118         }
3119 }
3120 /// The channel ID
3121 #[no_mangle]
3122 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] {
3123         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3124         &inner_val.0
3125 }
3126 /// The channel ID
3127 #[no_mangle]
3128 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) {
3129         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3130 }
3131 /// Constructs a new TxComplete given each field
3132 #[must_use]
3133 #[no_mangle]
3134 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete {
3135         TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3136                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3137         }), is_owned: true }
3138 }
3139 impl Clone for TxComplete {
3140         fn clone(&self) -> Self {
3141                 Self {
3142                         inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3143                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3144                         is_owned: true,
3145                 }
3146         }
3147 }
3148 #[allow(unused)]
3149 /// Used only if an object of this type is returned as a trait impl by a method
3150 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3151         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxComplete)).clone() })) as *mut c_void
3152 }
3153 #[no_mangle]
3154 /// Creates a copy of the TxComplete
3155 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3156         orig.clone()
3157 }
3158 /// Checks if two TxCompletes contain equal inner contents.
3159 /// This ignores pointers and is_owned flags and looks at the values in fields.
3160 /// Two objects with NULL inner values will be considered "equal" here.
3161 #[no_mangle]
3162 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3163         if a.inner == b.inner { return true; }
3164         if a.inner.is_null() || b.inner.is_null() { return false; }
3165         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3166 }
3167
3168 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3169 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3170
3171 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3172 /// interactive transaction construction.
3173 ///
3174 #[must_use]
3175 #[repr(C)]
3176 pub struct TxSignatures {
3177         /// A pointer to the opaque Rust object.
3178
3179         /// Nearly everywhere, inner must be non-null, however in places where
3180         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3181         pub inner: *mut nativeTxSignatures,
3182         /// Indicates that this is the only struct which contains the same pointer.
3183
3184         /// Rust functions which take ownership of an object provided via an argument require
3185         /// this to be true and invalidate the object pointed to by inner.
3186         pub is_owned: bool,
3187 }
3188
3189 impl Drop for TxSignatures {
3190         fn drop(&mut self) {
3191                 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3192                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3193                 }
3194         }
3195 }
3196 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3197 #[no_mangle]
3198 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3199 #[allow(unused)]
3200 /// Used only if an object of this type is returned as a trait impl by a method
3201 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3202         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3203 }
3204 #[allow(unused)]
3205 impl TxSignatures {
3206         pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3207                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3208         }
3209         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3210                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3211         }
3212         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3213         pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3214                 assert!(self.is_owned);
3215                 let ret = ObjOps::untweak_ptr(self.inner);
3216                 self.inner = core::ptr::null_mut();
3217                 ret
3218         }
3219 }
3220 /// The channel ID
3221 #[no_mangle]
3222 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] {
3223         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3224         &inner_val.0
3225 }
3226 /// The channel ID
3227 #[no_mangle]
3228 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3229         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3230 }
3231 /// The TXID
3232 #[no_mangle]
3233 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3234         let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3235         inner_val.as_inner()
3236 }
3237 /// The TXID
3238 #[no_mangle]
3239 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3240         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3241 }
3242 /// The list of witnesses
3243 ///
3244 /// Returns a copy of the field.
3245 #[no_mangle]
3246 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3247         let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
3248         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) }); };
3249         local_inner_val.into()
3250 }
3251 /// The list of witnesses
3252 #[no_mangle]
3253 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
3254         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
3255         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
3256 }
3257 /// Constructs a new TxSignatures given each field
3258 #[must_use]
3259 #[no_mangle]
3260 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 {
3261         let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
3262         TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
3263                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3264                 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
3265                 witnesses: local_witnesses_arg,
3266         }), is_owned: true }
3267 }
3268 impl Clone for TxSignatures {
3269         fn clone(&self) -> Self {
3270                 Self {
3271                         inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3272                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3273                         is_owned: true,
3274                 }
3275         }
3276 }
3277 #[allow(unused)]
3278 /// Used only if an object of this type is returned as a trait impl by a method
3279 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3280         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxSignatures)).clone() })) as *mut c_void
3281 }
3282 #[no_mangle]
3283 /// Creates a copy of the TxSignatures
3284 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
3285         orig.clone()
3286 }
3287 /// Checks if two TxSignaturess contain equal inner contents.
3288 /// This ignores pointers and is_owned flags and looks at the values in fields.
3289 /// Two objects with NULL inner values will be considered "equal" here.
3290 #[no_mangle]
3291 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
3292         if a.inner == b.inner { return true; }
3293         if a.inner.is_null() || b.inner.is_null() { return false; }
3294         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3295 }
3296
3297 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
3298 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
3299
3300 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
3301 /// completed.
3302 ///
3303 #[must_use]
3304 #[repr(C)]
3305 pub struct TxInitRbf {
3306         /// A pointer to the opaque Rust object.
3307
3308         /// Nearly everywhere, inner must be non-null, however in places where
3309         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3310         pub inner: *mut nativeTxInitRbf,
3311         /// Indicates that this is the only struct which contains the same pointer.
3312
3313         /// Rust functions which take ownership of an object provided via an argument require
3314         /// this to be true and invalidate the object pointed to by inner.
3315         pub is_owned: bool,
3316 }
3317
3318 impl Drop for TxInitRbf {
3319         fn drop(&mut self) {
3320                 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
3321                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3322                 }
3323         }
3324 }
3325 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
3326 #[no_mangle]
3327 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
3328 #[allow(unused)]
3329 /// Used only if an object of this type is returned as a trait impl by a method
3330 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
3331         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
3332 }
3333 #[allow(unused)]
3334 impl TxInitRbf {
3335         pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
3336                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3337         }
3338         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
3339                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3340         }
3341         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3342         pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
3343                 assert!(self.is_owned);
3344                 let ret = ObjOps::untweak_ptr(self.inner);
3345                 self.inner = core::ptr::null_mut();
3346                 ret
3347         }
3348 }
3349 /// The channel ID
3350 #[no_mangle]
3351 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] {
3352         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3353         &inner_val.0
3354 }
3355 /// The channel ID
3356 #[no_mangle]
3357 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3358         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3359 }
3360 /// The locktime of the transaction
3361 #[no_mangle]
3362 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
3363         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
3364         *inner_val
3365 }
3366 /// The locktime of the transaction
3367 #[no_mangle]
3368 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
3369         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
3370 }
3371 /// The feerate of the transaction
3372 #[no_mangle]
3373 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
3374         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
3375         *inner_val
3376 }
3377 /// The feerate of the transaction
3378 #[no_mangle]
3379 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
3380         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
3381 }
3382 /// The number of satoshis the sender will contribute to or, if negative, remove from
3383 /// (e.g. splice-out) the funding output of the transaction
3384 #[no_mangle]
3385 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
3386         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3387         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() }) };
3388         local_inner_val
3389 }
3390 /// The number of satoshis the sender will contribute to or, if negative, remove from
3391 /// (e.g. splice-out) the funding output of the transaction
3392 #[no_mangle]
3393 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
3394         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3395         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3396 }
3397 /// Constructs a new TxInitRbf given each field
3398 #[must_use]
3399 #[no_mangle]
3400 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 {
3401         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3402         TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
3403                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3404                 locktime: locktime_arg,
3405                 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
3406                 funding_output_contribution: local_funding_output_contribution_arg,
3407         }), is_owned: true }
3408 }
3409 impl Clone for TxInitRbf {
3410         fn clone(&self) -> Self {
3411                 Self {
3412                         inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3413                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3414                         is_owned: true,
3415                 }
3416         }
3417 }
3418 #[allow(unused)]
3419 /// Used only if an object of this type is returned as a trait impl by a method
3420 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3421         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxInitRbf)).clone() })) as *mut c_void
3422 }
3423 #[no_mangle]
3424 /// Creates a copy of the TxInitRbf
3425 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
3426         orig.clone()
3427 }
3428 /// Checks if two TxInitRbfs contain equal inner contents.
3429 /// This ignores pointers and is_owned flags and looks at the values in fields.
3430 /// Two objects with NULL inner values will be considered "equal" here.
3431 #[no_mangle]
3432 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
3433         if a.inner == b.inner { return true; }
3434         if a.inner.is_null() || b.inner.is_null() { return false; }
3435         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3436 }
3437
3438 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
3439 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
3440
3441 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
3442 /// completed.
3443 ///
3444 #[must_use]
3445 #[repr(C)]
3446 pub struct TxAckRbf {
3447         /// A pointer to the opaque Rust object.
3448
3449         /// Nearly everywhere, inner must be non-null, however in places where
3450         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3451         pub inner: *mut nativeTxAckRbf,
3452         /// Indicates that this is the only struct which contains the same pointer.
3453
3454         /// Rust functions which take ownership of an object provided via an argument require
3455         /// this to be true and invalidate the object pointed to by inner.
3456         pub is_owned: bool,
3457 }
3458
3459 impl Drop for TxAckRbf {
3460         fn drop(&mut self) {
3461                 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
3462                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3463                 }
3464         }
3465 }
3466 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
3467 #[no_mangle]
3468 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
3469 #[allow(unused)]
3470 /// Used only if an object of this type is returned as a trait impl by a method
3471 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
3472         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
3473 }
3474 #[allow(unused)]
3475 impl TxAckRbf {
3476         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
3477                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3478         }
3479         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
3480                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3481         }
3482         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3483         pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
3484                 assert!(self.is_owned);
3485                 let ret = ObjOps::untweak_ptr(self.inner);
3486                 self.inner = core::ptr::null_mut();
3487                 ret
3488         }
3489 }
3490 /// The channel ID
3491 #[no_mangle]
3492 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] {
3493         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3494         &inner_val.0
3495 }
3496 /// The channel ID
3497 #[no_mangle]
3498 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3499         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3500 }
3501 /// The number of satoshis the sender will contribute to or, if negative, remove from
3502 /// (e.g. splice-out) the funding output of the transaction
3503 #[no_mangle]
3504 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
3505         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3506         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() }) };
3507         local_inner_val
3508 }
3509 /// The number of satoshis the sender will contribute to or, if negative, remove from
3510 /// (e.g. splice-out) the funding output of the transaction
3511 #[no_mangle]
3512 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
3513         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3514         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3515 }
3516 /// Constructs a new TxAckRbf given each field
3517 #[must_use]
3518 #[no_mangle]
3519 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 {
3520         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3521         TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
3522                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3523                 funding_output_contribution: local_funding_output_contribution_arg,
3524         }), is_owned: true }
3525 }
3526 impl Clone for TxAckRbf {
3527         fn clone(&self) -> Self {
3528                 Self {
3529                         inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3530                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3531                         is_owned: true,
3532                 }
3533         }
3534 }
3535 #[allow(unused)]
3536 /// Used only if an object of this type is returned as a trait impl by a method
3537 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3538         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAckRbf)).clone() })) as *mut c_void
3539 }
3540 #[no_mangle]
3541 /// Creates a copy of the TxAckRbf
3542 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
3543         orig.clone()
3544 }
3545 /// Checks if two TxAckRbfs contain equal inner contents.
3546 /// This ignores pointers and is_owned flags and looks at the values in fields.
3547 /// Two objects with NULL inner values will be considered "equal" here.
3548 #[no_mangle]
3549 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
3550         if a.inner == b.inner { return true; }
3551         if a.inner.is_null() || b.inner.is_null() { return false; }
3552         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3553 }
3554
3555 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
3556 pub(crate) type nativeTxAbort = nativeTxAbortImport;
3557
3558 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
3559 ///
3560 #[must_use]
3561 #[repr(C)]
3562 pub struct TxAbort {
3563         /// A pointer to the opaque Rust object.
3564
3565         /// Nearly everywhere, inner must be non-null, however in places where
3566         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3567         pub inner: *mut nativeTxAbort,
3568         /// Indicates that this is the only struct which contains the same pointer.
3569
3570         /// Rust functions which take ownership of an object provided via an argument require
3571         /// this to be true and invalidate the object pointed to by inner.
3572         pub is_owned: bool,
3573 }
3574
3575 impl Drop for TxAbort {
3576         fn drop(&mut self) {
3577                 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
3578                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3579                 }
3580         }
3581 }
3582 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
3583 #[no_mangle]
3584 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
3585 #[allow(unused)]
3586 /// Used only if an object of this type is returned as a trait impl by a method
3587 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
3588         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
3589 }
3590 #[allow(unused)]
3591 impl TxAbort {
3592         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
3593                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3594         }
3595         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
3596                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3597         }
3598         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3599         pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
3600                 assert!(self.is_owned);
3601                 let ret = ObjOps::untweak_ptr(self.inner);
3602                 self.inner = core::ptr::null_mut();
3603                 ret
3604         }
3605 }
3606 /// The channel ID
3607 #[no_mangle]
3608 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] {
3609         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3610         &inner_val.0
3611 }
3612 /// The channel ID
3613 #[no_mangle]
3614 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) {
3615         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3616 }
3617 /// Message data
3618 ///
3619 /// Returns a copy of the field.
3620 #[no_mangle]
3621 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
3622         let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
3623         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
3624         local_inner_val.into()
3625 }
3626 /// Message data
3627 #[no_mangle]
3628 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
3629         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3630         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
3631 }
3632 /// Constructs a new TxAbort given each field
3633 #[must_use]
3634 #[no_mangle]
3635 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
3636         let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
3637         TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
3638                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3639                 data: local_data_arg,
3640         }), is_owned: true }
3641 }
3642 impl Clone for TxAbort {
3643         fn clone(&self) -> Self {
3644                 Self {
3645                         inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
3646                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3647                         is_owned: true,
3648                 }
3649         }
3650 }
3651 #[allow(unused)]
3652 /// Used only if an object of this type is returned as a trait impl by a method
3653 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
3654         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAbort)).clone() })) as *mut c_void
3655 }
3656 #[no_mangle]
3657 /// Creates a copy of the TxAbort
3658 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
3659         orig.clone()
3660 }
3661 /// Checks if two TxAborts contain equal inner contents.
3662 /// This ignores pointers and is_owned flags and looks at the values in fields.
3663 /// Two objects with NULL inner values will be considered "equal" here.
3664 #[no_mangle]
3665 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
3666         if a.inner == b.inner { return true; }
3667         if a.inner.is_null() || b.inner.is_null() { return false; }
3668         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3669 }
3670
3671 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
3672 pub(crate) type nativeShutdown = nativeShutdownImport;
3673
3674 /// A [`shutdown`] message to be sent to or received from a peer.
3675 ///
3676 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
3677 #[must_use]
3678 #[repr(C)]
3679 pub struct Shutdown {
3680         /// A pointer to the opaque Rust object.
3681
3682         /// Nearly everywhere, inner must be non-null, however in places where
3683         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3684         pub inner: *mut nativeShutdown,
3685         /// Indicates that this is the only struct which contains the same pointer.
3686
3687         /// Rust functions which take ownership of an object provided via an argument require
3688         /// this to be true and invalidate the object pointed to by inner.
3689         pub is_owned: bool,
3690 }
3691
3692 impl Drop for Shutdown {
3693         fn drop(&mut self) {
3694                 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
3695                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3696                 }
3697         }
3698 }
3699 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
3700 #[no_mangle]
3701 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
3702 #[allow(unused)]
3703 /// Used only if an object of this type is returned as a trait impl by a method
3704 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
3705         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
3706 }
3707 #[allow(unused)]
3708 impl Shutdown {
3709         pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
3710                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3711         }
3712         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
3713                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3714         }
3715         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3716         pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
3717                 assert!(self.is_owned);
3718                 let ret = ObjOps::untweak_ptr(self.inner);
3719                 self.inner = core::ptr::null_mut();
3720                 ret
3721         }
3722 }
3723 /// The channel ID
3724 #[no_mangle]
3725 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
3726         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3727         &inner_val.0
3728 }
3729 /// The channel ID
3730 #[no_mangle]
3731 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
3732         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3733 }
3734 /// The destination of this peer's funds on closing.
3735 ///
3736 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3737 #[no_mangle]
3738 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
3739         let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
3740         crate::c_types::u8slice::from_slice(&inner_val[..])
3741 }
3742 /// The destination of this peer's funds on closing.
3743 ///
3744 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3745 #[no_mangle]
3746 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
3747         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
3748 }
3749 /// Constructs a new Shutdown given each field
3750 #[must_use]
3751 #[no_mangle]
3752 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
3753         Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
3754                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3755                 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
3756         }), is_owned: true }
3757 }
3758 impl Clone for Shutdown {
3759         fn clone(&self) -> Self {
3760                 Self {
3761                         inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
3762                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3763                         is_owned: true,
3764                 }
3765         }
3766 }
3767 #[allow(unused)]
3768 /// Used only if an object of this type is returned as a trait impl by a method
3769 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
3770         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeShutdown)).clone() })) as *mut c_void
3771 }
3772 #[no_mangle]
3773 /// Creates a copy of the Shutdown
3774 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
3775         orig.clone()
3776 }
3777 /// Checks if two Shutdowns contain equal inner contents.
3778 /// This ignores pointers and is_owned flags and looks at the values in fields.
3779 /// Two objects with NULL inner values will be considered "equal" here.
3780 #[no_mangle]
3781 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
3782         if a.inner == b.inner { return true; }
3783         if a.inner.is_null() || b.inner.is_null() { return false; }
3784         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3785 }
3786
3787 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
3788 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
3789
3790 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
3791 ///
3792 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
3793 /// to use.
3794 #[must_use]
3795 #[repr(C)]
3796 pub struct ClosingSignedFeeRange {
3797         /// A pointer to the opaque Rust object.
3798
3799         /// Nearly everywhere, inner must be non-null, however in places where
3800         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3801         pub inner: *mut nativeClosingSignedFeeRange,
3802         /// Indicates that this is the only struct which contains the same pointer.
3803
3804         /// Rust functions which take ownership of an object provided via an argument require
3805         /// this to be true and invalidate the object pointed to by inner.
3806         pub is_owned: bool,
3807 }
3808
3809 impl Drop for ClosingSignedFeeRange {
3810         fn drop(&mut self) {
3811                 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
3812                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3813                 }
3814         }
3815 }
3816 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
3817 #[no_mangle]
3818 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
3819 #[allow(unused)]
3820 /// Used only if an object of this type is returned as a trait impl by a method
3821 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
3822         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
3823 }
3824 #[allow(unused)]
3825 impl ClosingSignedFeeRange {
3826         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
3827                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3828         }
3829         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
3830                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3831         }
3832         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3833         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
3834                 assert!(self.is_owned);
3835                 let ret = ObjOps::untweak_ptr(self.inner);
3836                 self.inner = core::ptr::null_mut();
3837                 ret
3838         }
3839 }
3840 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3841 /// transaction.
3842 #[no_mangle]
3843 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3844         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
3845         *inner_val
3846 }
3847 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3848 /// transaction.
3849 #[no_mangle]
3850 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3851         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
3852 }
3853 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3854 /// transaction.
3855 #[no_mangle]
3856 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3857         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
3858         *inner_val
3859 }
3860 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3861 /// transaction.
3862 #[no_mangle]
3863 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3864         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
3865 }
3866 /// Constructs a new ClosingSignedFeeRange given each field
3867 #[must_use]
3868 #[no_mangle]
3869 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
3870         ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
3871                 min_fee_satoshis: min_fee_satoshis_arg,
3872                 max_fee_satoshis: max_fee_satoshis_arg,
3873         }), is_owned: true }
3874 }
3875 impl Clone for ClosingSignedFeeRange {
3876         fn clone(&self) -> Self {
3877                 Self {
3878                         inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
3879                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3880                         is_owned: true,
3881                 }
3882         }
3883 }
3884 #[allow(unused)]
3885 /// Used only if an object of this type is returned as a trait impl by a method
3886 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3887         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSignedFeeRange)).clone() })) as *mut c_void
3888 }
3889 #[no_mangle]
3890 /// Creates a copy of the ClosingSignedFeeRange
3891 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
3892         orig.clone()
3893 }
3894 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
3895 /// This ignores pointers and is_owned flags and looks at the values in fields.
3896 /// Two objects with NULL inner values will be considered "equal" here.
3897 #[no_mangle]
3898 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
3899         if a.inner == b.inner { return true; }
3900         if a.inner.is_null() || b.inner.is_null() { return false; }
3901         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3902 }
3903
3904 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
3905 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
3906
3907 /// A [`closing_signed`] message to be sent to or received from a peer.
3908 ///
3909 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
3910 #[must_use]
3911 #[repr(C)]
3912 pub struct ClosingSigned {
3913         /// A pointer to the opaque Rust object.
3914
3915         /// Nearly everywhere, inner must be non-null, however in places where
3916         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3917         pub inner: *mut nativeClosingSigned,
3918         /// Indicates that this is the only struct which contains the same pointer.
3919
3920         /// Rust functions which take ownership of an object provided via an argument require
3921         /// this to be true and invalidate the object pointed to by inner.
3922         pub is_owned: bool,
3923 }
3924
3925 impl Drop for ClosingSigned {
3926         fn drop(&mut self) {
3927                 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
3928                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3929                 }
3930         }
3931 }
3932 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
3933 #[no_mangle]
3934 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
3935 #[allow(unused)]
3936 /// Used only if an object of this type is returned as a trait impl by a method
3937 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
3938         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
3939 }
3940 #[allow(unused)]
3941 impl ClosingSigned {
3942         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
3943                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3944         }
3945         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
3946                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3947         }
3948         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3949         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
3950                 assert!(self.is_owned);
3951                 let ret = ObjOps::untweak_ptr(self.inner);
3952                 self.inner = core::ptr::null_mut();
3953                 ret
3954         }
3955 }
3956 /// The channel ID
3957 #[no_mangle]
3958 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
3959         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3960         &inner_val.0
3961 }
3962 /// The channel ID
3963 #[no_mangle]
3964 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
3965         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3966 }
3967 /// The proposed total fee for the closing transaction
3968 #[no_mangle]
3969 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
3970         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
3971         *inner_val
3972 }
3973 /// The proposed total fee for the closing transaction
3974 #[no_mangle]
3975 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
3976         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
3977 }
3978 /// A signature on the closing transaction
3979 #[no_mangle]
3980 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::ECDSASignature {
3981         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3982         crate::c_types::ECDSASignature::from_rust(&inner_val)
3983 }
3984 /// A signature on the closing transaction
3985 #[no_mangle]
3986 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ECDSASignature) {
3987         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3988 }
3989 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
3990 /// nodes.
3991 ///
3992 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
3993 #[no_mangle]
3994 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
3995         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
3996         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 };
3997         local_inner_val
3998 }
3999 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4000 /// nodes.
4001 ///
4002 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4003 #[no_mangle]
4004 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
4005         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4006         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
4007 }
4008 /// Constructs a new ClosingSigned given each field
4009 ///
4010 /// Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4011 #[must_use]
4012 #[no_mangle]
4013 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::ECDSASignature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
4014         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()) } }) };
4015         ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
4016                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4017                 fee_satoshis: fee_satoshis_arg,
4018                 signature: signature_arg.into_rust(),
4019                 fee_range: local_fee_range_arg,
4020         }), is_owned: true }
4021 }
4022 impl Clone for ClosingSigned {
4023         fn clone(&self) -> Self {
4024                 Self {
4025                         inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4026                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4027                         is_owned: true,
4028                 }
4029         }
4030 }
4031 #[allow(unused)]
4032 /// Used only if an object of this type is returned as a trait impl by a method
4033 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4034         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSigned)).clone() })) as *mut c_void
4035 }
4036 #[no_mangle]
4037 /// Creates a copy of the ClosingSigned
4038 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4039         orig.clone()
4040 }
4041 /// Checks if two ClosingSigneds contain equal inner contents.
4042 /// This ignores pointers and is_owned flags and looks at the values in fields.
4043 /// Two objects with NULL inner values will be considered "equal" here.
4044 #[no_mangle]
4045 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4046         if a.inner == b.inner { return true; }
4047         if a.inner.is_null() || b.inner.is_null() { return false; }
4048         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4049 }
4050
4051 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4052 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4053
4054 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4055 ///
4056 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4057 #[must_use]
4058 #[repr(C)]
4059 pub struct UpdateAddHTLC {
4060         /// A pointer to the opaque Rust object.
4061
4062         /// Nearly everywhere, inner must be non-null, however in places where
4063         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4064         pub inner: *mut nativeUpdateAddHTLC,
4065         /// Indicates that this is the only struct which contains the same pointer.
4066
4067         /// Rust functions which take ownership of an object provided via an argument require
4068         /// this to be true and invalidate the object pointed to by inner.
4069         pub is_owned: bool,
4070 }
4071
4072 impl Drop for UpdateAddHTLC {
4073         fn drop(&mut self) {
4074                 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4075                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4076                 }
4077         }
4078 }
4079 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4080 #[no_mangle]
4081 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4082 #[allow(unused)]
4083 /// Used only if an object of this type is returned as a trait impl by a method
4084 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4085         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4086 }
4087 #[allow(unused)]
4088 impl UpdateAddHTLC {
4089         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4090                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4091         }
4092         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4093                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4094         }
4095         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4096         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4097                 assert!(self.is_owned);
4098                 let ret = ObjOps::untweak_ptr(self.inner);
4099                 self.inner = core::ptr::null_mut();
4100                 ret
4101         }
4102 }
4103 /// The channel ID
4104 #[no_mangle]
4105 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4106         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4107         &inner_val.0
4108 }
4109 /// The channel ID
4110 #[no_mangle]
4111 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4112         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4113 }
4114 /// The HTLC ID
4115 #[no_mangle]
4116 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4117         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4118         *inner_val
4119 }
4120 /// The HTLC ID
4121 #[no_mangle]
4122 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4123         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4124 }
4125 /// The HTLC value in milli-satoshi
4126 #[no_mangle]
4127 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4128         let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4129         *inner_val
4130 }
4131 /// The HTLC value in milli-satoshi
4132 #[no_mangle]
4133 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4134         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4135 }
4136 /// The payment hash, the pre-image of which controls HTLC redemption
4137 #[no_mangle]
4138 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4139         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4140         &inner_val.0
4141 }
4142 /// The payment hash, the pre-image of which controls HTLC redemption
4143 #[no_mangle]
4144 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4145         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
4146 }
4147 /// The expiry height of the HTLC
4148 #[no_mangle]
4149 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4150         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4151         *inner_val
4152 }
4153 /// The expiry height of the HTLC
4154 #[no_mangle]
4155 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4156         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
4157 }
4158 /// The extra fee skimmed by the sender of this message. See
4159 /// [`ChannelConfig::accept_underpaying_htlcs`].
4160 ///
4161 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4162 #[no_mangle]
4163 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
4164         let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
4165         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() }) };
4166         local_inner_val
4167 }
4168 /// The extra fee skimmed by the sender of this message. See
4169 /// [`ChannelConfig::accept_underpaying_htlcs`].
4170 ///
4171 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4172 #[no_mangle]
4173 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
4174         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4175         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
4176 }
4177 impl Clone for UpdateAddHTLC {
4178         fn clone(&self) -> Self {
4179                 Self {
4180                         inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4181                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4182                         is_owned: true,
4183                 }
4184         }
4185 }
4186 #[allow(unused)]
4187 /// Used only if an object of this type is returned as a trait impl by a method
4188 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4189         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateAddHTLC)).clone() })) as *mut c_void
4190 }
4191 #[no_mangle]
4192 /// Creates a copy of the UpdateAddHTLC
4193 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
4194         orig.clone()
4195 }
4196 /// Checks if two UpdateAddHTLCs contain equal inner contents.
4197 /// This ignores pointers and is_owned flags and looks at the values in fields.
4198 /// Two objects with NULL inner values will be considered "equal" here.
4199 #[no_mangle]
4200 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
4201         if a.inner == b.inner { return true; }
4202         if a.inner.is_null() || b.inner.is_null() { return false; }
4203         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4204 }
4205
4206 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
4207 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
4208
4209 /// An onion message to be sent to or received from a peer.
4210 ///
4211 #[must_use]
4212 #[repr(C)]
4213 pub struct OnionMessage {
4214         /// A pointer to the opaque Rust object.
4215
4216         /// Nearly everywhere, inner must be non-null, however in places where
4217         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4218         pub inner: *mut nativeOnionMessage,
4219         /// Indicates that this is the only struct which contains the same pointer.
4220
4221         /// Rust functions which take ownership of an object provided via an argument require
4222         /// this to be true and invalidate the object pointed to by inner.
4223         pub is_owned: bool,
4224 }
4225
4226 impl Drop for OnionMessage {
4227         fn drop(&mut self) {
4228                 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
4229                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4230                 }
4231         }
4232 }
4233 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
4234 #[no_mangle]
4235 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
4236 #[allow(unused)]
4237 /// Used only if an object of this type is returned as a trait impl by a method
4238 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
4239         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
4240 }
4241 #[allow(unused)]
4242 impl OnionMessage {
4243         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
4244                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4245         }
4246         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
4247                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4248         }
4249         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4250         pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
4251                 assert!(self.is_owned);
4252                 let ret = ObjOps::untweak_ptr(self.inner);
4253                 self.inner = core::ptr::null_mut();
4254                 ret
4255         }
4256 }
4257 /// Used in decrypting the onion packet's payload.
4258 #[no_mangle]
4259 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
4260         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
4261         crate::c_types::PublicKey::from_rust(&inner_val)
4262 }
4263 /// Used in decrypting the onion packet's payload.
4264 #[no_mangle]
4265 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
4266         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
4267 }
4268 /// The full onion packet including hop data, pubkey, and hmac
4269 #[no_mangle]
4270 pub extern "C" fn OnionMessage_get_onion_routing_packet(this_ptr: &OnionMessage) -> crate::lightning::onion_message::packet::Packet {
4271         let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
4272         crate::lightning::onion_message::packet::Packet { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::onion_message::packet::Packet<>) as *mut _) }, is_owned: false }
4273 }
4274 /// The full onion packet including hop data, pubkey, and hmac
4275 #[no_mangle]
4276 pub extern "C" fn OnionMessage_set_onion_routing_packet(this_ptr: &mut OnionMessage, mut val: crate::lightning::onion_message::packet::Packet) {
4277         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
4278 }
4279 /// Constructs a new OnionMessage given each field
4280 #[must_use]
4281 #[no_mangle]
4282 pub extern "C" fn OnionMessage_new(mut blinding_point_arg: crate::c_types::PublicKey, mut onion_routing_packet_arg: crate::lightning::onion_message::packet::Packet) -> OnionMessage {
4283         OnionMessage { inner: ObjOps::heap_alloc(nativeOnionMessage {
4284                 blinding_point: blinding_point_arg.into_rust(),
4285                 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
4286         }), is_owned: true }
4287 }
4288 impl Clone for OnionMessage {
4289         fn clone(&self) -> Self {
4290                 Self {
4291                         inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
4292                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4293                         is_owned: true,
4294                 }
4295         }
4296 }
4297 #[allow(unused)]
4298 /// Used only if an object of this type is returned as a trait impl by a method
4299 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
4300         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionMessage)).clone() })) as *mut c_void
4301 }
4302 #[no_mangle]
4303 /// Creates a copy of the OnionMessage
4304 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
4305         orig.clone()
4306 }
4307 /// Checks if two OnionMessages contain equal inner contents.
4308 /// This ignores pointers and is_owned flags and looks at the values in fields.
4309 /// Two objects with NULL inner values will be considered "equal" here.
4310 #[no_mangle]
4311 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
4312         if a.inner == b.inner { return true; }
4313         if a.inner.is_null() || b.inner.is_null() { return false; }
4314         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4315 }
4316
4317 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
4318 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
4319
4320 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
4321 ///
4322 /// [`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
4323 #[must_use]
4324 #[repr(C)]
4325 pub struct UpdateFulfillHTLC {
4326         /// A pointer to the opaque Rust object.
4327
4328         /// Nearly everywhere, inner must be non-null, however in places where
4329         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4330         pub inner: *mut nativeUpdateFulfillHTLC,
4331         /// Indicates that this is the only struct which contains the same pointer.
4332
4333         /// Rust functions which take ownership of an object provided via an argument require
4334         /// this to be true and invalidate the object pointed to by inner.
4335         pub is_owned: bool,
4336 }
4337
4338 impl Drop for UpdateFulfillHTLC {
4339         fn drop(&mut self) {
4340                 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
4341                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4342                 }
4343         }
4344 }
4345 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
4346 #[no_mangle]
4347 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
4348 #[allow(unused)]
4349 /// Used only if an object of this type is returned as a trait impl by a method
4350 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
4351         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
4352 }
4353 #[allow(unused)]
4354 impl UpdateFulfillHTLC {
4355         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
4356                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4357         }
4358         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
4359                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4360         }
4361         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4362         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
4363                 assert!(self.is_owned);
4364                 let ret = ObjOps::untweak_ptr(self.inner);
4365                 self.inner = core::ptr::null_mut();
4366                 ret
4367         }
4368 }
4369 /// The channel ID
4370 #[no_mangle]
4371 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4372         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4373         &inner_val.0
4374 }
4375 /// The channel ID
4376 #[no_mangle]
4377 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4378         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4379 }
4380 /// The HTLC ID
4381 #[no_mangle]
4382 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
4383         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4384         *inner_val
4385 }
4386 /// The HTLC ID
4387 #[no_mangle]
4388 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
4389         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4390 }
4391 /// The pre-image of the payment hash, allowing HTLC redemption
4392 #[no_mangle]
4393 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4394         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
4395         &inner_val.0
4396 }
4397 /// The pre-image of the payment hash, allowing HTLC redemption
4398 #[no_mangle]
4399 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4400         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
4401 }
4402 /// Constructs a new UpdateFulfillHTLC given each field
4403 #[must_use]
4404 #[no_mangle]
4405 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 {
4406         UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
4407                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4408                 htlc_id: htlc_id_arg,
4409                 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
4410         }), is_owned: true }
4411 }
4412 impl Clone for UpdateFulfillHTLC {
4413         fn clone(&self) -> Self {
4414                 Self {
4415                         inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4416                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4417                         is_owned: true,
4418                 }
4419         }
4420 }
4421 #[allow(unused)]
4422 /// Used only if an object of this type is returned as a trait impl by a method
4423 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4424         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
4425 }
4426 #[no_mangle]
4427 /// Creates a copy of the UpdateFulfillHTLC
4428 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
4429         orig.clone()
4430 }
4431 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
4432 /// This ignores pointers and is_owned flags and looks at the values in fields.
4433 /// Two objects with NULL inner values will be considered "equal" here.
4434 #[no_mangle]
4435 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
4436         if a.inner == b.inner { return true; }
4437         if a.inner.is_null() || b.inner.is_null() { return false; }
4438         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4439 }
4440
4441 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
4442 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
4443
4444 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
4445 ///
4446 /// [`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
4447 #[must_use]
4448 #[repr(C)]
4449 pub struct UpdateFailHTLC {
4450         /// A pointer to the opaque Rust object.
4451
4452         /// Nearly everywhere, inner must be non-null, however in places where
4453         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4454         pub inner: *mut nativeUpdateFailHTLC,
4455         /// Indicates that this is the only struct which contains the same pointer.
4456
4457         /// Rust functions which take ownership of an object provided via an argument require
4458         /// this to be true and invalidate the object pointed to by inner.
4459         pub is_owned: bool,
4460 }
4461
4462 impl Drop for UpdateFailHTLC {
4463         fn drop(&mut self) {
4464                 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
4465                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4466                 }
4467         }
4468 }
4469 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
4470 #[no_mangle]
4471 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
4472 #[allow(unused)]
4473 /// Used only if an object of this type is returned as a trait impl by a method
4474 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
4475         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
4476 }
4477 #[allow(unused)]
4478 impl UpdateFailHTLC {
4479         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
4480                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4481         }
4482         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
4483                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4484         }
4485         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4486         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
4487                 assert!(self.is_owned);
4488                 let ret = ObjOps::untweak_ptr(self.inner);
4489                 self.inner = core::ptr::null_mut();
4490                 ret
4491         }
4492 }
4493 /// The channel ID
4494 #[no_mangle]
4495 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
4496         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4497         &inner_val.0
4498 }
4499 /// The channel ID
4500 #[no_mangle]
4501 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4502         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4503 }
4504 /// The HTLC ID
4505 #[no_mangle]
4506 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
4507         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4508         *inner_val
4509 }
4510 /// The HTLC ID
4511 #[no_mangle]
4512 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
4513         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4514 }
4515 impl Clone for UpdateFailHTLC {
4516         fn clone(&self) -> Self {
4517                 Self {
4518                         inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4519                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4520                         is_owned: true,
4521                 }
4522         }
4523 }
4524 #[allow(unused)]
4525 /// Used only if an object of this type is returned as a trait impl by a method
4526 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4527         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailHTLC)).clone() })) as *mut c_void
4528 }
4529 #[no_mangle]
4530 /// Creates a copy of the UpdateFailHTLC
4531 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
4532         orig.clone()
4533 }
4534 /// Checks if two UpdateFailHTLCs contain equal inner contents.
4535 /// This ignores pointers and is_owned flags and looks at the values in fields.
4536 /// Two objects with NULL inner values will be considered "equal" here.
4537 #[no_mangle]
4538 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
4539         if a.inner == b.inner { return true; }
4540         if a.inner.is_null() || b.inner.is_null() { return false; }
4541         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4542 }
4543
4544 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
4545 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
4546
4547 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
4548 ///
4549 /// [`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
4550 #[must_use]
4551 #[repr(C)]
4552 pub struct UpdateFailMalformedHTLC {
4553         /// A pointer to the opaque Rust object.
4554
4555         /// Nearly everywhere, inner must be non-null, however in places where
4556         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4557         pub inner: *mut nativeUpdateFailMalformedHTLC,
4558         /// Indicates that this is the only struct which contains the same pointer.
4559
4560         /// Rust functions which take ownership of an object provided via an argument require
4561         /// this to be true and invalidate the object pointed to by inner.
4562         pub is_owned: bool,
4563 }
4564
4565 impl Drop for UpdateFailMalformedHTLC {
4566         fn drop(&mut self) {
4567                 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
4568                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4569                 }
4570         }
4571 }
4572 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
4573 #[no_mangle]
4574 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
4575 #[allow(unused)]
4576 /// Used only if an object of this type is returned as a trait impl by a method
4577 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
4578         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
4579 }
4580 #[allow(unused)]
4581 impl UpdateFailMalformedHTLC {
4582         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
4583                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4584         }
4585         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
4586                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4587         }
4588         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4589         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
4590                 assert!(self.is_owned);
4591                 let ret = ObjOps::untweak_ptr(self.inner);
4592                 self.inner = core::ptr::null_mut();
4593                 ret
4594         }
4595 }
4596 /// The channel ID
4597 #[no_mangle]
4598 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
4599         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4600         &inner_val.0
4601 }
4602 /// The channel ID
4603 #[no_mangle]
4604 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4605         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4606 }
4607 /// The HTLC ID
4608 #[no_mangle]
4609 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
4610         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4611         *inner_val
4612 }
4613 /// The HTLC ID
4614 #[no_mangle]
4615 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
4616         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4617 }
4618 /// The failure code
4619 #[no_mangle]
4620 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
4621         let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
4622         *inner_val
4623 }
4624 /// The failure code
4625 #[no_mangle]
4626 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
4627         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
4628 }
4629 impl Clone for UpdateFailMalformedHTLC {
4630         fn clone(&self) -> Self {
4631                 Self {
4632                         inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4633                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4634                         is_owned: true,
4635                 }
4636         }
4637 }
4638 #[allow(unused)]
4639 /// Used only if an object of this type is returned as a trait impl by a method
4640 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4641         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
4642 }
4643 #[no_mangle]
4644 /// Creates a copy of the UpdateFailMalformedHTLC
4645 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
4646         orig.clone()
4647 }
4648 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
4649 /// This ignores pointers and is_owned flags and looks at the values in fields.
4650 /// Two objects with NULL inner values will be considered "equal" here.
4651 #[no_mangle]
4652 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
4653         if a.inner == b.inner { return true; }
4654         if a.inner.is_null() || b.inner.is_null() { return false; }
4655         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4656 }
4657
4658 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
4659 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
4660
4661 /// A [`commitment_signed`] message to be sent to or received from a peer.
4662 ///
4663 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
4664 #[must_use]
4665 #[repr(C)]
4666 pub struct CommitmentSigned {
4667         /// A pointer to the opaque Rust object.
4668
4669         /// Nearly everywhere, inner must be non-null, however in places where
4670         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4671         pub inner: *mut nativeCommitmentSigned,
4672         /// Indicates that this is the only struct which contains the same pointer.
4673
4674         /// Rust functions which take ownership of an object provided via an argument require
4675         /// this to be true and invalidate the object pointed to by inner.
4676         pub is_owned: bool,
4677 }
4678
4679 impl Drop for CommitmentSigned {
4680         fn drop(&mut self) {
4681                 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
4682                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4683                 }
4684         }
4685 }
4686 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
4687 #[no_mangle]
4688 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
4689 #[allow(unused)]
4690 /// Used only if an object of this type is returned as a trait impl by a method
4691 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
4692         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
4693 }
4694 #[allow(unused)]
4695 impl CommitmentSigned {
4696         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
4697                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4698         }
4699         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
4700                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4701         }
4702         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4703         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
4704                 assert!(self.is_owned);
4705                 let ret = ObjOps::untweak_ptr(self.inner);
4706                 self.inner = core::ptr::null_mut();
4707                 ret
4708         }
4709 }
4710 /// The channel ID
4711 #[no_mangle]
4712 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
4713         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4714         &inner_val.0
4715 }
4716 /// The channel ID
4717 #[no_mangle]
4718 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
4719         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4720 }
4721 /// A signature on the commitment transaction
4722 #[no_mangle]
4723 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::ECDSASignature {
4724         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4725         crate::c_types::ECDSASignature::from_rust(&inner_val)
4726 }
4727 /// A signature on the commitment transaction
4728 #[no_mangle]
4729 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ECDSASignature) {
4730         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4731 }
4732 /// Signatures on the HTLC transactions
4733 ///
4734 /// Returns a copy of the field.
4735 #[no_mangle]
4736 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_ECDSASignatureZ {
4737         let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
4738         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::ECDSASignature::from_rust(&item) }); };
4739         local_inner_val.into()
4740 }
4741 /// Signatures on the HTLC transactions
4742 #[no_mangle]
4743 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_ECDSASignatureZ) {
4744         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
4745         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
4746 }
4747 /// Constructs a new CommitmentSigned given each field
4748 #[must_use]
4749 #[no_mangle]
4750 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ) -> CommitmentSigned {
4751         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() }); };
4752         CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
4753                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4754                 signature: signature_arg.into_rust(),
4755                 htlc_signatures: local_htlc_signatures_arg,
4756         }), is_owned: true }
4757 }
4758 impl Clone for CommitmentSigned {
4759         fn clone(&self) -> Self {
4760                 Self {
4761                         inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4762                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4763                         is_owned: true,
4764                 }
4765         }
4766 }
4767 #[allow(unused)]
4768 /// Used only if an object of this type is returned as a trait impl by a method
4769 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4770         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentSigned)).clone() })) as *mut c_void
4771 }
4772 #[no_mangle]
4773 /// Creates a copy of the CommitmentSigned
4774 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
4775         orig.clone()
4776 }
4777 /// Checks if two CommitmentSigneds contain equal inner contents.
4778 /// This ignores pointers and is_owned flags and looks at the values in fields.
4779 /// Two objects with NULL inner values will be considered "equal" here.
4780 #[no_mangle]
4781 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
4782         if a.inner == b.inner { return true; }
4783         if a.inner.is_null() || b.inner.is_null() { return false; }
4784         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4785 }
4786
4787 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
4788 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
4789
4790 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
4791 ///
4792 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
4793 #[must_use]
4794 #[repr(C)]
4795 pub struct RevokeAndACK {
4796         /// A pointer to the opaque Rust object.
4797
4798         /// Nearly everywhere, inner must be non-null, however in places where
4799         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4800         pub inner: *mut nativeRevokeAndACK,
4801         /// Indicates that this is the only struct which contains the same pointer.
4802
4803         /// Rust functions which take ownership of an object provided via an argument require
4804         /// this to be true and invalidate the object pointed to by inner.
4805         pub is_owned: bool,
4806 }
4807
4808 impl Drop for RevokeAndACK {
4809         fn drop(&mut self) {
4810                 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
4811                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4812                 }
4813         }
4814 }
4815 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
4816 #[no_mangle]
4817 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
4818 #[allow(unused)]
4819 /// Used only if an object of this type is returned as a trait impl by a method
4820 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
4821         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
4822 }
4823 #[allow(unused)]
4824 impl RevokeAndACK {
4825         pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
4826                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4827         }
4828         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
4829                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4830         }
4831         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4832         pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
4833                 assert!(self.is_owned);
4834                 let ret = ObjOps::untweak_ptr(self.inner);
4835                 self.inner = core::ptr::null_mut();
4836                 ret
4837         }
4838 }
4839 /// The channel ID
4840 #[no_mangle]
4841 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4842         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4843         &inner_val.0
4844 }
4845 /// The channel ID
4846 #[no_mangle]
4847 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4848         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4849 }
4850 /// The secret corresponding to the per-commitment point
4851 #[no_mangle]
4852 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4853         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
4854         inner_val
4855 }
4856 /// The secret corresponding to the per-commitment point
4857 #[no_mangle]
4858 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4859         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
4860 }
4861 /// The next sender-broadcast commitment transaction's per-commitment point
4862 #[no_mangle]
4863 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
4864         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
4865         crate::c_types::PublicKey::from_rust(&inner_val)
4866 }
4867 /// The next sender-broadcast commitment transaction's per-commitment point
4868 #[no_mangle]
4869 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
4870         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
4871 }
4872 /// Constructs a new RevokeAndACK given each field
4873 #[must_use]
4874 #[no_mangle]
4875 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 {
4876         RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
4877                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4878                 per_commitment_secret: per_commitment_secret_arg.data,
4879                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
4880         }), is_owned: true }
4881 }
4882 impl Clone for RevokeAndACK {
4883         fn clone(&self) -> Self {
4884                 Self {
4885                         inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
4886                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4887                         is_owned: true,
4888                 }
4889         }
4890 }
4891 #[allow(unused)]
4892 /// Used only if an object of this type is returned as a trait impl by a method
4893 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
4894         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRevokeAndACK)).clone() })) as *mut c_void
4895 }
4896 #[no_mangle]
4897 /// Creates a copy of the RevokeAndACK
4898 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
4899         orig.clone()
4900 }
4901 /// Checks if two RevokeAndACKs contain equal inner contents.
4902 /// This ignores pointers and is_owned flags and looks at the values in fields.
4903 /// Two objects with NULL inner values will be considered "equal" here.
4904 #[no_mangle]
4905 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
4906         if a.inner == b.inner { return true; }
4907         if a.inner.is_null() || b.inner.is_null() { return false; }
4908         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4909 }
4910
4911 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
4912 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
4913
4914 /// An [`update_fee`] message to be sent to or received from a peer
4915 ///
4916 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
4917 #[must_use]
4918 #[repr(C)]
4919 pub struct UpdateFee {
4920         /// A pointer to the opaque Rust object.
4921
4922         /// Nearly everywhere, inner must be non-null, however in places where
4923         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4924         pub inner: *mut nativeUpdateFee,
4925         /// Indicates that this is the only struct which contains the same pointer.
4926
4927         /// Rust functions which take ownership of an object provided via an argument require
4928         /// this to be true and invalidate the object pointed to by inner.
4929         pub is_owned: bool,
4930 }
4931
4932 impl Drop for UpdateFee {
4933         fn drop(&mut self) {
4934                 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
4935                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4936                 }
4937         }
4938 }
4939 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
4940 #[no_mangle]
4941 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
4942 #[allow(unused)]
4943 /// Used only if an object of this type is returned as a trait impl by a method
4944 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
4945         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
4946 }
4947 #[allow(unused)]
4948 impl UpdateFee {
4949         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
4950                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4951         }
4952         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
4953                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4954         }
4955         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4956         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
4957                 assert!(self.is_owned);
4958                 let ret = ObjOps::untweak_ptr(self.inner);
4959                 self.inner = core::ptr::null_mut();
4960                 ret
4961         }
4962 }
4963 /// The channel ID
4964 #[no_mangle]
4965 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
4966         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4967         &inner_val.0
4968 }
4969 /// The channel ID
4970 #[no_mangle]
4971 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
4972         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4973 }
4974 /// Fee rate per 1000-weight of the transaction
4975 #[no_mangle]
4976 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
4977         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
4978         *inner_val
4979 }
4980 /// Fee rate per 1000-weight of the transaction
4981 #[no_mangle]
4982 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
4983         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
4984 }
4985 /// Constructs a new UpdateFee given each field
4986 #[must_use]
4987 #[no_mangle]
4988 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
4989         UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
4990                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4991                 feerate_per_kw: feerate_per_kw_arg,
4992         }), is_owned: true }
4993 }
4994 impl Clone for UpdateFee {
4995         fn clone(&self) -> Self {
4996                 Self {
4997                         inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
4998                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4999                         is_owned: true,
5000                 }
5001         }
5002 }
5003 #[allow(unused)]
5004 /// Used only if an object of this type is returned as a trait impl by a method
5005 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
5006         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFee)).clone() })) as *mut c_void
5007 }
5008 #[no_mangle]
5009 /// Creates a copy of the UpdateFee
5010 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
5011         orig.clone()
5012 }
5013 /// Checks if two UpdateFees contain equal inner contents.
5014 /// This ignores pointers and is_owned flags and looks at the values in fields.
5015 /// Two objects with NULL inner values will be considered "equal" here.
5016 #[no_mangle]
5017 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
5018         if a.inner == b.inner { return true; }
5019         if a.inner.is_null() || b.inner.is_null() { return false; }
5020         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5021 }
5022
5023 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
5024 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
5025
5026 /// A [`channel_reestablish`] message to be sent to or received from a peer.
5027 ///
5028 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
5029 #[must_use]
5030 #[repr(C)]
5031 pub struct ChannelReestablish {
5032         /// A pointer to the opaque Rust object.
5033
5034         /// Nearly everywhere, inner must be non-null, however in places where
5035         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5036         pub inner: *mut nativeChannelReestablish,
5037         /// Indicates that this is the only struct which contains the same pointer.
5038
5039         /// Rust functions which take ownership of an object provided via an argument require
5040         /// this to be true and invalidate the object pointed to by inner.
5041         pub is_owned: bool,
5042 }
5043
5044 impl Drop for ChannelReestablish {
5045         fn drop(&mut self) {
5046                 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
5047                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5048                 }
5049         }
5050 }
5051 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
5052 #[no_mangle]
5053 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
5054 #[allow(unused)]
5055 /// Used only if an object of this type is returned as a trait impl by a method
5056 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
5057         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
5058 }
5059 #[allow(unused)]
5060 impl ChannelReestablish {
5061         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
5062                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5063         }
5064         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
5065                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5066         }
5067         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5068         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
5069                 assert!(self.is_owned);
5070                 let ret = ObjOps::untweak_ptr(self.inner);
5071                 self.inner = core::ptr::null_mut();
5072                 ret
5073         }
5074 }
5075 /// The channel ID
5076 #[no_mangle]
5077 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5078         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5079         &inner_val.0
5080 }
5081 /// The channel ID
5082 #[no_mangle]
5083 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5084         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5085 }
5086 /// The next commitment number for the sender
5087 #[no_mangle]
5088 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5089         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
5090         *inner_val
5091 }
5092 /// The next commitment number for the sender
5093 #[no_mangle]
5094 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5095         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
5096 }
5097 /// The next commitment number for the recipient
5098 #[no_mangle]
5099 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5100         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
5101         *inner_val
5102 }
5103 /// The next commitment number for the recipient
5104 #[no_mangle]
5105 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5106         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
5107 }
5108 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5109 /// belonging to the recipient
5110 #[no_mangle]
5111 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5112         let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
5113         inner_val
5114 }
5115 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5116 /// belonging to the recipient
5117 #[no_mangle]
5118 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5119         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
5120 }
5121 /// The sender's per-commitment point for their current commitment transaction
5122 #[no_mangle]
5123 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
5124         let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
5125         crate::c_types::PublicKey::from_rust(&inner_val)
5126 }
5127 /// The sender's per-commitment point for their current commitment transaction
5128 #[no_mangle]
5129 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
5130         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
5131 }
5132 /// The next funding transaction ID
5133 #[no_mangle]
5134 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
5135         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
5136         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().into_inner() } }) };
5137         local_inner_val
5138 }
5139 /// The next funding transaction ID
5140 #[no_mangle]
5141 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
5142         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() }})} };
5143         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
5144 }
5145 /// Constructs a new ChannelReestablish given each field
5146 #[must_use]
5147 #[no_mangle]
5148 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_ThirtyTwoBytesZ) -> ChannelReestablish {
5149         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() }})} };
5150         ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
5151                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5152                 next_local_commitment_number: next_local_commitment_number_arg,
5153                 next_remote_commitment_number: next_remote_commitment_number_arg,
5154                 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
5155                 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
5156                 next_funding_txid: local_next_funding_txid_arg,
5157         }), is_owned: true }
5158 }
5159 impl Clone for ChannelReestablish {
5160         fn clone(&self) -> Self {
5161                 Self {
5162                         inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
5163                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5164                         is_owned: true,
5165                 }
5166         }
5167 }
5168 #[allow(unused)]
5169 /// Used only if an object of this type is returned as a trait impl by a method
5170 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
5171         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReestablish)).clone() })) as *mut c_void
5172 }
5173 #[no_mangle]
5174 /// Creates a copy of the ChannelReestablish
5175 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
5176         orig.clone()
5177 }
5178 /// Checks if two ChannelReestablishs contain equal inner contents.
5179 /// This ignores pointers and is_owned flags and looks at the values in fields.
5180 /// Two objects with NULL inner values will be considered "equal" here.
5181 #[no_mangle]
5182 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
5183         if a.inner == b.inner { return true; }
5184         if a.inner.is_null() || b.inner.is_null() { return false; }
5185         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5186 }
5187
5188 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
5189 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
5190
5191 /// An [`announcement_signatures`] message to be sent to or received from a peer.
5192 ///
5193 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
5194 #[must_use]
5195 #[repr(C)]
5196 pub struct AnnouncementSignatures {
5197         /// A pointer to the opaque Rust object.
5198
5199         /// Nearly everywhere, inner must be non-null, however in places where
5200         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5201         pub inner: *mut nativeAnnouncementSignatures,
5202         /// Indicates that this is the only struct which contains the same pointer.
5203
5204         /// Rust functions which take ownership of an object provided via an argument require
5205         /// this to be true and invalidate the object pointed to by inner.
5206         pub is_owned: bool,
5207 }
5208
5209 impl Drop for AnnouncementSignatures {
5210         fn drop(&mut self) {
5211                 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
5212                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5213                 }
5214         }
5215 }
5216 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
5217 #[no_mangle]
5218 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
5219 #[allow(unused)]
5220 /// Used only if an object of this type is returned as a trait impl by a method
5221 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
5222         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
5223 }
5224 #[allow(unused)]
5225 impl AnnouncementSignatures {
5226         pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
5227                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5228         }
5229         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
5230                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5231         }
5232         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5233         pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
5234                 assert!(self.is_owned);
5235                 let ret = ObjOps::untweak_ptr(self.inner);
5236                 self.inner = core::ptr::null_mut();
5237                 ret
5238         }
5239 }
5240 /// The channel ID
5241 #[no_mangle]
5242 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
5243         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5244         &inner_val.0
5245 }
5246 /// The channel ID
5247 #[no_mangle]
5248 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
5249         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5250 }
5251 /// The short channel ID
5252 #[no_mangle]
5253 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
5254         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
5255         *inner_val
5256 }
5257 /// The short channel ID
5258 #[no_mangle]
5259 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
5260         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
5261 }
5262 /// A signature by the node key
5263 #[no_mangle]
5264 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
5265         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
5266         crate::c_types::ECDSASignature::from_rust(&inner_val)
5267 }
5268 /// A signature by the node key
5269 #[no_mangle]
5270 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
5271         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
5272 }
5273 /// A signature by the funding key
5274 #[no_mangle]
5275 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
5276         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
5277         crate::c_types::ECDSASignature::from_rust(&inner_val)
5278 }
5279 /// A signature by the funding key
5280 #[no_mangle]
5281 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
5282         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
5283 }
5284 /// Constructs a new AnnouncementSignatures given each field
5285 #[must_use]
5286 #[no_mangle]
5287 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::ECDSASignature, mut bitcoin_signature_arg: crate::c_types::ECDSASignature) -> AnnouncementSignatures {
5288         AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
5289                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5290                 short_channel_id: short_channel_id_arg,
5291                 node_signature: node_signature_arg.into_rust(),
5292                 bitcoin_signature: bitcoin_signature_arg.into_rust(),
5293         }), is_owned: true }
5294 }
5295 impl Clone for AnnouncementSignatures {
5296         fn clone(&self) -> Self {
5297                 Self {
5298                         inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
5299                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5300                         is_owned: true,
5301                 }
5302         }
5303 }
5304 #[allow(unused)]
5305 /// Used only if an object of this type is returned as a trait impl by a method
5306 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
5307         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAnnouncementSignatures)).clone() })) as *mut c_void
5308 }
5309 #[no_mangle]
5310 /// Creates a copy of the AnnouncementSignatures
5311 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
5312         orig.clone()
5313 }
5314 /// Checks if two AnnouncementSignaturess contain equal inner contents.
5315 /// This ignores pointers and is_owned flags and looks at the values in fields.
5316 /// Two objects with NULL inner values will be considered "equal" here.
5317 #[no_mangle]
5318 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
5319         if a.inner == b.inner { return true; }
5320         if a.inner.is_null() || b.inner.is_null() { return false; }
5321         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5322 }
5323 /// An address which can be used to connect to a remote peer.
5324 #[derive(Clone)]
5325 #[must_use]
5326 #[repr(C)]
5327 pub enum SocketAddress {
5328         /// An IPv4 address and port on which the peer is listening.
5329         TcpIpV4 {
5330                 /// The 4-byte IPv4 address
5331                 addr: crate::c_types::FourBytes,
5332                 /// The port on which the node is listening
5333                 port: u16,
5334         },
5335         /// An IPv6 address and port on which the peer is listening.
5336         TcpIpV6 {
5337                 /// The 16-byte IPv6 address
5338                 addr: crate::c_types::SixteenBytes,
5339                 /// The port on which the node is listening
5340                 port: u16,
5341         },
5342         /// An old-style Tor onion address/port on which the peer is listening.
5343         ///
5344         /// This field is deprecated and the Tor network generally no longer supports V2 Onion
5345         /// addresses. Thus, the details are not parsed here.
5346         OnionV2(
5347                 crate::c_types::TwelveBytes),
5348         /// A new-style Tor onion address/port on which the peer is listening.
5349         ///
5350         /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
5351         /// wrap as base32 and append \".onion\".
5352         OnionV3 {
5353                 /// The ed25519 long-term public key of the peer
5354                 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
5355                 /// The checksum of the pubkey and version, as included in the onion address
5356                 checksum: u16,
5357                 /// The version byte, as defined by the Tor Onion v3 spec.
5358                 version: u8,
5359                 /// The port on which the node is listening
5360                 port: u16,
5361         },
5362         /// A hostname/port on which the peer is listening.
5363         Hostname {
5364                 /// The hostname on which the node is listening.
5365                 hostname: crate::lightning::util::ser::Hostname,
5366                 /// The port on which the node is listening.
5367                 port: u16,
5368         },
5369 }
5370 use lightning::ln::msgs::SocketAddress as SocketAddressImport;
5371 pub(crate) type nativeSocketAddress = SocketAddressImport;
5372
5373 impl SocketAddress {
5374         #[allow(unused)]
5375         pub(crate) fn to_native(&self) -> nativeSocketAddress {
5376                 match self {
5377                         SocketAddress::TcpIpV4 {ref addr, ref port, } => {
5378                                 let mut addr_nonref = Clone::clone(addr);
5379                                 let mut port_nonref = Clone::clone(port);
5380                                 nativeSocketAddress::TcpIpV4 {
5381                                         addr: addr_nonref.data,
5382                                         port: port_nonref,
5383                                 }
5384                         },
5385                         SocketAddress::TcpIpV6 {ref addr, ref port, } => {
5386                                 let mut addr_nonref = Clone::clone(addr);
5387                                 let mut port_nonref = Clone::clone(port);
5388                                 nativeSocketAddress::TcpIpV6 {
5389                                         addr: addr_nonref.data,
5390                                         port: port_nonref,
5391                                 }
5392                         },
5393                         SocketAddress::OnionV2 (ref a, ) => {
5394                                 let mut a_nonref = Clone::clone(a);
5395                                 nativeSocketAddress::OnionV2 (
5396                                         a_nonref.data,
5397                                 )
5398                         },
5399                         SocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5400                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5401                                 let mut checksum_nonref = Clone::clone(checksum);
5402                                 let mut version_nonref = Clone::clone(version);
5403                                 let mut port_nonref = Clone::clone(port);
5404                                 nativeSocketAddress::OnionV3 {
5405                                         ed25519_pubkey: ed25519_pubkey_nonref.data,
5406                                         checksum: checksum_nonref,
5407                                         version: version_nonref,
5408                                         port: port_nonref,
5409                                 }
5410                         },
5411                         SocketAddress::Hostname {ref hostname, ref port, } => {
5412                                 let mut hostname_nonref = Clone::clone(hostname);
5413                                 let mut port_nonref = Clone::clone(port);
5414                                 nativeSocketAddress::Hostname {
5415                                         hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
5416                                         port: port_nonref,
5417                                 }
5418                         },
5419                 }
5420         }
5421         #[allow(unused)]
5422         pub(crate) fn into_native(self) -> nativeSocketAddress {
5423                 match self {
5424                         SocketAddress::TcpIpV4 {mut addr, mut port, } => {
5425                                 nativeSocketAddress::TcpIpV4 {
5426                                         addr: addr.data,
5427                                         port: port,
5428                                 }
5429                         },
5430                         SocketAddress::TcpIpV6 {mut addr, mut port, } => {
5431                                 nativeSocketAddress::TcpIpV6 {
5432                                         addr: addr.data,
5433                                         port: port,
5434                                 }
5435                         },
5436                         SocketAddress::OnionV2 (mut a, ) => {
5437                                 nativeSocketAddress::OnionV2 (
5438                                         a.data,
5439                                 )
5440                         },
5441                         SocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5442                                 nativeSocketAddress::OnionV3 {
5443                                         ed25519_pubkey: ed25519_pubkey.data,
5444                                         checksum: checksum,
5445                                         version: version,
5446                                         port: port,
5447                                 }
5448                         },
5449                         SocketAddress::Hostname {mut hostname, mut port, } => {
5450                                 nativeSocketAddress::Hostname {
5451                                         hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
5452                                         port: port,
5453                                 }
5454                         },
5455                 }
5456         }
5457         #[allow(unused)]
5458         pub(crate) fn from_native(native: &nativeSocketAddress) -> Self {
5459                 match native {
5460                         nativeSocketAddress::TcpIpV4 {ref addr, ref port, } => {
5461                                 let mut addr_nonref = Clone::clone(addr);
5462                                 let mut port_nonref = Clone::clone(port);
5463                                 SocketAddress::TcpIpV4 {
5464                                         addr: crate::c_types::FourBytes { data: addr_nonref },
5465                                         port: port_nonref,
5466                                 }
5467                         },
5468                         nativeSocketAddress::TcpIpV6 {ref addr, ref port, } => {
5469                                 let mut addr_nonref = Clone::clone(addr);
5470                                 let mut port_nonref = Clone::clone(port);
5471                                 SocketAddress::TcpIpV6 {
5472                                         addr: crate::c_types::SixteenBytes { data: addr_nonref },
5473                                         port: port_nonref,
5474                                 }
5475                         },
5476                         nativeSocketAddress::OnionV2 (ref a, ) => {
5477                                 let mut a_nonref = Clone::clone(a);
5478                                 SocketAddress::OnionV2 (
5479                                         crate::c_types::TwelveBytes { data: a_nonref },
5480                                 )
5481                         },
5482                         nativeSocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5483                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5484                                 let mut checksum_nonref = Clone::clone(checksum);
5485                                 let mut version_nonref = Clone::clone(version);
5486                                 let mut port_nonref = Clone::clone(port);
5487                                 SocketAddress::OnionV3 {
5488                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
5489                                         checksum: checksum_nonref,
5490                                         version: version_nonref,
5491                                         port: port_nonref,
5492                                 }
5493                         },
5494                         nativeSocketAddress::Hostname {ref hostname, ref port, } => {
5495                                 let mut hostname_nonref = Clone::clone(hostname);
5496                                 let mut port_nonref = Clone::clone(port);
5497                                 SocketAddress::Hostname {
5498                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
5499                                         port: port_nonref,
5500                                 }
5501                         },
5502                 }
5503         }
5504         #[allow(unused)]
5505         pub(crate) fn native_into(native: nativeSocketAddress) -> Self {
5506                 match native {
5507                         nativeSocketAddress::TcpIpV4 {mut addr, mut port, } => {
5508                                 SocketAddress::TcpIpV4 {
5509                                         addr: crate::c_types::FourBytes { data: addr },
5510                                         port: port,
5511                                 }
5512                         },
5513                         nativeSocketAddress::TcpIpV6 {mut addr, mut port, } => {
5514                                 SocketAddress::TcpIpV6 {
5515                                         addr: crate::c_types::SixteenBytes { data: addr },
5516                                         port: port,
5517                                 }
5518                         },
5519                         nativeSocketAddress::OnionV2 (mut a, ) => {
5520                                 SocketAddress::OnionV2 (
5521                                         crate::c_types::TwelveBytes { data: a },
5522                                 )
5523                         },
5524                         nativeSocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5525                                 SocketAddress::OnionV3 {
5526                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
5527                                         checksum: checksum,
5528                                         version: version,
5529                                         port: port,
5530                                 }
5531                         },
5532                         nativeSocketAddress::Hostname {mut hostname, mut port, } => {
5533                                 SocketAddress::Hostname {
5534                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
5535                                         port: port,
5536                                 }
5537                         },
5538                 }
5539         }
5540 }
5541 /// Frees any resources used by the SocketAddress
5542 #[no_mangle]
5543 pub extern "C" fn SocketAddress_free(this_ptr: SocketAddress) { }
5544 /// Creates a copy of the SocketAddress
5545 #[no_mangle]
5546 pub extern "C" fn SocketAddress_clone(orig: &SocketAddress) -> SocketAddress {
5547         orig.clone()
5548 }
5549 #[allow(unused)]
5550 /// Used only if an object of this type is returned as a trait impl by a method
5551 pub(crate) extern "C" fn SocketAddress_clone_void(this_ptr: *const c_void) -> *mut c_void {
5552         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddress)).clone() })) as *mut c_void
5553 }
5554 #[allow(unused)]
5555 /// Used only if an object of this type is returned as a trait impl by a method
5556 pub(crate) extern "C" fn SocketAddress_free_void(this_ptr: *mut c_void) {
5557         let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddress) };
5558 }
5559 #[no_mangle]
5560 /// Utility method to constructs a new TcpIpV4-variant SocketAddress
5561 pub extern "C" fn SocketAddress_tcp_ip_v4(addr: crate::c_types::FourBytes, port: u16) -> SocketAddress {
5562         SocketAddress::TcpIpV4 {
5563                 addr,
5564                 port,
5565         }
5566 }
5567 #[no_mangle]
5568 /// Utility method to constructs a new TcpIpV6-variant SocketAddress
5569 pub extern "C" fn SocketAddress_tcp_ip_v6(addr: crate::c_types::SixteenBytes, port: u16) -> SocketAddress {
5570         SocketAddress::TcpIpV6 {
5571                 addr,
5572                 port,
5573         }
5574 }
5575 #[no_mangle]
5576 /// Utility method to constructs a new OnionV2-variant SocketAddress
5577 pub extern "C" fn SocketAddress_onion_v2(a: crate::c_types::TwelveBytes) -> SocketAddress {
5578         SocketAddress::OnionV2(a, )
5579 }
5580 #[no_mangle]
5581 /// Utility method to constructs a new OnionV3-variant SocketAddress
5582 pub extern "C" fn SocketAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> SocketAddress {
5583         SocketAddress::OnionV3 {
5584                 ed25519_pubkey,
5585                 checksum,
5586                 version,
5587                 port,
5588         }
5589 }
5590 #[no_mangle]
5591 /// Utility method to constructs a new Hostname-variant SocketAddress
5592 pub extern "C" fn SocketAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> SocketAddress {
5593         SocketAddress::Hostname {
5594                 hostname,
5595                 port,
5596         }
5597 }
5598 /// Checks if two SocketAddresss contain equal inner contents.
5599 /// This ignores pointers and is_owned flags and looks at the values in fields.
5600 #[no_mangle]
5601 pub extern "C" fn SocketAddress_eq(a: &SocketAddress, b: &SocketAddress) -> bool {
5602         if &a.to_native() == &b.to_native() { true } else { false }
5603 }
5604 #[no_mangle]
5605 /// Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read
5606 pub extern "C" fn SocketAddress_write(obj: &crate::lightning::ln::msgs::SocketAddress) -> crate::c_types::derived::CVec_u8Z {
5607         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5608 }
5609 #[allow(unused)]
5610 pub(crate) extern "C" fn SocketAddress_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5611         SocketAddress_write(unsafe { &*(obj as *const SocketAddress) })
5612 }
5613 #[no_mangle]
5614 /// Read a SocketAddress from a byte array, created by SocketAddress_write
5615 pub extern "C" fn SocketAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SocketAddressDecodeErrorZ {
5616         let res: Result<lightning::ln::msgs::SocketAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5617         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
5618         local_res
5619 }
5620 /// [`SocketAddress`] error variants
5621 #[derive(Clone)]
5622 #[must_use]
5623 #[repr(C)]
5624 pub enum SocketAddressParseError {
5625         /// Socket address (IPv4/IPv6) parsing error
5626         SocketAddrParse,
5627         /// Invalid input format
5628         InvalidInput,
5629         /// Invalid port
5630         InvalidPort,
5631         /// Invalid onion v3 address
5632         InvalidOnionV3,
5633 }
5634 use lightning::ln::msgs::SocketAddressParseError as SocketAddressParseErrorImport;
5635 pub(crate) type nativeSocketAddressParseError = SocketAddressParseErrorImport;
5636
5637 impl SocketAddressParseError {
5638         #[allow(unused)]
5639         pub(crate) fn to_native(&self) -> nativeSocketAddressParseError {
5640                 match self {
5641                         SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
5642                         SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
5643                         SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
5644                         SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
5645                 }
5646         }
5647         #[allow(unused)]
5648         pub(crate) fn into_native(self) -> nativeSocketAddressParseError {
5649                 match self {
5650                         SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
5651                         SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
5652                         SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
5653                         SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
5654                 }
5655         }
5656         #[allow(unused)]
5657         pub(crate) fn from_native(native: &nativeSocketAddressParseError) -> Self {
5658                 match native {
5659                         nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
5660                         nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
5661                         nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
5662                         nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
5663                 }
5664         }
5665         #[allow(unused)]
5666         pub(crate) fn native_into(native: nativeSocketAddressParseError) -> Self {
5667                 match native {
5668                         nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
5669                         nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
5670                         nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
5671                         nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
5672                 }
5673         }
5674 }
5675 /// Creates a copy of the SocketAddressParseError
5676 #[no_mangle]
5677 pub extern "C" fn SocketAddressParseError_clone(orig: &SocketAddressParseError) -> SocketAddressParseError {
5678         orig.clone()
5679 }
5680 #[allow(unused)]
5681 /// Used only if an object of this type is returned as a trait impl by a method
5682 pub(crate) extern "C" fn SocketAddressParseError_clone_void(this_ptr: *const c_void) -> *mut c_void {
5683         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddressParseError)).clone() })) as *mut c_void
5684 }
5685 #[allow(unused)]
5686 /// Used only if an object of this type is returned as a trait impl by a method
5687 pub(crate) extern "C" fn SocketAddressParseError_free_void(this_ptr: *mut c_void) {
5688         let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddressParseError) };
5689 }
5690 #[no_mangle]
5691 /// Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError
5692 pub extern "C" fn SocketAddressParseError_socket_addr_parse() -> SocketAddressParseError {
5693         SocketAddressParseError::SocketAddrParse}
5694 #[no_mangle]
5695 /// Utility method to constructs a new InvalidInput-variant SocketAddressParseError
5696 pub extern "C" fn SocketAddressParseError_invalid_input() -> SocketAddressParseError {
5697         SocketAddressParseError::InvalidInput}
5698 #[no_mangle]
5699 /// Utility method to constructs a new InvalidPort-variant SocketAddressParseError
5700 pub extern "C" fn SocketAddressParseError_invalid_port() -> SocketAddressParseError {
5701         SocketAddressParseError::InvalidPort}
5702 #[no_mangle]
5703 /// Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError
5704 pub extern "C" fn SocketAddressParseError_invalid_onion_v3() -> SocketAddressParseError {
5705         SocketAddressParseError::InvalidOnionV3}
5706 /// Checks if two SocketAddressParseErrors contain equal inner contents.
5707 /// This ignores pointers and is_owned flags and looks at the values in fields.
5708 #[no_mangle]
5709 pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool {
5710         if &a.to_native() == &b.to_native() { true } else { false }
5711 }
5712 /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
5713 ///
5714 /// The host part must end with \".onion\".
5715 #[no_mangle]
5716 pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
5717         let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
5718         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::SocketAddressParseError::native_into(e) }).into() };
5719         local_ret
5720 }
5721
5722 #[no_mangle]
5723 /// Get the string representation of a SocketAddress object
5724 pub extern "C" fn SocketAddress_to_str(o: &crate::lightning::ln::msgs::SocketAddress) -> Str {
5725         alloc::format!("{}", &o.to_native()).into()
5726 }
5727 #[no_mangle]
5728 /// Read a SocketAddress object from a string
5729 pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
5730         match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
5731                 Ok(r) => {
5732                         crate::c_types::CResultTempl::ok(
5733                                 crate::lightning::ln::msgs::SocketAddress::native_into(r)
5734                         )
5735                 },
5736                 Err(e) => {
5737                         crate::c_types::CResultTempl::err(
5738                                 crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
5739                         )
5740                 },
5741         }.into()
5742 }
5743 /// Represents the set of gossip messages that require a signature from a node's identity key.
5744 #[derive(Clone)]
5745 #[must_use]
5746 #[repr(C)]
5747 pub enum UnsignedGossipMessage {
5748         /// An unsigned channel announcement.
5749         ChannelAnnouncement(
5750                 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
5751         /// An unsigned channel update.
5752         ChannelUpdate(
5753                 crate::lightning::ln::msgs::UnsignedChannelUpdate),
5754         /// An unsigned node announcement.
5755         NodeAnnouncement(
5756                 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
5757 }
5758 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
5759 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
5760
5761 impl UnsignedGossipMessage {
5762         #[allow(unused)]
5763         pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
5764                 match self {
5765                         UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5766                                 let mut a_nonref = Clone::clone(a);
5767                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
5768                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
5769                                 )
5770                         },
5771                         UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5772                                 let mut a_nonref = Clone::clone(a);
5773                                 nativeUnsignedGossipMessage::ChannelUpdate (
5774                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
5775                                 )
5776                         },
5777                         UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5778                                 let mut a_nonref = Clone::clone(a);
5779                                 nativeUnsignedGossipMessage::NodeAnnouncement (
5780                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
5781                                 )
5782                         },
5783                 }
5784         }
5785         #[allow(unused)]
5786         pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
5787                 match self {
5788                         UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5789                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
5790                                         *unsafe { Box::from_raw(a.take_inner()) },
5791                                 )
5792                         },
5793                         UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5794                                 nativeUnsignedGossipMessage::ChannelUpdate (
5795                                         *unsafe { Box::from_raw(a.take_inner()) },
5796                                 )
5797                         },
5798                         UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5799                                 nativeUnsignedGossipMessage::NodeAnnouncement (
5800                                         *unsafe { Box::from_raw(a.take_inner()) },
5801                                 )
5802                         },
5803                 }
5804         }
5805         #[allow(unused)]
5806         pub(crate) fn from_native(native: &nativeUnsignedGossipMessage) -> Self {
5807                 match native {
5808                         nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5809                                 let mut a_nonref = Clone::clone(a);
5810                                 UnsignedGossipMessage::ChannelAnnouncement (
5811                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5812                                 )
5813                         },
5814                         nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5815                                 let mut a_nonref = Clone::clone(a);
5816                                 UnsignedGossipMessage::ChannelUpdate (
5817                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5818                                 )
5819                         },
5820                         nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5821                                 let mut a_nonref = Clone::clone(a);
5822                                 UnsignedGossipMessage::NodeAnnouncement (
5823                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5824                                 )
5825                         },
5826                 }
5827         }
5828         #[allow(unused)]
5829         pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
5830                 match native {
5831                         nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5832                                 UnsignedGossipMessage::ChannelAnnouncement (
5833                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5834                                 )
5835                         },
5836                         nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5837                                 UnsignedGossipMessage::ChannelUpdate (
5838                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
5839                                 )
5840                         },
5841                         nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5842                                 UnsignedGossipMessage::NodeAnnouncement (
5843                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5844                                 )
5845                         },
5846                 }
5847         }
5848 }
5849 /// Frees any resources used by the UnsignedGossipMessage
5850 #[no_mangle]
5851 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
5852 /// Creates a copy of the UnsignedGossipMessage
5853 #[no_mangle]
5854 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
5855         orig.clone()
5856 }
5857 #[allow(unused)]
5858 /// Used only if an object of this type is returned as a trait impl by a method
5859 pub(crate) extern "C" fn UnsignedGossipMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
5860         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const UnsignedGossipMessage)).clone() })) as *mut c_void
5861 }
5862 #[allow(unused)]
5863 /// Used only if an object of this type is returned as a trait impl by a method
5864 pub(crate) extern "C" fn UnsignedGossipMessage_free_void(this_ptr: *mut c_void) {
5865         let _ = unsafe { Box::from_raw(this_ptr as *mut UnsignedGossipMessage) };
5866 }
5867 #[no_mangle]
5868 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
5869 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
5870         UnsignedGossipMessage::ChannelAnnouncement(a, )
5871 }
5872 #[no_mangle]
5873 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
5874 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
5875         UnsignedGossipMessage::ChannelUpdate(a, )
5876 }
5877 #[no_mangle]
5878 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
5879 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
5880         UnsignedGossipMessage::NodeAnnouncement(a, )
5881 }
5882 #[no_mangle]
5883 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
5884 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
5885         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5886 }
5887 #[allow(unused)]
5888 pub(crate) extern "C" fn UnsignedGossipMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5889         UnsignedGossipMessage_write(unsafe { &*(obj as *const UnsignedGossipMessage) })
5890 }
5891
5892 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
5893 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
5894
5895 /// The unsigned part of a [`node_announcement`] message.
5896 ///
5897 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
5898 #[must_use]
5899 #[repr(C)]
5900 pub struct UnsignedNodeAnnouncement {
5901         /// A pointer to the opaque Rust object.
5902
5903         /// Nearly everywhere, inner must be non-null, however in places where
5904         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5905         pub inner: *mut nativeUnsignedNodeAnnouncement,
5906         /// Indicates that this is the only struct which contains the same pointer.
5907
5908         /// Rust functions which take ownership of an object provided via an argument require
5909         /// this to be true and invalidate the object pointed to by inner.
5910         pub is_owned: bool,
5911 }
5912
5913 impl Drop for UnsignedNodeAnnouncement {
5914         fn drop(&mut self) {
5915                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
5916                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5917                 }
5918         }
5919 }
5920 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
5921 #[no_mangle]
5922 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
5923 #[allow(unused)]
5924 /// Used only if an object of this type is returned as a trait impl by a method
5925 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
5926         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
5927 }
5928 #[allow(unused)]
5929 impl UnsignedNodeAnnouncement {
5930         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
5931                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5932         }
5933         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
5934                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5935         }
5936         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5937         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
5938                 assert!(self.is_owned);
5939                 let ret = ObjOps::untweak_ptr(self.inner);
5940                 self.inner = core::ptr::null_mut();
5941                 ret
5942         }
5943 }
5944 /// The advertised features
5945 #[no_mangle]
5946 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
5947         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
5948         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 }
5949 }
5950 /// The advertised features
5951 #[no_mangle]
5952 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
5953         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
5954 }
5955 /// A strictly monotonic announcement counter, with gaps allowed
5956 #[no_mangle]
5957 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
5958         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
5959         *inner_val
5960 }
5961 /// A strictly monotonic announcement counter, with gaps allowed
5962 #[no_mangle]
5963 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
5964         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
5965 }
5966 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5967 /// to this node).
5968 #[no_mangle]
5969 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
5970         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
5971         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 }
5972 }
5973 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5974 /// to this node).
5975 #[no_mangle]
5976 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
5977         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
5978 }
5979 /// An RGB color for UI purposes
5980 #[no_mangle]
5981 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
5982         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
5983         inner_val
5984 }
5985 /// An RGB color for UI purposes
5986 #[no_mangle]
5987 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
5988         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
5989 }
5990 /// An alias, for UI purposes.
5991 ///
5992 /// This should be sanitized before use. There is no guarantee of uniqueness.
5993 #[no_mangle]
5994 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
5995         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
5996         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 }
5997 }
5998 /// An alias, for UI purposes.
5999 ///
6000 /// This should be sanitized before use. There is no guarantee of uniqueness.
6001 #[no_mangle]
6002 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
6003         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
6004 }
6005 /// List of addresses on which this node is reachable
6006 ///
6007 /// Returns a copy of the field.
6008 #[no_mangle]
6009 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
6010         let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
6011         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); };
6012         local_inner_val.into()
6013 }
6014 /// List of addresses on which this node is reachable
6015 #[no_mangle]
6016 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
6017         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
6018         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
6019 }
6020 impl Clone for UnsignedNodeAnnouncement {
6021         fn clone(&self) -> Self {
6022                 Self {
6023                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6024                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6025                         is_owned: true,
6026                 }
6027         }
6028 }
6029 #[allow(unused)]
6030 /// Used only if an object of this type is returned as a trait impl by a method
6031 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6032         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
6033 }
6034 #[no_mangle]
6035 /// Creates a copy of the UnsignedNodeAnnouncement
6036 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
6037         orig.clone()
6038 }
6039 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
6040 /// This ignores pointers and is_owned flags and looks at the values in fields.
6041 /// Two objects with NULL inner values will be considered "equal" here.
6042 #[no_mangle]
6043 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
6044         if a.inner == b.inner { return true; }
6045         if a.inner.is_null() || b.inner.is_null() { return false; }
6046         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6047 }
6048
6049 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
6050 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
6051
6052 /// A [`node_announcement`] message to be sent to or received from a peer.
6053 ///
6054 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
6055 #[must_use]
6056 #[repr(C)]
6057 pub struct NodeAnnouncement {
6058         /// A pointer to the opaque Rust object.
6059
6060         /// Nearly everywhere, inner must be non-null, however in places where
6061         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6062         pub inner: *mut nativeNodeAnnouncement,
6063         /// Indicates that this is the only struct which contains the same pointer.
6064
6065         /// Rust functions which take ownership of an object provided via an argument require
6066         /// this to be true and invalidate the object pointed to by inner.
6067         pub is_owned: bool,
6068 }
6069
6070 impl Drop for NodeAnnouncement {
6071         fn drop(&mut self) {
6072                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
6073                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6074                 }
6075         }
6076 }
6077 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
6078 #[no_mangle]
6079 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
6080 #[allow(unused)]
6081 /// Used only if an object of this type is returned as a trait impl by a method
6082 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
6083         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
6084 }
6085 #[allow(unused)]
6086 impl NodeAnnouncement {
6087         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
6088                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6089         }
6090         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
6091                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6092         }
6093         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6094         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
6095                 assert!(self.is_owned);
6096                 let ret = ObjOps::untweak_ptr(self.inner);
6097                 self.inner = core::ptr::null_mut();
6098                 ret
6099         }
6100 }
6101 /// The signature by the node key
6102 #[no_mangle]
6103 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
6104         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
6105         crate::c_types::ECDSASignature::from_rust(&inner_val)
6106 }
6107 /// The signature by the node key
6108 #[no_mangle]
6109 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
6110         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
6111 }
6112 /// The actual content of the announcement
6113 #[no_mangle]
6114 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
6115         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6116         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 }
6117 }
6118 /// The actual content of the announcement
6119 #[no_mangle]
6120 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
6121         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6122 }
6123 /// Constructs a new NodeAnnouncement given each field
6124 #[must_use]
6125 #[no_mangle]
6126 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
6127         NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
6128                 signature: signature_arg.into_rust(),
6129                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6130         }), is_owned: true }
6131 }
6132 impl Clone for NodeAnnouncement {
6133         fn clone(&self) -> Self {
6134                 Self {
6135                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6136                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6137                         is_owned: true,
6138                 }
6139         }
6140 }
6141 #[allow(unused)]
6142 /// Used only if an object of this type is returned as a trait impl by a method
6143 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6144         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncement)).clone() })) as *mut c_void
6145 }
6146 #[no_mangle]
6147 /// Creates a copy of the NodeAnnouncement
6148 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
6149         orig.clone()
6150 }
6151 /// Checks if two NodeAnnouncements contain equal inner contents.
6152 /// This ignores pointers and is_owned flags and looks at the values in fields.
6153 /// Two objects with NULL inner values will be considered "equal" here.
6154 #[no_mangle]
6155 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
6156         if a.inner == b.inner { return true; }
6157         if a.inner.is_null() || b.inner.is_null() { return false; }
6158         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6159 }
6160
6161 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
6162 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
6163
6164 /// The unsigned part of a [`channel_announcement`] message.
6165 ///
6166 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
6167 #[must_use]
6168 #[repr(C)]
6169 pub struct UnsignedChannelAnnouncement {
6170         /// A pointer to the opaque Rust object.
6171
6172         /// Nearly everywhere, inner must be non-null, however in places where
6173         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6174         pub inner: *mut nativeUnsignedChannelAnnouncement,
6175         /// Indicates that this is the only struct which contains the same pointer.
6176
6177         /// Rust functions which take ownership of an object provided via an argument require
6178         /// this to be true and invalidate the object pointed to by inner.
6179         pub is_owned: bool,
6180 }
6181
6182 impl Drop for UnsignedChannelAnnouncement {
6183         fn drop(&mut self) {
6184                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
6185                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6186                 }
6187         }
6188 }
6189 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
6190 #[no_mangle]
6191 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
6192 #[allow(unused)]
6193 /// Used only if an object of this type is returned as a trait impl by a method
6194 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6195         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
6196 }
6197 #[allow(unused)]
6198 impl UnsignedChannelAnnouncement {
6199         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
6200                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6201         }
6202         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
6203                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6204         }
6205         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6206         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
6207                 assert!(self.is_owned);
6208                 let ret = ObjOps::untweak_ptr(self.inner);
6209                 self.inner = core::ptr::null_mut();
6210                 ret
6211         }
6212 }
6213 /// The advertised channel features
6214 #[no_mangle]
6215 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
6216         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6217         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 }
6218 }
6219 /// The advertised channel features
6220 #[no_mangle]
6221 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
6222         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
6223 }
6224 /// The genesis hash of the blockchain where the channel is to be opened
6225 #[no_mangle]
6226 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
6227         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6228         inner_val.as_bytes()
6229 }
6230 /// The genesis hash of the blockchain where the channel is to be opened
6231 #[no_mangle]
6232 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
6233         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
6234 }
6235 /// The short channel ID
6236 #[no_mangle]
6237 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
6238         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6239         *inner_val
6240 }
6241 /// The short channel ID
6242 #[no_mangle]
6243 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
6244         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6245 }
6246 /// One of the two `node_id`s which are endpoints of this channel
6247 #[no_mangle]
6248 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6249         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
6250         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 }
6251 }
6252 /// One of the two `node_id`s which are endpoints of this channel
6253 #[no_mangle]
6254 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6255         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
6256 }
6257 /// The other of the two `node_id`s which are endpoints of this channel
6258 #[no_mangle]
6259 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6260         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
6261         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 }
6262 }
6263 /// The other of the two `node_id`s which are endpoints of this channel
6264 #[no_mangle]
6265 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6266         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
6267 }
6268 /// The funding key for the first node
6269 #[no_mangle]
6270 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6271         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
6272         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 }
6273 }
6274 /// The funding key for the first node
6275 #[no_mangle]
6276 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6277         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
6278 }
6279 /// The funding key for the second node
6280 #[no_mangle]
6281 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6282         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
6283         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 }
6284 }
6285 /// The funding key for the second node
6286 #[no_mangle]
6287 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6288         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
6289 }
6290 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6291 /// to decode.
6292 ///
6293 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6294 ///
6295 /// Returns a copy of the field.
6296 #[no_mangle]
6297 pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6298         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6299         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6300         local_inner_val.into()
6301 }
6302 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6303 /// to decode.
6304 ///
6305 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6306 #[no_mangle]
6307 pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6308         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6309         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6310 }
6311 /// Constructs a new UnsignedChannelAnnouncement given each field
6312 #[must_use]
6313 #[no_mangle]
6314 pub extern "C" fn UnsignedChannelAnnouncement_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_id_1_arg: crate::lightning::routing::gossip::NodeId, mut node_id_2_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_1_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_2_arg: crate::lightning::routing::gossip::NodeId, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelAnnouncement {
6315         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6316         UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
6317                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
6318                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
6319                 short_channel_id: short_channel_id_arg,
6320                 node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
6321                 node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
6322                 bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
6323                 bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
6324                 excess_data: local_excess_data_arg,
6325         }), is_owned: true }
6326 }
6327 impl Clone for UnsignedChannelAnnouncement {
6328         fn clone(&self) -> Self {
6329                 Self {
6330                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6331                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6332                         is_owned: true,
6333                 }
6334         }
6335 }
6336 #[allow(unused)]
6337 /// Used only if an object of this type is returned as a trait impl by a method
6338 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6339         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
6340 }
6341 #[no_mangle]
6342 /// Creates a copy of the UnsignedChannelAnnouncement
6343 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
6344         orig.clone()
6345 }
6346 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
6347 /// This ignores pointers and is_owned flags and looks at the values in fields.
6348 /// Two objects with NULL inner values will be considered "equal" here.
6349 #[no_mangle]
6350 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
6351         if a.inner == b.inner { return true; }
6352         if a.inner.is_null() || b.inner.is_null() { return false; }
6353         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6354 }
6355
6356 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
6357 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
6358
6359 /// A [`channel_announcement`] message to be sent to or received from a peer.
6360 ///
6361 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
6362 #[must_use]
6363 #[repr(C)]
6364 pub struct ChannelAnnouncement {
6365         /// A pointer to the opaque Rust object.
6366
6367         /// Nearly everywhere, inner must be non-null, however in places where
6368         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6369         pub inner: *mut nativeChannelAnnouncement,
6370         /// Indicates that this is the only struct which contains the same pointer.
6371
6372         /// Rust functions which take ownership of an object provided via an argument require
6373         /// this to be true and invalidate the object pointed to by inner.
6374         pub is_owned: bool,
6375 }
6376
6377 impl Drop for ChannelAnnouncement {
6378         fn drop(&mut self) {
6379                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
6380                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6381                 }
6382         }
6383 }
6384 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
6385 #[no_mangle]
6386 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
6387 #[allow(unused)]
6388 /// Used only if an object of this type is returned as a trait impl by a method
6389 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6390         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
6391 }
6392 #[allow(unused)]
6393 impl ChannelAnnouncement {
6394         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
6395                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6396         }
6397         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
6398                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6399         }
6400         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6401         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
6402                 assert!(self.is_owned);
6403                 let ret = ObjOps::untweak_ptr(self.inner);
6404                 self.inner = core::ptr::null_mut();
6405                 ret
6406         }
6407 }
6408 /// Authentication of the announcement by the first public node
6409 #[no_mangle]
6410 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6411         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
6412         crate::c_types::ECDSASignature::from_rust(&inner_val)
6413 }
6414 /// Authentication of the announcement by the first public node
6415 #[no_mangle]
6416 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6417         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
6418 }
6419 /// Authentication of the announcement by the second public node
6420 #[no_mangle]
6421 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6422         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
6423         crate::c_types::ECDSASignature::from_rust(&inner_val)
6424 }
6425 /// Authentication of the announcement by the second public node
6426 #[no_mangle]
6427 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6428         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
6429 }
6430 /// Proof of funding UTXO ownership by the first public node
6431 #[no_mangle]
6432 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6433         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
6434         crate::c_types::ECDSASignature::from_rust(&inner_val)
6435 }
6436 /// Proof of funding UTXO ownership by the first public node
6437 #[no_mangle]
6438 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6439         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
6440 }
6441 /// Proof of funding UTXO ownership by the second public node
6442 #[no_mangle]
6443 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6444         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
6445         crate::c_types::ECDSASignature::from_rust(&inner_val)
6446 }
6447 /// Proof of funding UTXO ownership by the second public node
6448 #[no_mangle]
6449 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6450         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
6451 }
6452 /// The actual announcement
6453 #[no_mangle]
6454 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
6455         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6456         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 }
6457 }
6458 /// The actual announcement
6459 #[no_mangle]
6460 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
6461         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6462 }
6463 /// Constructs a new ChannelAnnouncement given each field
6464 #[must_use]
6465 #[no_mangle]
6466 pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_types::ECDSASignature, mut node_signature_2_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_1_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_2_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
6467         ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
6468                 node_signature_1: node_signature_1_arg.into_rust(),
6469                 node_signature_2: node_signature_2_arg.into_rust(),
6470                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
6471                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
6472                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6473         }), is_owned: true }
6474 }
6475 impl Clone for ChannelAnnouncement {
6476         fn clone(&self) -> Self {
6477                 Self {
6478                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6479                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6480                         is_owned: true,
6481                 }
6482         }
6483 }
6484 #[allow(unused)]
6485 /// Used only if an object of this type is returned as a trait impl by a method
6486 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6487         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelAnnouncement)).clone() })) as *mut c_void
6488 }
6489 #[no_mangle]
6490 /// Creates a copy of the ChannelAnnouncement
6491 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
6492         orig.clone()
6493 }
6494 /// Checks if two ChannelAnnouncements contain equal inner contents.
6495 /// This ignores pointers and is_owned flags and looks at the values in fields.
6496 /// Two objects with NULL inner values will be considered "equal" here.
6497 #[no_mangle]
6498 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
6499         if a.inner == b.inner { return true; }
6500         if a.inner.is_null() || b.inner.is_null() { return false; }
6501         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6502 }
6503
6504 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
6505 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
6506
6507 /// The unsigned part of a [`channel_update`] message.
6508 ///
6509 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6510 #[must_use]
6511 #[repr(C)]
6512 pub struct UnsignedChannelUpdate {
6513         /// A pointer to the opaque Rust object.
6514
6515         /// Nearly everywhere, inner must be non-null, however in places where
6516         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6517         pub inner: *mut nativeUnsignedChannelUpdate,
6518         /// Indicates that this is the only struct which contains the same pointer.
6519
6520         /// Rust functions which take ownership of an object provided via an argument require
6521         /// this to be true and invalidate the object pointed to by inner.
6522         pub is_owned: bool,
6523 }
6524
6525 impl Drop for UnsignedChannelUpdate {
6526         fn drop(&mut self) {
6527                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
6528                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6529                 }
6530         }
6531 }
6532 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
6533 #[no_mangle]
6534 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
6535 #[allow(unused)]
6536 /// Used only if an object of this type is returned as a trait impl by a method
6537 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
6538         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
6539 }
6540 #[allow(unused)]
6541 impl UnsignedChannelUpdate {
6542         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
6543                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6544         }
6545         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
6546                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6547         }
6548         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6549         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
6550                 assert!(self.is_owned);
6551                 let ret = ObjOps::untweak_ptr(self.inner);
6552                 self.inner = core::ptr::null_mut();
6553                 ret
6554         }
6555 }
6556 /// The genesis hash of the blockchain where the channel is to be opened
6557 #[no_mangle]
6558 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
6559         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6560         inner_val.as_bytes()
6561 }
6562 /// The genesis hash of the blockchain where the channel is to be opened
6563 #[no_mangle]
6564 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
6565         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
6566 }
6567 /// The short channel ID
6568 #[no_mangle]
6569 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
6570         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6571         *inner_val
6572 }
6573 /// The short channel ID
6574 #[no_mangle]
6575 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6576         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6577 }
6578 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6579 #[no_mangle]
6580 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
6581         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
6582         *inner_val
6583 }
6584 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6585 #[no_mangle]
6586 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6587         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
6588 }
6589 /// Channel flags
6590 #[no_mangle]
6591 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
6592         let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
6593         *inner_val
6594 }
6595 /// Channel flags
6596 #[no_mangle]
6597 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
6598         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
6599 }
6600 /// The number of blocks such that if:
6601 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6602 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6603 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6604 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6605 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6606 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6607 /// constructing the route.
6608 #[no_mangle]
6609 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
6610         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
6611         *inner_val
6612 }
6613 /// The number of blocks such that if:
6614 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6615 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6616 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6617 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6618 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6619 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6620 /// constructing the route.
6621 #[no_mangle]
6622 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
6623         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
6624 }
6625 /// The minimum HTLC size incoming to sender, in milli-satoshi
6626 #[no_mangle]
6627 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6628         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
6629         *inner_val
6630 }
6631 /// The minimum HTLC size incoming to sender, in milli-satoshi
6632 #[no_mangle]
6633 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6634         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
6635 }
6636 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6637 ///
6638 /// This used to be optional.
6639 #[no_mangle]
6640 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6641         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
6642         *inner_val
6643 }
6644 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6645 ///
6646 /// This used to be optional.
6647 #[no_mangle]
6648 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6649         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
6650 }
6651 /// The base HTLC fee charged by sender, in milli-satoshi
6652 #[no_mangle]
6653 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
6654         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
6655         *inner_val
6656 }
6657 /// The base HTLC fee charged by sender, in milli-satoshi
6658 #[no_mangle]
6659 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6660         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
6661 }
6662 /// The amount to fee multiplier, in micro-satoshi
6663 #[no_mangle]
6664 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
6665         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
6666         *inner_val
6667 }
6668 /// The amount to fee multiplier, in micro-satoshi
6669 #[no_mangle]
6670 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6671         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
6672 }
6673 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6674 /// to decode.
6675 ///
6676 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6677 ///
6678 /// Returns a copy of the field.
6679 #[no_mangle]
6680 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6681         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6682         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6683         local_inner_val.into()
6684 }
6685 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6686 /// to decode.
6687 ///
6688 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6689 #[no_mangle]
6690 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
6691         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6692         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6693 }
6694 /// Constructs a new UnsignedChannelUpdate given each field
6695 #[must_use]
6696 #[no_mangle]
6697 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 {
6698         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6699         UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
6700                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
6701                 short_channel_id: short_channel_id_arg,
6702                 timestamp: timestamp_arg,
6703                 flags: flags_arg,
6704                 cltv_expiry_delta: cltv_expiry_delta_arg,
6705                 htlc_minimum_msat: htlc_minimum_msat_arg,
6706                 htlc_maximum_msat: htlc_maximum_msat_arg,
6707                 fee_base_msat: fee_base_msat_arg,
6708                 fee_proportional_millionths: fee_proportional_millionths_arg,
6709                 excess_data: local_excess_data_arg,
6710         }), is_owned: true }
6711 }
6712 impl Clone for UnsignedChannelUpdate {
6713         fn clone(&self) -> Self {
6714                 Self {
6715                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6716                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6717                         is_owned: true,
6718                 }
6719         }
6720 }
6721 #[allow(unused)]
6722 /// Used only if an object of this type is returned as a trait impl by a method
6723 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6724         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
6725 }
6726 #[no_mangle]
6727 /// Creates a copy of the UnsignedChannelUpdate
6728 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
6729         orig.clone()
6730 }
6731 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
6732 /// This ignores pointers and is_owned flags and looks at the values in fields.
6733 /// Two objects with NULL inner values will be considered "equal" here.
6734 #[no_mangle]
6735 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
6736         if a.inner == b.inner { return true; }
6737         if a.inner.is_null() || b.inner.is_null() { return false; }
6738         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6739 }
6740
6741 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
6742 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
6743
6744 /// A [`channel_update`] message to be sent to or received from a peer.
6745 ///
6746 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6747 #[must_use]
6748 #[repr(C)]
6749 pub struct ChannelUpdate {
6750         /// A pointer to the opaque Rust object.
6751
6752         /// Nearly everywhere, inner must be non-null, however in places where
6753         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6754         pub inner: *mut nativeChannelUpdate,
6755         /// Indicates that this is the only struct which contains the same pointer.
6756
6757         /// Rust functions which take ownership of an object provided via an argument require
6758         /// this to be true and invalidate the object pointed to by inner.
6759         pub is_owned: bool,
6760 }
6761
6762 impl Drop for ChannelUpdate {
6763         fn drop(&mut self) {
6764                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
6765                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6766                 }
6767         }
6768 }
6769 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
6770 #[no_mangle]
6771 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
6772 #[allow(unused)]
6773 /// Used only if an object of this type is returned as a trait impl by a method
6774 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
6775         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
6776 }
6777 #[allow(unused)]
6778 impl ChannelUpdate {
6779         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
6780                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6781         }
6782         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
6783                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6784         }
6785         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6786         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
6787                 assert!(self.is_owned);
6788                 let ret = ObjOps::untweak_ptr(self.inner);
6789                 self.inner = core::ptr::null_mut();
6790                 ret
6791         }
6792 }
6793 /// A signature of the channel update
6794 #[no_mangle]
6795 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
6796         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
6797         crate::c_types::ECDSASignature::from_rust(&inner_val)
6798 }
6799 /// A signature of the channel update
6800 #[no_mangle]
6801 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
6802         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
6803 }
6804 /// The actual channel update
6805 #[no_mangle]
6806 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
6807         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6808         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 }
6809 }
6810 /// The actual channel update
6811 #[no_mangle]
6812 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
6813         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6814 }
6815 /// Constructs a new ChannelUpdate given each field
6816 #[must_use]
6817 #[no_mangle]
6818 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
6819         ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
6820                 signature: signature_arg.into_rust(),
6821                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6822         }), is_owned: true }
6823 }
6824 impl Clone for ChannelUpdate {
6825         fn clone(&self) -> Self {
6826                 Self {
6827                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6828                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6829                         is_owned: true,
6830                 }
6831         }
6832 }
6833 #[allow(unused)]
6834 /// Used only if an object of this type is returned as a trait impl by a method
6835 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6836         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelUpdate)).clone() })) as *mut c_void
6837 }
6838 #[no_mangle]
6839 /// Creates a copy of the ChannelUpdate
6840 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
6841         orig.clone()
6842 }
6843 /// Checks if two ChannelUpdates contain equal inner contents.
6844 /// This ignores pointers and is_owned flags and looks at the values in fields.
6845 /// Two objects with NULL inner values will be considered "equal" here.
6846 #[no_mangle]
6847 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
6848         if a.inner == b.inner { return true; }
6849         if a.inner.is_null() || b.inner.is_null() { return false; }
6850         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6851 }
6852
6853 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
6854 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
6855
6856 /// A [`query_channel_range`] message is used to query a peer for channel
6857 /// UTXOs in a range of blocks. The recipient of a query makes a best
6858 /// effort to reply to the query using one or more [`ReplyChannelRange`]
6859 /// messages.
6860 ///
6861 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6862 #[must_use]
6863 #[repr(C)]
6864 pub struct QueryChannelRange {
6865         /// A pointer to the opaque Rust object.
6866
6867         /// Nearly everywhere, inner must be non-null, however in places where
6868         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6869         pub inner: *mut nativeQueryChannelRange,
6870         /// Indicates that this is the only struct which contains the same pointer.
6871
6872         /// Rust functions which take ownership of an object provided via an argument require
6873         /// this to be true and invalidate the object pointed to by inner.
6874         pub is_owned: bool,
6875 }
6876
6877 impl Drop for QueryChannelRange {
6878         fn drop(&mut self) {
6879                 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
6880                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6881                 }
6882         }
6883 }
6884 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
6885 #[no_mangle]
6886 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
6887 #[allow(unused)]
6888 /// Used only if an object of this type is returned as a trait impl by a method
6889 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
6890         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
6891 }
6892 #[allow(unused)]
6893 impl QueryChannelRange {
6894         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
6895                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6896         }
6897         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
6898                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6899         }
6900         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6901         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
6902                 assert!(self.is_owned);
6903                 let ret = ObjOps::untweak_ptr(self.inner);
6904                 self.inner = core::ptr::null_mut();
6905                 ret
6906         }
6907 }
6908 /// The genesis hash of the blockchain being queried
6909 #[no_mangle]
6910 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
6911         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6912         inner_val.as_bytes()
6913 }
6914 /// The genesis hash of the blockchain being queried
6915 #[no_mangle]
6916 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
6917         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
6918 }
6919 /// The height of the first block for the channel UTXOs being queried
6920 #[no_mangle]
6921 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
6922         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
6923         *inner_val
6924 }
6925 /// The height of the first block for the channel UTXOs being queried
6926 #[no_mangle]
6927 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
6928         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
6929 }
6930 /// The number of blocks to include in the query results
6931 #[no_mangle]
6932 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
6933         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
6934         *inner_val
6935 }
6936 /// The number of blocks to include in the query results
6937 #[no_mangle]
6938 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
6939         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
6940 }
6941 /// Constructs a new QueryChannelRange given each field
6942 #[must_use]
6943 #[no_mangle]
6944 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 {
6945         QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
6946                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
6947                 first_blocknum: first_blocknum_arg,
6948                 number_of_blocks: number_of_blocks_arg,
6949         }), is_owned: true }
6950 }
6951 impl Clone for QueryChannelRange {
6952         fn clone(&self) -> Self {
6953                 Self {
6954                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
6955                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6956                         is_owned: true,
6957                 }
6958         }
6959 }
6960 #[allow(unused)]
6961 /// Used only if an object of this type is returned as a trait impl by a method
6962 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
6963         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryChannelRange)).clone() })) as *mut c_void
6964 }
6965 #[no_mangle]
6966 /// Creates a copy of the QueryChannelRange
6967 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
6968         orig.clone()
6969 }
6970 /// Checks if two QueryChannelRanges contain equal inner contents.
6971 /// This ignores pointers and is_owned flags and looks at the values in fields.
6972 /// Two objects with NULL inner values will be considered "equal" here.
6973 #[no_mangle]
6974 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
6975         if a.inner == b.inner { return true; }
6976         if a.inner.is_null() || b.inner.is_null() { return false; }
6977         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6978 }
6979
6980 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
6981 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
6982
6983 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
6984 /// message.
6985 ///
6986 /// Multiple `reply_channel_range` messages can be sent in reply
6987 /// to a single [`QueryChannelRange`] message. The query recipient makes a
6988 /// best effort to respond based on their local network view which may
6989 /// not be a perfect view of the network. The `short_channel_id`s in the
6990 /// reply are encoded. We only support `encoding_type=0` uncompressed
6991 /// serialization and do not support `encoding_type=1` zlib serialization.
6992 ///
6993 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6994 #[must_use]
6995 #[repr(C)]
6996 pub struct ReplyChannelRange {
6997         /// A pointer to the opaque Rust object.
6998
6999         /// Nearly everywhere, inner must be non-null, however in places where
7000         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7001         pub inner: *mut nativeReplyChannelRange,
7002         /// Indicates that this is the only struct which contains the same pointer.
7003
7004         /// Rust functions which take ownership of an object provided via an argument require
7005         /// this to be true and invalidate the object pointed to by inner.
7006         pub is_owned: bool,
7007 }
7008
7009 impl Drop for ReplyChannelRange {
7010         fn drop(&mut self) {
7011                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
7012                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7013                 }
7014         }
7015 }
7016 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
7017 #[no_mangle]
7018 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
7019 #[allow(unused)]
7020 /// Used only if an object of this type is returned as a trait impl by a method
7021 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
7022         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
7023 }
7024 #[allow(unused)]
7025 impl ReplyChannelRange {
7026         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
7027                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7028         }
7029         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
7030                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7031         }
7032         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7033         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
7034                 assert!(self.is_owned);
7035                 let ret = ObjOps::untweak_ptr(self.inner);
7036                 self.inner = core::ptr::null_mut();
7037                 ret
7038         }
7039 }
7040 /// The genesis hash of the blockchain being queried
7041 #[no_mangle]
7042 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
7043         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7044         inner_val.as_bytes()
7045 }
7046 /// The genesis hash of the blockchain being queried
7047 #[no_mangle]
7048 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
7049         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
7050 }
7051 /// The height of the first block in the range of the reply
7052 #[no_mangle]
7053 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
7054         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
7055         *inner_val
7056 }
7057 /// The height of the first block in the range of the reply
7058 #[no_mangle]
7059 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
7060         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
7061 }
7062 /// The number of blocks included in the range of the reply
7063 #[no_mangle]
7064 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
7065         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
7066         *inner_val
7067 }
7068 /// The number of blocks included in the range of the reply
7069 #[no_mangle]
7070 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
7071         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
7072 }
7073 /// True when this is the final reply for a query
7074 #[no_mangle]
7075 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
7076         let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
7077         *inner_val
7078 }
7079 /// True when this is the final reply for a query
7080 #[no_mangle]
7081 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
7082         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
7083 }
7084 /// The `short_channel_id`s in the channel range
7085 ///
7086 /// Returns a copy of the field.
7087 #[no_mangle]
7088 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
7089         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
7090         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7091         local_inner_val.into()
7092 }
7093 /// The `short_channel_id`s in the channel range
7094 #[no_mangle]
7095 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
7096         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7097         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
7098 }
7099 /// Constructs a new ReplyChannelRange given each field
7100 #[must_use]
7101 #[no_mangle]
7102 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 {
7103         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 }); };
7104         ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
7105                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
7106                 first_blocknum: first_blocknum_arg,
7107                 number_of_blocks: number_of_blocks_arg,
7108                 sync_complete: sync_complete_arg,
7109                 short_channel_ids: local_short_channel_ids_arg,
7110         }), is_owned: true }
7111 }
7112 impl Clone for ReplyChannelRange {
7113         fn clone(&self) -> Self {
7114                 Self {
7115                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
7116                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7117                         is_owned: true,
7118                 }
7119         }
7120 }
7121 #[allow(unused)]
7122 /// Used only if an object of this type is returned as a trait impl by a method
7123 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
7124         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyChannelRange)).clone() })) as *mut c_void
7125 }
7126 #[no_mangle]
7127 /// Creates a copy of the ReplyChannelRange
7128 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
7129         orig.clone()
7130 }
7131 /// Checks if two ReplyChannelRanges contain equal inner contents.
7132 /// This ignores pointers and is_owned flags and looks at the values in fields.
7133 /// Two objects with NULL inner values will be considered "equal" here.
7134 #[no_mangle]
7135 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
7136         if a.inner == b.inner { return true; }
7137         if a.inner.is_null() || b.inner.is_null() { return false; }
7138         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7139 }
7140
7141 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
7142 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
7143
7144 /// A [`query_short_channel_ids`] message is used to query a peer for
7145 /// routing gossip messages related to one or more `short_channel_id`s.
7146 ///
7147 /// The query recipient will reply with the latest, if available,
7148 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
7149 /// it maintains for the requested `short_channel_id`s followed by a
7150 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
7151 /// this query are encoded. We only support `encoding_type=0` uncompressed
7152 /// serialization and do not support `encoding_type=1` zlib serialization.
7153 ///
7154 /// [`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
7155 #[must_use]
7156 #[repr(C)]
7157 pub struct QueryShortChannelIds {
7158         /// A pointer to the opaque Rust object.
7159
7160         /// Nearly everywhere, inner must be non-null, however in places where
7161         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7162         pub inner: *mut nativeQueryShortChannelIds,
7163         /// Indicates that this is the only struct which contains the same pointer.
7164
7165         /// Rust functions which take ownership of an object provided via an argument require
7166         /// this to be true and invalidate the object pointed to by inner.
7167         pub is_owned: bool,
7168 }
7169
7170 impl Drop for QueryShortChannelIds {
7171         fn drop(&mut self) {
7172                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
7173                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7174                 }
7175         }
7176 }
7177 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
7178 #[no_mangle]
7179 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
7180 #[allow(unused)]
7181 /// Used only if an object of this type is returned as a trait impl by a method
7182 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
7183         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
7184 }
7185 #[allow(unused)]
7186 impl QueryShortChannelIds {
7187         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
7188                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7189         }
7190         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
7191                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7192         }
7193         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7194         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
7195                 assert!(self.is_owned);
7196                 let ret = ObjOps::untweak_ptr(self.inner);
7197                 self.inner = core::ptr::null_mut();
7198                 ret
7199         }
7200 }
7201 /// The genesis hash of the blockchain being queried
7202 #[no_mangle]
7203 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
7204         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7205         inner_val.as_bytes()
7206 }
7207 /// The genesis hash of the blockchain being queried
7208 #[no_mangle]
7209 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
7210         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
7211 }
7212 /// The short_channel_ids that are being queried
7213 ///
7214 /// Returns a copy of the field.
7215 #[no_mangle]
7216 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
7217         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
7218         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7219         local_inner_val.into()
7220 }
7221 /// The short_channel_ids that are being queried
7222 #[no_mangle]
7223 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
7224         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7225         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
7226 }
7227 /// Constructs a new QueryShortChannelIds given each field
7228 #[must_use]
7229 #[no_mangle]
7230 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 {
7231         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 }); };
7232         QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
7233                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
7234                 short_channel_ids: local_short_channel_ids_arg,
7235         }), is_owned: true }
7236 }
7237 impl Clone for QueryShortChannelIds {
7238         fn clone(&self) -> Self {
7239                 Self {
7240                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
7241                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7242                         is_owned: true,
7243                 }
7244         }
7245 }
7246 #[allow(unused)]
7247 /// Used only if an object of this type is returned as a trait impl by a method
7248 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
7249         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryShortChannelIds)).clone() })) as *mut c_void
7250 }
7251 #[no_mangle]
7252 /// Creates a copy of the QueryShortChannelIds
7253 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
7254         orig.clone()
7255 }
7256 /// Checks if two QueryShortChannelIdss contain equal inner contents.
7257 /// This ignores pointers and is_owned flags and looks at the values in fields.
7258 /// Two objects with NULL inner values will be considered "equal" here.
7259 #[no_mangle]
7260 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
7261         if a.inner == b.inner { return true; }
7262         if a.inner.is_null() || b.inner.is_null() { return false; }
7263         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7264 }
7265
7266 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
7267 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
7268
7269 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
7270 /// message. The query recipient makes a best
7271 /// effort to respond based on their local network view which may not be
7272 /// a perfect view of the network.
7273 ///
7274 /// [`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
7275 #[must_use]
7276 #[repr(C)]
7277 pub struct ReplyShortChannelIdsEnd {
7278         /// A pointer to the opaque Rust object.
7279
7280         /// Nearly everywhere, inner must be non-null, however in places where
7281         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7282         pub inner: *mut nativeReplyShortChannelIdsEnd,
7283         /// Indicates that this is the only struct which contains the same pointer.
7284
7285         /// Rust functions which take ownership of an object provided via an argument require
7286         /// this to be true and invalidate the object pointed to by inner.
7287         pub is_owned: bool,
7288 }
7289
7290 impl Drop for ReplyShortChannelIdsEnd {
7291         fn drop(&mut self) {
7292                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
7293                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7294                 }
7295         }
7296 }
7297 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
7298 #[no_mangle]
7299 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
7300 #[allow(unused)]
7301 /// Used only if an object of this type is returned as a trait impl by a method
7302 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
7303         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
7304 }
7305 #[allow(unused)]
7306 impl ReplyShortChannelIdsEnd {
7307         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
7308                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7309         }
7310         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
7311                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7312         }
7313         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7314         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
7315                 assert!(self.is_owned);
7316                 let ret = ObjOps::untweak_ptr(self.inner);
7317                 self.inner = core::ptr::null_mut();
7318                 ret
7319         }
7320 }
7321 /// The genesis hash of the blockchain that was queried
7322 #[no_mangle]
7323 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
7324         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7325         inner_val.as_bytes()
7326 }
7327 /// The genesis hash of the blockchain that was queried
7328 #[no_mangle]
7329 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
7330         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
7331 }
7332 /// Indicates if the query recipient maintains up-to-date channel
7333 /// information for the `chain_hash`
7334 #[no_mangle]
7335 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
7336         let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
7337         *inner_val
7338 }
7339 /// Indicates if the query recipient maintains up-to-date channel
7340 /// information for the `chain_hash`
7341 #[no_mangle]
7342 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
7343         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
7344 }
7345 /// Constructs a new ReplyShortChannelIdsEnd given each field
7346 #[must_use]
7347 #[no_mangle]
7348 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
7349         ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
7350                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
7351                 full_information: full_information_arg,
7352         }), is_owned: true }
7353 }
7354 impl Clone for ReplyShortChannelIdsEnd {
7355         fn clone(&self) -> Self {
7356                 Self {
7357                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
7358                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7359                         is_owned: true,
7360                 }
7361         }
7362 }
7363 #[allow(unused)]
7364 /// Used only if an object of this type is returned as a trait impl by a method
7365 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
7366         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
7367 }
7368 #[no_mangle]
7369 /// Creates a copy of the ReplyShortChannelIdsEnd
7370 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
7371         orig.clone()
7372 }
7373 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
7374 /// This ignores pointers and is_owned flags and looks at the values in fields.
7375 /// Two objects with NULL inner values will be considered "equal" here.
7376 #[no_mangle]
7377 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
7378         if a.inner == b.inner { return true; }
7379         if a.inner.is_null() || b.inner.is_null() { return false; }
7380         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7381 }
7382
7383 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
7384 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
7385
7386 /// A [`gossip_timestamp_filter`] message is used by a node to request
7387 /// gossip relay for messages in the requested time range when the
7388 /// `gossip_queries` feature has been negotiated.
7389 ///
7390 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
7391 #[must_use]
7392 #[repr(C)]
7393 pub struct GossipTimestampFilter {
7394         /// A pointer to the opaque Rust object.
7395
7396         /// Nearly everywhere, inner must be non-null, however in places where
7397         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7398         pub inner: *mut nativeGossipTimestampFilter,
7399         /// Indicates that this is the only struct which contains the same pointer.
7400
7401         /// Rust functions which take ownership of an object provided via an argument require
7402         /// this to be true and invalidate the object pointed to by inner.
7403         pub is_owned: bool,
7404 }
7405
7406 impl Drop for GossipTimestampFilter {
7407         fn drop(&mut self) {
7408                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
7409                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7410                 }
7411         }
7412 }
7413 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
7414 #[no_mangle]
7415 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
7416 #[allow(unused)]
7417 /// Used only if an object of this type is returned as a trait impl by a method
7418 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
7419         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
7420 }
7421 #[allow(unused)]
7422 impl GossipTimestampFilter {
7423         pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
7424                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7425         }
7426         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
7427                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7428         }
7429         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7430         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
7431                 assert!(self.is_owned);
7432                 let ret = ObjOps::untweak_ptr(self.inner);
7433                 self.inner = core::ptr::null_mut();
7434                 ret
7435         }
7436 }
7437 /// The genesis hash of the blockchain for channel and node information
7438 #[no_mangle]
7439 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
7440         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7441         inner_val.as_bytes()
7442 }
7443 /// The genesis hash of the blockchain for channel and node information
7444 #[no_mangle]
7445 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
7446         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
7447 }
7448 /// The starting unix timestamp
7449 #[no_mangle]
7450 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
7451         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
7452         *inner_val
7453 }
7454 /// The starting unix timestamp
7455 #[no_mangle]
7456 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7457         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
7458 }
7459 /// The range of information in seconds
7460 #[no_mangle]
7461 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
7462         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
7463         *inner_val
7464 }
7465 /// The range of information in seconds
7466 #[no_mangle]
7467 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7468         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
7469 }
7470 /// Constructs a new GossipTimestampFilter given each field
7471 #[must_use]
7472 #[no_mangle]
7473 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 {
7474         GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
7475                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
7476                 first_timestamp: first_timestamp_arg,
7477                 timestamp_range: timestamp_range_arg,
7478         }), is_owned: true }
7479 }
7480 impl Clone for GossipTimestampFilter {
7481         fn clone(&self) -> Self {
7482                 Self {
7483                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
7484                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7485                         is_owned: true,
7486                 }
7487         }
7488 }
7489 #[allow(unused)]
7490 /// Used only if an object of this type is returned as a trait impl by a method
7491 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
7492         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeGossipTimestampFilter)).clone() })) as *mut c_void
7493 }
7494 #[no_mangle]
7495 /// Creates a copy of the GossipTimestampFilter
7496 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
7497         orig.clone()
7498 }
7499 /// Checks if two GossipTimestampFilters contain equal inner contents.
7500 /// This ignores pointers and is_owned flags and looks at the values in fields.
7501 /// Two objects with NULL inner values will be considered "equal" here.
7502 #[no_mangle]
7503 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
7504         if a.inner == b.inner { return true; }
7505         if a.inner.is_null() || b.inner.is_null() { return false; }
7506         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7507 }
7508 /// Used to put an error message in a [`LightningError`].
7509 #[derive(Clone)]
7510 #[must_use]
7511 #[repr(C)]
7512 pub enum ErrorAction {
7513         /// The peer took some action which made us think they were useless. Disconnect them.
7514         DisconnectPeer {
7515                 /// An error message which we should make an effort to send before we disconnect.
7516                 ///
7517                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
7518                 msg: crate::lightning::ln::msgs::ErrorMessage,
7519         },
7520         /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
7521         DisconnectPeerWithWarning {
7522                 /// A warning message which we should make an effort to send before we disconnect.
7523                 msg: crate::lightning::ln::msgs::WarningMessage,
7524         },
7525         /// The peer did something harmless that we weren't able to process, just log and ignore
7526         IgnoreError,
7527         /// The peer did something harmless that we weren't able to meaningfully process.
7528         /// If the error is logged, log it at the given level.
7529         IgnoreAndLog(
7530                 crate::lightning::util::logger::Level),
7531         /// The peer provided us with a gossip message which we'd already seen. In most cases this
7532         /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
7533         /// our own channel announcements.
7534         IgnoreDuplicateGossip,
7535         /// The peer did something incorrect. Tell them.
7536         SendErrorMessage {
7537                 /// The message to send.
7538                 msg: crate::lightning::ln::msgs::ErrorMessage,
7539         },
7540         /// The peer did something incorrect. Tell them without closing any channels.
7541         SendWarningMessage {
7542                 /// The message to send.
7543                 msg: crate::lightning::ln::msgs::WarningMessage,
7544                 /// The peer may have done something harmless that we weren't able to meaningfully process,
7545                 /// though we should still tell them about it.
7546                 /// If this event is logged, log it at the given level.
7547                 log_level: crate::lightning::util::logger::Level,
7548         },
7549 }
7550 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
7551 pub(crate) type nativeErrorAction = ErrorActionImport;
7552
7553 impl ErrorAction {
7554         #[allow(unused)]
7555         pub(crate) fn to_native(&self) -> nativeErrorAction {
7556                 match self {
7557                         ErrorAction::DisconnectPeer {ref msg, } => {
7558                                 let mut msg_nonref = Clone::clone(msg);
7559                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
7560                                 nativeErrorAction::DisconnectPeer {
7561                                         msg: local_msg_nonref,
7562                                 }
7563                         },
7564                         ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7565                                 let mut msg_nonref = Clone::clone(msg);
7566                                 nativeErrorAction::DisconnectPeerWithWarning {
7567                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7568                                 }
7569                         },
7570                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7571                         ErrorAction::IgnoreAndLog (ref a, ) => {
7572                                 let mut a_nonref = Clone::clone(a);
7573                                 nativeErrorAction::IgnoreAndLog (
7574                                         a_nonref.into_native(),
7575                                 )
7576                         },
7577                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7578                         ErrorAction::SendErrorMessage {ref msg, } => {
7579                                 let mut msg_nonref = Clone::clone(msg);
7580                                 nativeErrorAction::SendErrorMessage {
7581                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7582                                 }
7583                         },
7584                         ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7585                                 let mut msg_nonref = Clone::clone(msg);
7586                                 let mut log_level_nonref = Clone::clone(log_level);
7587                                 nativeErrorAction::SendWarningMessage {
7588                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7589                                         log_level: log_level_nonref.into_native(),
7590                                 }
7591                         },
7592                 }
7593         }
7594         #[allow(unused)]
7595         pub(crate) fn into_native(self) -> nativeErrorAction {
7596                 match self {
7597                         ErrorAction::DisconnectPeer {mut msg, } => {
7598                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
7599                                 nativeErrorAction::DisconnectPeer {
7600                                         msg: local_msg,
7601                                 }
7602                         },
7603                         ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7604                                 nativeErrorAction::DisconnectPeerWithWarning {
7605                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
7606                                 }
7607                         },
7608                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7609                         ErrorAction::IgnoreAndLog (mut a, ) => {
7610                                 nativeErrorAction::IgnoreAndLog (
7611                                         a.into_native(),
7612                                 )
7613                         },
7614                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7615                         ErrorAction::SendErrorMessage {mut msg, } => {
7616                                 nativeErrorAction::SendErrorMessage {
7617                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
7618                                 }
7619                         },
7620                         ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7621                                 nativeErrorAction::SendWarningMessage {
7622                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
7623                                         log_level: log_level.into_native(),
7624                                 }
7625                         },
7626                 }
7627         }
7628         #[allow(unused)]
7629         pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
7630                 match native {
7631                         nativeErrorAction::DisconnectPeer {ref msg, } => {
7632                                 let mut msg_nonref = Clone::clone(msg);
7633                                 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 };
7634                                 ErrorAction::DisconnectPeer {
7635                                         msg: local_msg_nonref,
7636                                 }
7637                         },
7638                         nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7639                                 let mut msg_nonref = Clone::clone(msg);
7640                                 ErrorAction::DisconnectPeerWithWarning {
7641                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7642                                 }
7643                         },
7644                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7645                         nativeErrorAction::IgnoreAndLog (ref a, ) => {
7646                                 let mut a_nonref = Clone::clone(a);
7647                                 ErrorAction::IgnoreAndLog (
7648                                         crate::lightning::util::logger::Level::native_into(a_nonref),
7649                                 )
7650                         },
7651                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7652                         nativeErrorAction::SendErrorMessage {ref msg, } => {
7653                                 let mut msg_nonref = Clone::clone(msg);
7654                                 ErrorAction::SendErrorMessage {
7655                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7656                                 }
7657                         },
7658                         nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7659                                 let mut msg_nonref = Clone::clone(msg);
7660                                 let mut log_level_nonref = Clone::clone(log_level);
7661                                 ErrorAction::SendWarningMessage {
7662                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7663                                         log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
7664                                 }
7665                         },
7666                 }
7667         }
7668         #[allow(unused)]
7669         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
7670                 match native {
7671                         nativeErrorAction::DisconnectPeer {mut msg, } => {
7672                                 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 };
7673                                 ErrorAction::DisconnectPeer {
7674                                         msg: local_msg,
7675                                 }
7676                         },
7677                         nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7678                                 ErrorAction::DisconnectPeerWithWarning {
7679                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7680                                 }
7681                         },
7682                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7683                         nativeErrorAction::IgnoreAndLog (mut a, ) => {
7684                                 ErrorAction::IgnoreAndLog (
7685                                         crate::lightning::util::logger::Level::native_into(a),
7686                                 )
7687                         },
7688                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7689                         nativeErrorAction::SendErrorMessage {mut msg, } => {
7690                                 ErrorAction::SendErrorMessage {
7691                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7692                                 }
7693                         },
7694                         nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7695                                 ErrorAction::SendWarningMessage {
7696                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7697                                         log_level: crate::lightning::util::logger::Level::native_into(log_level),
7698                                 }
7699                         },
7700                 }
7701         }
7702 }
7703 /// Frees any resources used by the ErrorAction
7704 #[no_mangle]
7705 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
7706 /// Creates a copy of the ErrorAction
7707 #[no_mangle]
7708 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
7709         orig.clone()
7710 }
7711 #[allow(unused)]
7712 /// Used only if an object of this type is returned as a trait impl by a method
7713 pub(crate) extern "C" fn ErrorAction_clone_void(this_ptr: *const c_void) -> *mut c_void {
7714         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ErrorAction)).clone() })) as *mut c_void
7715 }
7716 #[allow(unused)]
7717 /// Used only if an object of this type is returned as a trait impl by a method
7718 pub(crate) extern "C" fn ErrorAction_free_void(this_ptr: *mut c_void) {
7719         let _ = unsafe { Box::from_raw(this_ptr as *mut ErrorAction) };
7720 }
7721 #[no_mangle]
7722 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
7723 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7724         ErrorAction::DisconnectPeer {
7725                 msg,
7726         }
7727 }
7728 #[no_mangle]
7729 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
7730 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
7731         ErrorAction::DisconnectPeerWithWarning {
7732                 msg,
7733         }
7734 }
7735 #[no_mangle]
7736 /// Utility method to constructs a new IgnoreError-variant ErrorAction
7737 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
7738         ErrorAction::IgnoreError}
7739 #[no_mangle]
7740 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
7741 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
7742         ErrorAction::IgnoreAndLog(a, )
7743 }
7744 #[no_mangle]
7745 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
7746 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
7747         ErrorAction::IgnoreDuplicateGossip}
7748 #[no_mangle]
7749 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
7750 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7751         ErrorAction::SendErrorMessage {
7752                 msg,
7753         }
7754 }
7755 #[no_mangle]
7756 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
7757 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
7758         ErrorAction::SendWarningMessage {
7759                 msg,
7760                 log_level,
7761         }
7762 }
7763
7764 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
7765 pub(crate) type nativeLightningError = nativeLightningErrorImport;
7766
7767 /// An Err type for failure to process messages.
7768 #[must_use]
7769 #[repr(C)]
7770 pub struct LightningError {
7771         /// A pointer to the opaque Rust object.
7772
7773         /// Nearly everywhere, inner must be non-null, however in places where
7774         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7775         pub inner: *mut nativeLightningError,
7776         /// Indicates that this is the only struct which contains the same pointer.
7777
7778         /// Rust functions which take ownership of an object provided via an argument require
7779         /// this to be true and invalidate the object pointed to by inner.
7780         pub is_owned: bool,
7781 }
7782
7783 impl Drop for LightningError {
7784         fn drop(&mut self) {
7785                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
7786                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7787                 }
7788         }
7789 }
7790 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
7791 #[no_mangle]
7792 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
7793 #[allow(unused)]
7794 /// Used only if an object of this type is returned as a trait impl by a method
7795 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
7796         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
7797 }
7798 #[allow(unused)]
7799 impl LightningError {
7800         pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
7801                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7802         }
7803         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
7804                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7805         }
7806         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7807         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
7808                 assert!(self.is_owned);
7809                 let ret = ObjOps::untweak_ptr(self.inner);
7810                 self.inner = core::ptr::null_mut();
7811                 ret
7812         }
7813 }
7814 /// A human-readable message describing the error
7815 #[no_mangle]
7816 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
7817         let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
7818         inner_val.as_str().into()
7819 }
7820 /// A human-readable message describing the error
7821 #[no_mangle]
7822 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
7823         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
7824 }
7825 /// The action which should be taken against the offending peer.
7826 #[no_mangle]
7827 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
7828         let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
7829         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
7830 }
7831 /// The action which should be taken against the offending peer.
7832 #[no_mangle]
7833 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
7834         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
7835 }
7836 /// Constructs a new LightningError given each field
7837 #[must_use]
7838 #[no_mangle]
7839 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
7840         LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
7841                 err: err_arg.into_string(),
7842                 action: action_arg.into_native(),
7843         }), is_owned: true }
7844 }
7845 impl Clone for LightningError {
7846         fn clone(&self) -> Self {
7847                 Self {
7848                         inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
7849                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7850                         is_owned: true,
7851                 }
7852         }
7853 }
7854 #[allow(unused)]
7855 /// Used only if an object of this type is returned as a trait impl by a method
7856 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
7857         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLightningError)).clone() })) as *mut c_void
7858 }
7859 #[no_mangle]
7860 /// Creates a copy of the LightningError
7861 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
7862         orig.clone()
7863 }
7864
7865 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
7866 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
7867
7868 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
7869 /// transaction updates if they were pending.
7870 #[must_use]
7871 #[repr(C)]
7872 pub struct CommitmentUpdate {
7873         /// A pointer to the opaque Rust object.
7874
7875         /// Nearly everywhere, inner must be non-null, however in places where
7876         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7877         pub inner: *mut nativeCommitmentUpdate,
7878         /// Indicates that this is the only struct which contains the same pointer.
7879
7880         /// Rust functions which take ownership of an object provided via an argument require
7881         /// this to be true and invalidate the object pointed to by inner.
7882         pub is_owned: bool,
7883 }
7884
7885 impl Drop for CommitmentUpdate {
7886         fn drop(&mut self) {
7887                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
7888                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7889                 }
7890         }
7891 }
7892 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
7893 #[no_mangle]
7894 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
7895 #[allow(unused)]
7896 /// Used only if an object of this type is returned as a trait impl by a method
7897 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
7898         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
7899 }
7900 #[allow(unused)]
7901 impl CommitmentUpdate {
7902         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
7903                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7904         }
7905         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
7906                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7907         }
7908         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7909         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
7910                 assert!(self.is_owned);
7911                 let ret = ObjOps::untweak_ptr(self.inner);
7912                 self.inner = core::ptr::null_mut();
7913                 ret
7914         }
7915 }
7916 /// `update_add_htlc` messages which should be sent
7917 #[no_mangle]
7918 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
7919         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
7920         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 } }); };
7921         local_inner_val.into()
7922 }
7923 /// `update_add_htlc` messages which should be sent
7924 #[no_mangle]
7925 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
7926         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7927         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
7928 }
7929 /// `update_fulfill_htlc` messages which should be sent
7930 #[no_mangle]
7931 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
7932         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
7933         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 } }); };
7934         local_inner_val.into()
7935 }
7936 /// `update_fulfill_htlc` messages which should be sent
7937 #[no_mangle]
7938 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
7939         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7940         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
7941 }
7942 /// `update_fail_htlc` messages which should be sent
7943 #[no_mangle]
7944 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
7945         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
7946         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 } }); };
7947         local_inner_val.into()
7948 }
7949 /// `update_fail_htlc` messages which should be sent
7950 #[no_mangle]
7951 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
7952         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7953         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
7954 }
7955 /// `update_fail_malformed_htlc` messages which should be sent
7956 #[no_mangle]
7957 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
7958         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
7959         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 } }); };
7960         local_inner_val.into()
7961 }
7962 /// `update_fail_malformed_htlc` messages which should be sent
7963 #[no_mangle]
7964 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
7965         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7966         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
7967 }
7968 /// An `update_fee` message which should be sent
7969 ///
7970 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
7971 #[no_mangle]
7972 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
7973         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
7974         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 };
7975         local_inner_val
7976 }
7977 /// An `update_fee` message which should be sent
7978 ///
7979 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
7980 #[no_mangle]
7981 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
7982         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
7983         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
7984 }
7985 /// A `commitment_signed` message which should be sent
7986 #[no_mangle]
7987 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
7988         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
7989         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 }
7990 }
7991 /// A `commitment_signed` message which should be sent
7992 #[no_mangle]
7993 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
7994         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
7995 }
7996 /// Constructs a new CommitmentUpdate given each field
7997 ///
7998 /// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
7999 #[must_use]
8000 #[no_mangle]
8001 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 {
8002         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()) } }); };
8003         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()) } }); };
8004         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()) } }); };
8005         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()) } }); };
8006         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()) } }) };
8007         CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
8008                 update_add_htlcs: local_update_add_htlcs_arg,
8009                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
8010                 update_fail_htlcs: local_update_fail_htlcs_arg,
8011                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
8012                 update_fee: local_update_fee_arg,
8013                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
8014         }), is_owned: true }
8015 }
8016 impl Clone for CommitmentUpdate {
8017         fn clone(&self) -> Self {
8018                 Self {
8019                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
8020                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8021                         is_owned: true,
8022                 }
8023         }
8024 }
8025 #[allow(unused)]
8026 /// Used only if an object of this type is returned as a trait impl by a method
8027 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
8028         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentUpdate)).clone() })) as *mut c_void
8029 }
8030 #[no_mangle]
8031 /// Creates a copy of the CommitmentUpdate
8032 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
8033         orig.clone()
8034 }
8035 /// Checks if two CommitmentUpdates contain equal inner contents.
8036 /// This ignores pointers and is_owned flags and looks at the values in fields.
8037 /// Two objects with NULL inner values will be considered "equal" here.
8038 #[no_mangle]
8039 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
8040         if a.inner == b.inner { return true; }
8041         if a.inner.is_null() || b.inner.is_null() { return false; }
8042         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8043 }
8044 /// A trait to describe an object which can receive channel messages.
8045 ///
8046 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
8047 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
8048 #[repr(C)]
8049 pub struct ChannelMessageHandler {
8050         /// An opaque pointer which is passed to your function implementations as an argument.
8051         /// This has no meaning in the LDK, and can be NULL or any other value.
8052         pub this_arg: *mut c_void,
8053         /// Handle an incoming `open_channel` message from the given peer.
8054         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),
8055         /// Handle an incoming `open_channel2` message from the given peer.
8056         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),
8057         /// Handle an incoming `accept_channel` message from the given peer.
8058         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),
8059         /// Handle an incoming `accept_channel2` message from the given peer.
8060         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),
8061         /// Handle an incoming `funding_created` message from the given peer.
8062         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),
8063         /// Handle an incoming `funding_signed` message from the given peer.
8064         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),
8065         /// Handle an incoming `channel_ready` message from the given peer.
8066         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),
8067         /// Handle an incoming `shutdown` message from the given peer.
8068         pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
8069         /// Handle an incoming `closing_signed` message from the given peer.
8070         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),
8071         /// Handle an incoming `tx_add_input message` from the given peer.
8072         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),
8073         /// Handle an incoming `tx_add_output` message from the given peer.
8074         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),
8075         /// Handle an incoming `tx_remove_input` message from the given peer.
8076         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),
8077         /// Handle an incoming `tx_remove_output` message from the given peer.
8078         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),
8079         /// Handle an incoming `tx_complete message` from the given peer.
8080         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),
8081         /// Handle an incoming `tx_signatures` message from the given peer.
8082         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),
8083         /// Handle an incoming `tx_init_rbf` message from the given peer.
8084         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),
8085         /// Handle an incoming `tx_ack_rbf` message from the given peer.
8086         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),
8087         /// Handle an incoming `tx_abort message` from the given peer.
8088         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),
8089         /// Handle an incoming `update_add_htlc` message from the given peer.
8090         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),
8091         /// Handle an incoming `update_fulfill_htlc` message from the given peer.
8092         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),
8093         /// Handle an incoming `update_fail_htlc` message from the given peer.
8094         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),
8095         /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
8096         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),
8097         /// Handle an incoming `commitment_signed` message from the given peer.
8098         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),
8099         /// Handle an incoming `revoke_and_ack` message from the given peer.
8100         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),
8101         /// Handle an incoming `update_fee` message from the given peer.
8102         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),
8103         /// Handle an incoming `announcement_signatures` message from the given peer.
8104         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),
8105         /// Indicates a connection to the peer failed/an existing connection was lost.
8106         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
8107         /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
8108         ///
8109         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8110         /// with us. Implementors should be somewhat conservative about doing so, however, as other
8111         /// message handlers may still wish to communicate with this peer.
8112         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,
8113         /// Handle an incoming `channel_reestablish` message from the given peer.
8114         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),
8115         /// Handle an incoming `channel_update` message from the given peer.
8116         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),
8117         /// Handle an incoming `error` message from the given peer.
8118         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
8119         /// Gets the node feature flags which this handler itself supports. All available handlers are
8120         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8121         /// which are broadcasted in our [`NodeAnnouncement`] message.
8122         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8123         /// Gets the init feature flags which should be sent to the given peer. All available handlers
8124         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8125         /// which are sent in our [`Init`] message.
8126         ///
8127         /// Note that this method is called before [`Self::peer_connected`].
8128         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8129         /// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
8130         ///
8131         /// If it's `None`, then no particular network chain hash compatibility will be enforced when
8132         /// connecting to peers.
8133         pub get_chain_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ,
8134         /// Implementation of MessageSendEventsProvider for this object.
8135         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
8136         /// Frees any resources associated with this object given its this_arg pointer.
8137         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8138         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8139 }
8140 unsafe impl Send for ChannelMessageHandler {}
8141 unsafe impl Sync for ChannelMessageHandler {}
8142 #[allow(unused)]
8143 pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
8144         ChannelMessageHandler {
8145                 this_arg: orig.this_arg,
8146                 handle_open_channel: Clone::clone(&orig.handle_open_channel),
8147                 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
8148                 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
8149                 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
8150                 handle_funding_created: Clone::clone(&orig.handle_funding_created),
8151                 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
8152                 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
8153                 handle_shutdown: Clone::clone(&orig.handle_shutdown),
8154                 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
8155                 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
8156                 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
8157                 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
8158                 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
8159                 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
8160                 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
8161                 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
8162                 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
8163                 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
8164                 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
8165                 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
8166                 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
8167                 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
8168                 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
8169                 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
8170                 handle_update_fee: Clone::clone(&orig.handle_update_fee),
8171                 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
8172                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
8173                 peer_connected: Clone::clone(&orig.peer_connected),
8174                 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
8175                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
8176                 handle_error: Clone::clone(&orig.handle_error),
8177                 provided_node_features: Clone::clone(&orig.provided_node_features),
8178                 provided_init_features: Clone::clone(&orig.provided_init_features),
8179                 get_chain_hashes: Clone::clone(&orig.get_chain_hashes),
8180                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
8181                 free: Clone::clone(&orig.free),
8182         }
8183 }
8184 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
8185         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
8186                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
8187                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
8188                 local_ret
8189         }
8190 }
8191
8192 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
8193 impl rustChannelMessageHandler for ChannelMessageHandler {
8194         fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
8195                 (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 })
8196         }
8197         fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
8198                 (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 })
8199         }
8200         fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
8201                 (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 })
8202         }
8203         fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
8204                 (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 })
8205         }
8206         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
8207                 (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 })
8208         }
8209         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
8210                 (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 })
8211         }
8212         fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
8213                 (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 })
8214         }
8215         fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
8216                 (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 })
8217         }
8218         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
8219                 (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 })
8220         }
8221         fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
8222                 (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 })
8223         }
8224         fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
8225                 (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 })
8226         }
8227         fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
8228                 (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 })
8229         }
8230         fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
8231                 (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 })
8232         }
8233         fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
8234                 (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 })
8235         }
8236         fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
8237                 (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 })
8238         }
8239         fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
8240                 (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 })
8241         }
8242         fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
8243                 (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 })
8244         }
8245         fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
8246                 (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 })
8247         }
8248         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
8249                 (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 })
8250         }
8251         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
8252                 (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 })
8253         }
8254         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
8255                 (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 })
8256         }
8257         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
8258                 (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 })
8259         }
8260         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
8261                 (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 })
8262         }
8263         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
8264                 (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 })
8265         }
8266         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
8267                 (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 })
8268         }
8269         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
8270                 (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 })
8271         }
8272         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8273                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8274         }
8275         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8276                 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);
8277                 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)) })*/ })};
8278                 local_ret
8279         }
8280         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
8281                 (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 })
8282         }
8283         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
8284                 (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 })
8285         }
8286         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
8287                 (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 })
8288         }
8289         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8290                 let mut ret = (self.provided_node_features)(self.this_arg);
8291                 *unsafe { Box::from_raw(ret.take_inner()) }
8292         }
8293         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8294                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8295                 *unsafe { Box::from_raw(ret.take_inner()) }
8296         }
8297         fn get_chain_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
8298                 let mut ret = (self.get_chain_hashes)(self.this_arg);
8299                 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 }})} };
8300                 local_ret
8301         }
8302 }
8303
8304 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8305 // directly as a Deref trait in higher-level structs:
8306 impl core::ops::Deref for ChannelMessageHandler {
8307         type Target = Self;
8308         fn deref(&self) -> &Self {
8309                 self
8310         }
8311 }
8312 impl core::ops::DerefMut for ChannelMessageHandler {
8313         fn deref_mut(&mut self) -> &mut Self {
8314                 self
8315         }
8316 }
8317 /// Calls the free function if one is set
8318 #[no_mangle]
8319 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
8320 impl Drop for ChannelMessageHandler {
8321         fn drop(&mut self) {
8322                 if let Some(f) = self.free {
8323                         f(self.this_arg);
8324                 }
8325         }
8326 }
8327 /// A trait to describe an object which can receive routing messages.
8328 ///
8329 /// # Implementor DoS Warnings
8330 ///
8331 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
8332 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
8333 /// repeated disk I/O for queries accessing different parts of the network graph.
8334 #[repr(C)]
8335 pub struct RoutingMessageHandler {
8336         /// An opaque pointer which is passed to your function implementations as an argument.
8337         /// This has no meaning in the LDK, and can be NULL or any other value.
8338         pub this_arg: *mut c_void,
8339         /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
8340         /// `false` or returning an `Err` otherwise.
8341         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8342         /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
8343         /// or returning an `Err` otherwise.
8344         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8345         /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
8346         /// `false` or returning an `Err` otherwise.
8347         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8348         /// Gets channel announcements and updates required to dump our routing table to a remote node,
8349         /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
8350         /// for a single channel.
8351         pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
8352         /// Gets a node announcement required to dump our routing table to a remote node, starting at
8353         /// the node *after* the provided pubkey and including up to one announcement immediately
8354         /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
8355         /// If `None` is provided for `starting_point`, we start at the first node.
8356         ///
8357         /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
8358         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
8359         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,
8360         /// Called when a connection is established with a peer. This can be used to
8361         /// perform routing table synchronization using a strategy defined by the
8362         /// implementor.
8363         ///
8364         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8365         /// with us. Implementors should be somewhat conservative about doing so, however, as other
8366         /// message handlers may still wish to communicate with this peer.
8367         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,
8368         /// Handles the reply of a query we initiated to learn about channels
8369         /// for a given range of blocks. We can expect to receive one or more
8370         /// replies to a single query.
8371         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,
8372         /// Handles the reply of a query we initiated asking for routing gossip
8373         /// messages for a list of channels. We should receive this message when
8374         /// a node has completed its best effort to send us the pertaining routing
8375         /// gossip messages.
8376         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,
8377         /// Handles when a peer asks us to send a list of `short_channel_id`s
8378         /// for the requested range of blocks.
8379         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,
8380         /// Handles when a peer asks us to send routing gossip messages for a
8381         /// list of `short_channel_id`s.
8382         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,
8383         /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
8384         /// pending some async action. While there is no guarantee of the rate of future messages, the
8385         /// caller should seek to reduce the rate of new gossip messages handled, especially
8386         /// [`ChannelAnnouncement`]s.
8387         pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
8388         /// Gets the node feature flags which this handler itself supports. All available handlers are
8389         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8390         /// which are broadcasted in our [`NodeAnnouncement`] message.
8391         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8392         /// Gets the init feature flags which should be sent to the given peer. All available handlers
8393         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8394         /// which are sent in our [`Init`] message.
8395         ///
8396         /// Note that this method is called before [`Self::peer_connected`].
8397         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8398         /// Implementation of MessageSendEventsProvider for this object.
8399         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
8400         /// Frees any resources associated with this object given its this_arg pointer.
8401         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8402         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8403 }
8404 unsafe impl Send for RoutingMessageHandler {}
8405 unsafe impl Sync for RoutingMessageHandler {}
8406 #[allow(unused)]
8407 pub(crate) fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
8408         RoutingMessageHandler {
8409                 this_arg: orig.this_arg,
8410                 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
8411                 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
8412                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
8413                 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
8414                 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
8415                 peer_connected: Clone::clone(&orig.peer_connected),
8416                 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
8417                 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
8418                 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
8419                 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
8420                 processing_queue_high: Clone::clone(&orig.processing_queue_high),
8421                 provided_node_features: Clone::clone(&orig.provided_node_features),
8422                 provided_init_features: Clone::clone(&orig.provided_init_features),
8423                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
8424                 free: Clone::clone(&orig.free),
8425         }
8426 }
8427 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
8428         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
8429                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
8430                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
8431                 local_ret
8432         }
8433 }
8434
8435 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
8436 impl rustRoutingMessageHandler for RoutingMessageHandler {
8437         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8438                 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 });
8439                 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()) } })};
8440                 local_ret
8441         }
8442         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8443                 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 });
8444                 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()) } })};
8445                 local_ret
8446         }
8447         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
8448                 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 });
8449                 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()) } })};
8450                 local_ret
8451         }
8452         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>)> {
8453                 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
8454                 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 };
8455                 local_ret
8456         }
8457         fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
8458                 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 };
8459                 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
8460                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8461                 local_ret
8462         }
8463         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8464                 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);
8465                 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)) })*/ })};
8466                 local_ret
8467         }
8468         fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8469                 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 });
8470                 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()) } })};
8471                 local_ret
8472         }
8473         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> {
8474                 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 });
8475                 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()) } })};
8476                 local_ret
8477         }
8478         fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8479                 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 });
8480                 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()) } })};
8481                 local_ret
8482         }
8483         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> {
8484                 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 });
8485                 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()) } })};
8486                 local_ret
8487         }
8488         fn processing_queue_high(&self) -> bool {
8489                 let mut ret = (self.processing_queue_high)(self.this_arg);
8490                 ret
8491         }
8492         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8493                 let mut ret = (self.provided_node_features)(self.this_arg);
8494                 *unsafe { Box::from_raw(ret.take_inner()) }
8495         }
8496         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8497                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8498                 *unsafe { Box::from_raw(ret.take_inner()) }
8499         }
8500 }
8501
8502 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8503 // directly as a Deref trait in higher-level structs:
8504 impl core::ops::Deref for RoutingMessageHandler {
8505         type Target = Self;
8506         fn deref(&self) -> &Self {
8507                 self
8508         }
8509 }
8510 impl core::ops::DerefMut for RoutingMessageHandler {
8511         fn deref_mut(&mut self) -> &mut Self {
8512                 self
8513         }
8514 }
8515 /// Calls the free function if one is set
8516 #[no_mangle]
8517 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
8518 impl Drop for RoutingMessageHandler {
8519         fn drop(&mut self) {
8520                 if let Some(f) = self.free {
8521                         f(self.this_arg);
8522                 }
8523         }
8524 }
8525 /// A handler for received [`OnionMessage`]s and for providing generated ones to send.
8526 #[repr(C)]
8527 pub struct OnionMessageHandler {
8528         /// An opaque pointer which is passed to your function implementations as an argument.
8529         /// This has no meaning in the LDK, and can be NULL or any other value.
8530         pub this_arg: *mut c_void,
8531         /// Handle an incoming `onion_message` message from the given peer.
8532         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),
8533         /// Returns the next pending onion message for the peer with the given node id.
8534         ///
8535         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
8536         pub next_onion_message_for_peer: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage,
8537         /// Called when a connection is established with a peer. Can be used to track which peers
8538         /// advertise onion message support and are online.
8539         ///
8540         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8541         /// with us. Implementors should be somewhat conservative about doing so, however, as other
8542         /// message handlers may still wish to communicate with this peer.
8543         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,
8544         /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
8545         /// drop and refuse to forward onion messages to this peer.
8546         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
8547         /// Gets the node feature flags which this handler itself supports. All available handlers are
8548         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8549         /// which are broadcasted in our [`NodeAnnouncement`] message.
8550         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8551         /// Gets the init feature flags which should be sent to the given peer. All available handlers
8552         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8553         /// which are sent in our [`Init`] message.
8554         ///
8555         /// Note that this method is called before [`Self::peer_connected`].
8556         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8557         /// Frees any resources associated with this object given its this_arg pointer.
8558         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8559         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8560 }
8561 unsafe impl Send for OnionMessageHandler {}
8562 unsafe impl Sync for OnionMessageHandler {}
8563 #[allow(unused)]
8564 pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
8565         OnionMessageHandler {
8566                 this_arg: orig.this_arg,
8567                 handle_onion_message: Clone::clone(&orig.handle_onion_message),
8568                 next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
8569                 peer_connected: Clone::clone(&orig.peer_connected),
8570                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
8571                 provided_node_features: Clone::clone(&orig.provided_node_features),
8572                 provided_init_features: Clone::clone(&orig.provided_init_features),
8573                 free: Clone::clone(&orig.free),
8574         }
8575 }
8576
8577 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
8578 impl rustOnionMessageHandler for OnionMessageHandler {
8579         fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
8580                 (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 })
8581         }
8582         fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
8583                 let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
8584                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8585                 local_ret
8586         }
8587         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8588                 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);
8589                 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)) })*/ })};
8590                 local_ret
8591         }
8592         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8593                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8594         }
8595         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8596                 let mut ret = (self.provided_node_features)(self.this_arg);
8597                 *unsafe { Box::from_raw(ret.take_inner()) }
8598         }
8599         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8600                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8601                 *unsafe { Box::from_raw(ret.take_inner()) }
8602         }
8603 }
8604
8605 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8606 // directly as a Deref trait in higher-level structs:
8607 impl core::ops::Deref for OnionMessageHandler {
8608         type Target = Self;
8609         fn deref(&self) -> &Self {
8610                 self
8611         }
8612 }
8613 impl core::ops::DerefMut for OnionMessageHandler {
8614         fn deref_mut(&mut self) -> &mut Self {
8615                 self
8616         }
8617 }
8618 /// Calls the free function if one is set
8619 #[no_mangle]
8620 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
8621 impl Drop for OnionMessageHandler {
8622         fn drop(&mut self) {
8623                 if let Some(f) = self.free {
8624                         f(self.this_arg);
8625                 }
8626         }
8627 }
8628 mod fuzzy_internal_msgs {
8629
8630 use alloc::str::FromStr;
8631 use alloc::string::String;
8632 use core::ffi::c_void;
8633 use core::convert::Infallible;
8634 use bitcoin::hashes::Hash;
8635 use crate::c_types::*;
8636 #[cfg(feature="no-std")]
8637 use alloc::{vec::Vec, boxed::Box};
8638
8639 }
8640 #[no_mangle]
8641 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
8642 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
8643         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8644 }
8645 #[allow(unused)]
8646 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8647         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
8648 }
8649 #[no_mangle]
8650 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
8651 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
8652         let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8653         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() };
8654         local_res
8655 }
8656 #[no_mangle]
8657 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
8658 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
8659         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8660 }
8661 #[allow(unused)]
8662 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8663         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
8664 }
8665 #[no_mangle]
8666 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
8667 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
8668         let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8669         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() };
8670         local_res
8671 }
8672 #[no_mangle]
8673 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
8674 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
8675         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8676 }
8677 #[allow(unused)]
8678 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8679         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
8680 }
8681 #[no_mangle]
8682 /// Read a TxAddInput from a byte array, created by TxAddInput_write
8683 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
8684         let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8685         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() };
8686         local_res
8687 }
8688 #[no_mangle]
8689 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
8690 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
8691         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8692 }
8693 #[allow(unused)]
8694 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8695         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
8696 }
8697 #[no_mangle]
8698 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
8699 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
8700         let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8701         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() };
8702         local_res
8703 }
8704 #[no_mangle]
8705 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
8706 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
8707         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8708 }
8709 #[allow(unused)]
8710 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8711         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
8712 }
8713 #[no_mangle]
8714 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
8715 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
8716         let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8717         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() };
8718         local_res
8719 }
8720 #[no_mangle]
8721 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
8722 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
8723         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8724 }
8725 #[allow(unused)]
8726 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8727         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
8728 }
8729 #[no_mangle]
8730 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
8731 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
8732         let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8733         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() };
8734         local_res
8735 }
8736 #[no_mangle]
8737 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
8738 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
8739         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8740 }
8741 #[allow(unused)]
8742 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8743         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
8744 }
8745 #[no_mangle]
8746 /// Read a TxComplete from a byte array, created by TxComplete_write
8747 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
8748         let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8749         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() };
8750         local_res
8751 }
8752 #[no_mangle]
8753 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
8754 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
8755         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8756 }
8757 #[allow(unused)]
8758 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8759         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
8760 }
8761 #[no_mangle]
8762 /// Read a TxSignatures from a byte array, created by TxSignatures_write
8763 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
8764         let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8765         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() };
8766         local_res
8767 }
8768 #[no_mangle]
8769 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
8770 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
8771         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8772 }
8773 #[allow(unused)]
8774 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8775         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
8776 }
8777 #[no_mangle]
8778 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
8779 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
8780         let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8781         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() };
8782         local_res
8783 }
8784 #[no_mangle]
8785 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
8786 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
8787         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8788 }
8789 #[allow(unused)]
8790 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8791         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
8792 }
8793 #[no_mangle]
8794 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
8795 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
8796         let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8797         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() };
8798         local_res
8799 }
8800 #[no_mangle]
8801 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
8802 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
8803         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8804 }
8805 #[allow(unused)]
8806 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8807         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
8808 }
8809 #[no_mangle]
8810 /// Read a TxAbort from a byte array, created by TxAbort_write
8811 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
8812         let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8813         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() };
8814         local_res
8815 }
8816 #[no_mangle]
8817 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
8818 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
8819         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8820 }
8821 #[allow(unused)]
8822 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8823         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
8824 }
8825 #[no_mangle]
8826 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
8827 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
8828         let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8829         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() };
8830         local_res
8831 }
8832 #[no_mangle]
8833 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
8834 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
8835         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8836 }
8837 #[allow(unused)]
8838 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8839         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
8840 }
8841 #[no_mangle]
8842 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
8843 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
8844         let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8845         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() };
8846         local_res
8847 }
8848 #[no_mangle]
8849 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
8850 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
8851         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8852 }
8853 #[allow(unused)]
8854 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8855         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
8856 }
8857 #[no_mangle]
8858 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
8859 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
8860         let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8861         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() };
8862         local_res
8863 }
8864 #[no_mangle]
8865 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
8866 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
8867         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8868 }
8869 #[allow(unused)]
8870 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8871         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
8872 }
8873 #[no_mangle]
8874 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
8875 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
8876         let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8877         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() };
8878         local_res
8879 }
8880 #[no_mangle]
8881 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
8882 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
8883         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8884 }
8885 #[allow(unused)]
8886 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8887         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
8888 }
8889 #[no_mangle]
8890 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
8891 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
8892         let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8893         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() };
8894         local_res
8895 }
8896 #[no_mangle]
8897 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
8898 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
8899         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8900 }
8901 #[allow(unused)]
8902 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8903         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
8904 }
8905 #[no_mangle]
8906 /// Read a FundingCreated from a byte array, created by FundingCreated_write
8907 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
8908         let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8909         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() };
8910         local_res
8911 }
8912 #[no_mangle]
8913 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
8914 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
8915         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8916 }
8917 #[allow(unused)]
8918 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8919         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
8920 }
8921 #[no_mangle]
8922 /// Read a FundingSigned from a byte array, created by FundingSigned_write
8923 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
8924         let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8925         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() };
8926         local_res
8927 }
8928 #[no_mangle]
8929 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
8930 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
8931         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8932 }
8933 #[allow(unused)]
8934 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8935         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
8936 }
8937 #[no_mangle]
8938 /// Read a ChannelReady from a byte array, created by ChannelReady_write
8939 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
8940         let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8941         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() };
8942         local_res
8943 }
8944 #[no_mangle]
8945 /// Serialize the Init object into a byte array which can be read by Init_read
8946 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
8947         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8948 }
8949 #[allow(unused)]
8950 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8951         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
8952 }
8953 #[no_mangle]
8954 /// Read a Init from a byte array, created by Init_write
8955 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
8956         let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8957         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() };
8958         local_res
8959 }
8960 #[no_mangle]
8961 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
8962 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
8963         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8964 }
8965 #[allow(unused)]
8966 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8967         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
8968 }
8969 #[no_mangle]
8970 /// Read a OpenChannel from a byte array, created by OpenChannel_write
8971 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
8972         let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8973         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() };
8974         local_res
8975 }
8976 #[no_mangle]
8977 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
8978 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
8979         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8980 }
8981 #[allow(unused)]
8982 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8983         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
8984 }
8985 #[no_mangle]
8986 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
8987 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
8988         let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8989         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() };
8990         local_res
8991 }
8992 #[no_mangle]
8993 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
8994 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
8995         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8996 }
8997 #[allow(unused)]
8998 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8999         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
9000 }
9001 #[no_mangle]
9002 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
9003 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
9004         let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9005         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() };
9006         local_res
9007 }
9008 #[no_mangle]
9009 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
9010 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
9011         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9012 }
9013 #[allow(unused)]
9014 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9015         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
9016 }
9017 #[no_mangle]
9018 /// Read a Shutdown from a byte array, created by Shutdown_write
9019 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
9020         let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9021         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() };
9022         local_res
9023 }
9024 #[no_mangle]
9025 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
9026 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
9027         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9028 }
9029 #[allow(unused)]
9030 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9031         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
9032 }
9033 #[no_mangle]
9034 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
9035 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
9036         let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9037         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() };
9038         local_res
9039 }
9040 #[no_mangle]
9041 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
9042 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
9043         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9044 }
9045 #[allow(unused)]
9046 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9047         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
9048 }
9049 #[no_mangle]
9050 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
9051 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
9052         let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9053         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() };
9054         local_res
9055 }
9056 #[no_mangle]
9057 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
9058 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
9059         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9060 }
9061 #[allow(unused)]
9062 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9063         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
9064 }
9065 #[no_mangle]
9066 /// Read a UpdateFee from a byte array, created by UpdateFee_write
9067 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
9068         let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9069         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() };
9070         local_res
9071 }
9072 #[no_mangle]
9073 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
9074 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
9075         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9076 }
9077 #[allow(unused)]
9078 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9079         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
9080 }
9081 #[no_mangle]
9082 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
9083 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
9084         let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, 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::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() };
9086         local_res
9087 }
9088 #[no_mangle]
9089 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
9090 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
9091         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9092 }
9093 #[allow(unused)]
9094 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9095         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
9096 }
9097 #[no_mangle]
9098 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
9099 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
9100         let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9101         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() };
9102         local_res
9103 }
9104 #[no_mangle]
9105 /// Read a OnionMessage from a byte array, created by OnionMessage_write
9106 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
9107         let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9108         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() };
9109         local_res
9110 }
9111 #[no_mangle]
9112 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
9113 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
9114         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9115 }
9116 #[allow(unused)]
9117 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9118         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
9119 }
9120 #[no_mangle]
9121 /// Serialize the Ping object into a byte array which can be read by Ping_read
9122 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
9123         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9124 }
9125 #[allow(unused)]
9126 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9127         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
9128 }
9129 #[no_mangle]
9130 /// Read a Ping from a byte array, created by Ping_write
9131 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
9132         let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9133         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() };
9134         local_res
9135 }
9136 #[no_mangle]
9137 /// Serialize the Pong object into a byte array which can be read by Pong_read
9138 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
9139         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9140 }
9141 #[allow(unused)]
9142 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9143         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
9144 }
9145 #[no_mangle]
9146 /// Read a Pong from a byte array, created by Pong_write
9147 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
9148         let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9149         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() };
9150         local_res
9151 }
9152 #[no_mangle]
9153 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
9154 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9155         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9156 }
9157 #[allow(unused)]
9158 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9159         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
9160 }
9161 #[no_mangle]
9162 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
9163 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
9164         let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9165         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() };
9166         local_res
9167 }
9168 #[no_mangle]
9169 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
9170 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9171         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9172 }
9173 #[allow(unused)]
9174 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9175         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
9176 }
9177 #[no_mangle]
9178 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
9179 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
9180         let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9181         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() };
9182         local_res
9183 }
9184 #[no_mangle]
9185 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
9186 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
9187         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9188 }
9189 #[allow(unused)]
9190 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9191         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
9192 }
9193 #[no_mangle]
9194 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
9195 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
9196         let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9197         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() };
9198         local_res
9199 }
9200 #[no_mangle]
9201 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
9202 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
9203         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9204 }
9205 #[allow(unused)]
9206 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9207         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
9208 }
9209 #[no_mangle]
9210 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
9211 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
9212         let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9213         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() };
9214         local_res
9215 }
9216 #[no_mangle]
9217 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
9218 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
9219         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9220 }
9221 #[allow(unused)]
9222 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9223         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
9224 }
9225 #[no_mangle]
9226 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
9227 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
9228         let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9229         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() };
9230         local_res
9231 }
9232 #[no_mangle]
9233 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
9234 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
9235         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9236 }
9237 #[allow(unused)]
9238 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9239         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
9240 }
9241 #[no_mangle]
9242 /// Read a WarningMessage from a byte array, created by WarningMessage_write
9243 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
9244         let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9245         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() };
9246         local_res
9247 }
9248 #[no_mangle]
9249 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
9250 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9251         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9252 }
9253 #[allow(unused)]
9254 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9255         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
9256 }
9257 #[no_mangle]
9258 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
9259 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
9260         let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9261         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() };
9262         local_res
9263 }
9264 #[no_mangle]
9265 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
9266 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9267         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9268 }
9269 #[allow(unused)]
9270 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9271         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
9272 }
9273 #[no_mangle]
9274 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
9275 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
9276         let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9277         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() };
9278         local_res
9279 }
9280 #[no_mangle]
9281 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
9282 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
9283         let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9284         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() };
9285         local_res
9286 }
9287 #[no_mangle]
9288 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
9289 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
9290         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9291 }
9292 #[allow(unused)]
9293 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9294         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
9295 }
9296 #[no_mangle]
9297 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
9298 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
9299         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9300 }
9301 #[allow(unused)]
9302 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9303         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
9304 }
9305 #[no_mangle]
9306 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
9307 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
9308         let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9309         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() };
9310         local_res
9311 }
9312 /// Calculates the overflow safe ending block height for the query.
9313 ///
9314 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
9315 #[must_use]
9316 #[no_mangle]
9317 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
9318         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
9319         ret
9320 }
9321
9322 #[no_mangle]
9323 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
9324 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
9325         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9326 }
9327 #[allow(unused)]
9328 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9329         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
9330 }
9331 #[no_mangle]
9332 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
9333 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
9334         let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9335         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() };
9336         local_res
9337 }
9338 #[no_mangle]
9339 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
9340 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
9341         let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9342         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() };
9343         local_res
9344 }
9345 #[no_mangle]
9346 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
9347 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
9348         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9349 }
9350 #[allow(unused)]
9351 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9352         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
9353 }
9354 #[no_mangle]
9355 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
9356 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
9357         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9358 }
9359 #[allow(unused)]
9360 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9361         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
9362 }
9363 #[no_mangle]
9364 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
9365 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
9366         let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9367         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() };
9368         local_res
9369 }