Update CI/Cargo.toml references to 0.0.122
[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: &DecodeErrorImport) -> Self {
101                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeDecodeError) };
102                 match native {
103                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
104                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
105                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
106                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
107                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
108                         nativeDecodeError::Io (ref a, ) => {
109                                 let mut a_nonref = Clone::clone(a);
110                                 DecodeError::Io (
111                                         crate::c_types::IOError::from_rust_kind(a_nonref),
112                                 )
113                         },
114                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
115                 }
116         }
117         #[allow(unused)]
118         pub(crate) fn native_into(native: nativeDecodeError) -> Self {
119                 match native {
120                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
121                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
122                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
123                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
124                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
125                         nativeDecodeError::Io (mut a, ) => {
126                                 DecodeError::Io (
127                                         crate::c_types::IOError::from_rust_kind(a),
128                                 )
129                         },
130                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
131                 }
132         }
133 }
134 /// Frees any resources used by the DecodeError
135 #[no_mangle]
136 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
137 /// Creates a copy of the DecodeError
138 #[no_mangle]
139 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
140         orig.clone()
141 }
142 #[allow(unused)]
143 /// Used only if an object of this type is returned as a trait impl by a method
144 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
145         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const DecodeError)).clone() })) as *mut c_void
146 }
147 #[allow(unused)]
148 /// Used only if an object of this type is returned as a trait impl by a method
149 pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
150         let _ = unsafe { Box::from_raw(this_ptr as *mut DecodeError) };
151 }
152 #[no_mangle]
153 /// Utility method to constructs a new UnknownVersion-variant DecodeError
154 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
155         DecodeError::UnknownVersion}
156 #[no_mangle]
157 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
158 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
159         DecodeError::UnknownRequiredFeature}
160 #[no_mangle]
161 /// Utility method to constructs a new InvalidValue-variant DecodeError
162 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
163         DecodeError::InvalidValue}
164 #[no_mangle]
165 /// Utility method to constructs a new ShortRead-variant DecodeError
166 pub extern "C" fn DecodeError_short_read() -> DecodeError {
167         DecodeError::ShortRead}
168 #[no_mangle]
169 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
170 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
171         DecodeError::BadLengthDescriptor}
172 #[no_mangle]
173 /// Utility method to constructs a new Io-variant DecodeError
174 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
175         DecodeError::Io(a, )
176 }
177 #[no_mangle]
178 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
179 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
180         DecodeError::UnsupportedCompression}
181 /// Get a string which allows debug introspection of a DecodeError object
182 pub extern "C" fn DecodeError_debug_str_void(o: *const c_void) -> Str {
183         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::DecodeError }).into()}
184 /// Generates a non-cryptographic 64-bit hash of the DecodeError.
185 #[no_mangle]
186 pub extern "C" fn DecodeError_hash(o: &DecodeError) -> u64 {
187         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
188         #[allow(deprecated)]
189         let mut hasher = core::hash::SipHasher::new();
190         core::hash::Hash::hash(&o.to_native(), &mut hasher);
191         core::hash::Hasher::finish(&hasher)
192 }
193 /// Checks if two DecodeErrors contain equal inner contents.
194 /// This ignores pointers and is_owned flags and looks at the values in fields.
195 #[no_mangle]
196 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
197         if &a.to_native() == &b.to_native() { true } else { false }
198 }
199
200 use lightning::ln::msgs::Init as nativeInitImport;
201 pub(crate) type nativeInit = nativeInitImport;
202
203 /// An [`init`] message to be sent to or received from a peer.
204 ///
205 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
206 #[must_use]
207 #[repr(C)]
208 pub struct Init {
209         /// A pointer to the opaque Rust object.
210
211         /// Nearly everywhere, inner must be non-null, however in places where
212         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
213         pub inner: *mut nativeInit,
214         /// Indicates that this is the only struct which contains the same pointer.
215
216         /// Rust functions which take ownership of an object provided via an argument require
217         /// this to be true and invalidate the object pointed to by inner.
218         pub is_owned: bool,
219 }
220
221 impl Drop for Init {
222         fn drop(&mut self) {
223                 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
224                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
225                 }
226         }
227 }
228 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
229 #[no_mangle]
230 pub extern "C" fn Init_free(this_obj: Init) { }
231 #[allow(unused)]
232 /// Used only if an object of this type is returned as a trait impl by a method
233 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
234         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
235 }
236 #[allow(unused)]
237 impl Init {
238         pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
239                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
240         }
241         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
242                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
243         }
244         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
245         pub(crate) fn take_inner(mut self) -> *mut nativeInit {
246                 assert!(self.is_owned);
247                 let ret = ObjOps::untweak_ptr(self.inner);
248                 self.inner = core::ptr::null_mut();
249                 ret
250         }
251 }
252 /// The relevant features which the sender supports.
253 #[no_mangle]
254 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
255         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
256         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 }
257 }
258 /// The relevant features which the sender supports.
259 #[no_mangle]
260 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
261         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
262 }
263 /// Indicates chains the sender is interested in.
264 ///
265 /// If there are no common chains, the connection will be closed.
266 ///
267 /// Returns a copy of the field.
268 #[no_mangle]
269 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
270         let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
271         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.as_ref() } }); }; local_inner_val_0.into() }) };
272         local_inner_val
273 }
274 /// Indicates chains the sender is interested in.
275 ///
276 /// If there are no common chains, the connection will be closed.
277 #[no_mangle]
278 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ) {
279         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 }})} };
280         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
281 }
282 /// The receipient's network address.
283 ///
284 /// This adds the option to report a remote IP address back to a connecting peer using the init
285 /// message. A node can decide to use that information to discover a potential update to its
286 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
287 /// the new address.
288 #[no_mangle]
289 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_SocketAddressZ {
290         let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
291         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()) }) };
292         local_inner_val
293 }
294 /// The receipient's network address.
295 ///
296 /// This adds the option to report a remote IP address back to a connecting peer using the init
297 /// message. A node can decide to use that information to discover a potential update to its
298 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
299 /// the new address.
300 #[no_mangle]
301 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_SocketAddressZ) {
302         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
303         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
304 }
305 /// Constructs a new Init given each field
306 #[must_use]
307 #[no_mangle]
308 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 {
309         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 }})} };
310         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() }})} };
311         Init { inner: ObjOps::heap_alloc(nativeInit {
312                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
313                 networks: local_networks_arg,
314                 remote_network_address: local_remote_network_address_arg,
315         }), is_owned: true }
316 }
317 impl Clone for Init {
318         fn clone(&self) -> Self {
319                 Self {
320                         inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
321                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
322                         is_owned: true,
323                 }
324         }
325 }
326 #[allow(unused)]
327 /// Used only if an object of this type is returned as a trait impl by a method
328 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
329         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInit)).clone() })) as *mut c_void
330 }
331 #[no_mangle]
332 /// Creates a copy of the Init
333 pub extern "C" fn Init_clone(orig: &Init) -> Init {
334         orig.clone()
335 }
336 /// Get a string which allows debug introspection of a Init object
337 pub extern "C" fn Init_debug_str_void(o: *const c_void) -> Str {
338         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Init }).into()}
339 /// Generates a non-cryptographic 64-bit hash of the Init.
340 #[no_mangle]
341 pub extern "C" fn Init_hash(o: &Init) -> u64 {
342         if o.inner.is_null() { return 0; }
343         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
344         #[allow(deprecated)]
345         let mut hasher = core::hash::SipHasher::new();
346         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
347         core::hash::Hasher::finish(&hasher)
348 }
349 /// Checks if two Inits contain equal inner contents.
350 /// This ignores pointers and is_owned flags and looks at the values in fields.
351 /// Two objects with NULL inner values will be considered "equal" here.
352 #[no_mangle]
353 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
354         if a.inner == b.inner { return true; }
355         if a.inner.is_null() || b.inner.is_null() { return false; }
356         if a.get_native_ref() == b.get_native_ref() { true } else { false }
357 }
358
359 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
360 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
361
362 /// An [`error`] message to be sent to or received from a peer.
363 ///
364 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
365 #[must_use]
366 #[repr(C)]
367 pub struct ErrorMessage {
368         /// A pointer to the opaque Rust object.
369
370         /// Nearly everywhere, inner must be non-null, however in places where
371         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
372         pub inner: *mut nativeErrorMessage,
373         /// Indicates that this is the only struct which contains the same pointer.
374
375         /// Rust functions which take ownership of an object provided via an argument require
376         /// this to be true and invalidate the object pointed to by inner.
377         pub is_owned: bool,
378 }
379
380 impl Drop for ErrorMessage {
381         fn drop(&mut self) {
382                 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
383                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
384                 }
385         }
386 }
387 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
388 #[no_mangle]
389 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
390 #[allow(unused)]
391 /// Used only if an object of this type is returned as a trait impl by a method
392 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
393         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
394 }
395 #[allow(unused)]
396 impl ErrorMessage {
397         pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
398                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
399         }
400         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
401                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
402         }
403         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
404         pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
405                 assert!(self.is_owned);
406                 let ret = ObjOps::untweak_ptr(self.inner);
407                 self.inner = core::ptr::null_mut();
408                 ret
409         }
410 }
411 /// The channel ID involved in the error.
412 ///
413 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
414 /// with the sending peer should be closed.
415 #[no_mangle]
416 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
417         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
418         &inner_val.0
419 }
420 /// The channel ID involved in the error.
421 ///
422 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
423 /// with the sending peer should be closed.
424 #[no_mangle]
425 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
426         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
427 }
428 /// A possibly human-readable error description.
429 ///
430 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
431 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
432 /// the terminal emulator or the logging subsystem.
433 #[no_mangle]
434 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
435         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
436         inner_val.as_str().into()
437 }
438 /// A possibly human-readable error description.
439 ///
440 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
441 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
442 /// the terminal emulator or the logging subsystem.
443 #[no_mangle]
444 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
445         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
446 }
447 /// Constructs a new ErrorMessage given each field
448 #[must_use]
449 #[no_mangle]
450 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
451         ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
452                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
453                 data: data_arg.into_string(),
454         }), is_owned: true }
455 }
456 impl Clone for ErrorMessage {
457         fn clone(&self) -> Self {
458                 Self {
459                         inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
460                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
461                         is_owned: true,
462                 }
463         }
464 }
465 #[allow(unused)]
466 /// Used only if an object of this type is returned as a trait impl by a method
467 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
468         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeErrorMessage)).clone() })) as *mut c_void
469 }
470 #[no_mangle]
471 /// Creates a copy of the ErrorMessage
472 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
473         orig.clone()
474 }
475 /// Get a string which allows debug introspection of a ErrorMessage object
476 pub extern "C" fn ErrorMessage_debug_str_void(o: *const c_void) -> Str {
477         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorMessage }).into()}
478 /// Generates a non-cryptographic 64-bit hash of the ErrorMessage.
479 #[no_mangle]
480 pub extern "C" fn ErrorMessage_hash(o: &ErrorMessage) -> u64 {
481         if o.inner.is_null() { return 0; }
482         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
483         #[allow(deprecated)]
484         let mut hasher = core::hash::SipHasher::new();
485         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
486         core::hash::Hasher::finish(&hasher)
487 }
488 /// Checks if two ErrorMessages contain equal inner contents.
489 /// This ignores pointers and is_owned flags and looks at the values in fields.
490 /// Two objects with NULL inner values will be considered "equal" here.
491 #[no_mangle]
492 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
493         if a.inner == b.inner { return true; }
494         if a.inner.is_null() || b.inner.is_null() { return false; }
495         if a.get_native_ref() == b.get_native_ref() { true } else { false }
496 }
497
498 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
499 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
500
501 /// A [`warning`] message to be sent to or received from a peer.
502 ///
503 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
504 #[must_use]
505 #[repr(C)]
506 pub struct WarningMessage {
507         /// A pointer to the opaque Rust object.
508
509         /// Nearly everywhere, inner must be non-null, however in places where
510         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
511         pub inner: *mut nativeWarningMessage,
512         /// Indicates that this is the only struct which contains the same pointer.
513
514         /// Rust functions which take ownership of an object provided via an argument require
515         /// this to be true and invalidate the object pointed to by inner.
516         pub is_owned: bool,
517 }
518
519 impl Drop for WarningMessage {
520         fn drop(&mut self) {
521                 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
522                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
523                 }
524         }
525 }
526 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
527 #[no_mangle]
528 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
529 #[allow(unused)]
530 /// Used only if an object of this type is returned as a trait impl by a method
531 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
532         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
533 }
534 #[allow(unused)]
535 impl WarningMessage {
536         pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
537                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
538         }
539         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
540                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
541         }
542         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
543         pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
544                 assert!(self.is_owned);
545                 let ret = ObjOps::untweak_ptr(self.inner);
546                 self.inner = core::ptr::null_mut();
547                 ret
548         }
549 }
550 /// The channel ID involved in the warning.
551 ///
552 /// All-0s indicates a warning unrelated to a specific channel.
553 #[no_mangle]
554 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
555         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
556         &inner_val.0
557 }
558 /// The channel ID involved in the warning.
559 ///
560 /// All-0s indicates a warning unrelated to a specific channel.
561 #[no_mangle]
562 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
563         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
564 }
565 /// A possibly human-readable warning description.
566 ///
567 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
568 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
569 /// the terminal emulator or the logging subsystem.
570 #[no_mangle]
571 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
572         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
573         inner_val.as_str().into()
574 }
575 /// A possibly human-readable warning description.
576 ///
577 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
578 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
579 /// the terminal emulator or the logging subsystem.
580 #[no_mangle]
581 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
582         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
583 }
584 /// Constructs a new WarningMessage given each field
585 #[must_use]
586 #[no_mangle]
587 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
588         WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
589                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
590                 data: data_arg.into_string(),
591         }), is_owned: true }
592 }
593 impl Clone for WarningMessage {
594         fn clone(&self) -> Self {
595                 Self {
596                         inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
597                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
598                         is_owned: true,
599                 }
600         }
601 }
602 #[allow(unused)]
603 /// Used only if an object of this type is returned as a trait impl by a method
604 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
605         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeWarningMessage)).clone() })) as *mut c_void
606 }
607 #[no_mangle]
608 /// Creates a copy of the WarningMessage
609 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
610         orig.clone()
611 }
612 /// Get a string which allows debug introspection of a WarningMessage object
613 pub extern "C" fn WarningMessage_debug_str_void(o: *const c_void) -> Str {
614         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::WarningMessage }).into()}
615 /// Generates a non-cryptographic 64-bit hash of the WarningMessage.
616 #[no_mangle]
617 pub extern "C" fn WarningMessage_hash(o: &WarningMessage) -> u64 {
618         if o.inner.is_null() { return 0; }
619         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
620         #[allow(deprecated)]
621         let mut hasher = core::hash::SipHasher::new();
622         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
623         core::hash::Hasher::finish(&hasher)
624 }
625 /// Checks if two WarningMessages contain equal inner contents.
626 /// This ignores pointers and is_owned flags and looks at the values in fields.
627 /// Two objects with NULL inner values will be considered "equal" here.
628 #[no_mangle]
629 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
630         if a.inner == b.inner { return true; }
631         if a.inner.is_null() || b.inner.is_null() { return false; }
632         if a.get_native_ref() == b.get_native_ref() { true } else { false }
633 }
634
635 use lightning::ln::msgs::Ping as nativePingImport;
636 pub(crate) type nativePing = nativePingImport;
637
638 /// A [`ping`] message to be sent to or received from a peer.
639 ///
640 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
641 #[must_use]
642 #[repr(C)]
643 pub struct Ping {
644         /// A pointer to the opaque Rust object.
645
646         /// Nearly everywhere, inner must be non-null, however in places where
647         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
648         pub inner: *mut nativePing,
649         /// Indicates that this is the only struct which contains the same pointer.
650
651         /// Rust functions which take ownership of an object provided via an argument require
652         /// this to be true and invalidate the object pointed to by inner.
653         pub is_owned: bool,
654 }
655
656 impl Drop for Ping {
657         fn drop(&mut self) {
658                 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
659                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
660                 }
661         }
662 }
663 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
664 #[no_mangle]
665 pub extern "C" fn Ping_free(this_obj: Ping) { }
666 #[allow(unused)]
667 /// Used only if an object of this type is returned as a trait impl by a method
668 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
669         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
670 }
671 #[allow(unused)]
672 impl Ping {
673         pub(crate) fn get_native_ref(&self) -> &'static nativePing {
674                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
675         }
676         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
677                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
678         }
679         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
680         pub(crate) fn take_inner(mut self) -> *mut nativePing {
681                 assert!(self.is_owned);
682                 let ret = ObjOps::untweak_ptr(self.inner);
683                 self.inner = core::ptr::null_mut();
684                 ret
685         }
686 }
687 /// The desired response length.
688 #[no_mangle]
689 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
690         let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
691         *inner_val
692 }
693 /// The desired response length.
694 #[no_mangle]
695 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
696         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
697 }
698 /// The ping packet size.
699 ///
700 /// This field is not sent on the wire. byteslen zeros are sent.
701 #[no_mangle]
702 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
703         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
704         *inner_val
705 }
706 /// The ping packet size.
707 ///
708 /// This field is not sent on the wire. byteslen zeros are sent.
709 #[no_mangle]
710 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
711         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
712 }
713 /// Constructs a new Ping given each field
714 #[must_use]
715 #[no_mangle]
716 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
717         Ping { inner: ObjOps::heap_alloc(nativePing {
718                 ponglen: ponglen_arg,
719                 byteslen: byteslen_arg,
720         }), is_owned: true }
721 }
722 impl Clone for Ping {
723         fn clone(&self) -> Self {
724                 Self {
725                         inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
726                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
727                         is_owned: true,
728                 }
729         }
730 }
731 #[allow(unused)]
732 /// Used only if an object of this type is returned as a trait impl by a method
733 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
734         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePing)).clone() })) as *mut c_void
735 }
736 #[no_mangle]
737 /// Creates a copy of the Ping
738 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
739         orig.clone()
740 }
741 /// Get a string which allows debug introspection of a Ping object
742 pub extern "C" fn Ping_debug_str_void(o: *const c_void) -> Str {
743         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Ping }).into()}
744 /// Generates a non-cryptographic 64-bit hash of the Ping.
745 #[no_mangle]
746 pub extern "C" fn Ping_hash(o: &Ping) -> u64 {
747         if o.inner.is_null() { return 0; }
748         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
749         #[allow(deprecated)]
750         let mut hasher = core::hash::SipHasher::new();
751         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
752         core::hash::Hasher::finish(&hasher)
753 }
754 /// Checks if two Pings contain equal inner contents.
755 /// This ignores pointers and is_owned flags and looks at the values in fields.
756 /// Two objects with NULL inner values will be considered "equal" here.
757 #[no_mangle]
758 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
759         if a.inner == b.inner { return true; }
760         if a.inner.is_null() || b.inner.is_null() { return false; }
761         if a.get_native_ref() == b.get_native_ref() { true } else { false }
762 }
763
764 use lightning::ln::msgs::Pong as nativePongImport;
765 pub(crate) type nativePong = nativePongImport;
766
767 /// A [`pong`] message to be sent to or received from a peer.
768 ///
769 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
770 #[must_use]
771 #[repr(C)]
772 pub struct Pong {
773         /// A pointer to the opaque Rust object.
774
775         /// Nearly everywhere, inner must be non-null, however in places where
776         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
777         pub inner: *mut nativePong,
778         /// Indicates that this is the only struct which contains the same pointer.
779
780         /// Rust functions which take ownership of an object provided via an argument require
781         /// this to be true and invalidate the object pointed to by inner.
782         pub is_owned: bool,
783 }
784
785 impl Drop for Pong {
786         fn drop(&mut self) {
787                 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
788                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
789                 }
790         }
791 }
792 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
793 #[no_mangle]
794 pub extern "C" fn Pong_free(this_obj: Pong) { }
795 #[allow(unused)]
796 /// Used only if an object of this type is returned as a trait impl by a method
797 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
798         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
799 }
800 #[allow(unused)]
801 impl Pong {
802         pub(crate) fn get_native_ref(&self) -> &'static nativePong {
803                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
804         }
805         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
806                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
807         }
808         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
809         pub(crate) fn take_inner(mut self) -> *mut nativePong {
810                 assert!(self.is_owned);
811                 let ret = ObjOps::untweak_ptr(self.inner);
812                 self.inner = core::ptr::null_mut();
813                 ret
814         }
815 }
816 /// The pong packet size.
817 ///
818 /// This field is not sent on the wire. byteslen zeros are sent.
819 #[no_mangle]
820 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
821         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
822         *inner_val
823 }
824 /// The pong packet size.
825 ///
826 /// This field is not sent on the wire. byteslen zeros are sent.
827 #[no_mangle]
828 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
829         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
830 }
831 /// Constructs a new Pong given each field
832 #[must_use]
833 #[no_mangle]
834 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
835         Pong { inner: ObjOps::heap_alloc(nativePong {
836                 byteslen: byteslen_arg,
837         }), is_owned: true }
838 }
839 impl Clone for Pong {
840         fn clone(&self) -> Self {
841                 Self {
842                         inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
843                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
844                         is_owned: true,
845                 }
846         }
847 }
848 #[allow(unused)]
849 /// Used only if an object of this type is returned as a trait impl by a method
850 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
851         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePong)).clone() })) as *mut c_void
852 }
853 #[no_mangle]
854 /// Creates a copy of the Pong
855 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
856         orig.clone()
857 }
858 /// Get a string which allows debug introspection of a Pong object
859 pub extern "C" fn Pong_debug_str_void(o: *const c_void) -> Str {
860         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Pong }).into()}
861 /// Generates a non-cryptographic 64-bit hash of the Pong.
862 #[no_mangle]
863 pub extern "C" fn Pong_hash(o: &Pong) -> u64 {
864         if o.inner.is_null() { return 0; }
865         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
866         #[allow(deprecated)]
867         let mut hasher = core::hash::SipHasher::new();
868         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
869         core::hash::Hasher::finish(&hasher)
870 }
871 /// Checks if two Pongs contain equal inner contents.
872 /// This ignores pointers and is_owned flags and looks at the values in fields.
873 /// Two objects with NULL inner values will be considered "equal" here.
874 #[no_mangle]
875 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
876         if a.inner == b.inner { return true; }
877         if a.inner.is_null() || b.inner.is_null() { return false; }
878         if a.get_native_ref() == b.get_native_ref() { true } else { false }
879 }
880
881 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
882 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
883
884 /// An [`open_channel`] message to be sent to or received from a peer.
885 ///
886 /// Used in V1 channel establishment
887 ///
888 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
889 #[must_use]
890 #[repr(C)]
891 pub struct OpenChannel {
892         /// A pointer to the opaque Rust object.
893
894         /// Nearly everywhere, inner must be non-null, however in places where
895         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
896         pub inner: *mut nativeOpenChannel,
897         /// Indicates that this is the only struct which contains the same pointer.
898
899         /// Rust functions which take ownership of an object provided via an argument require
900         /// this to be true and invalidate the object pointed to by inner.
901         pub is_owned: bool,
902 }
903
904 impl Drop for OpenChannel {
905         fn drop(&mut self) {
906                 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
907                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
908                 }
909         }
910 }
911 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
912 #[no_mangle]
913 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
914 #[allow(unused)]
915 /// Used only if an object of this type is returned as a trait impl by a method
916 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
917         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
918 }
919 #[allow(unused)]
920 impl OpenChannel {
921         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
922                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
923         }
924         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
925                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
926         }
927         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
928         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
929                 assert!(self.is_owned);
930                 let ret = ObjOps::untweak_ptr(self.inner);
931                 self.inner = core::ptr::null_mut();
932                 ret
933         }
934 }
935 /// The genesis hash of the blockchain where the channel is to be opened
936 #[no_mangle]
937 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
938         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
939         inner_val.as_ref()
940 }
941 /// The genesis hash of the blockchain where the channel is to be opened
942 #[no_mangle]
943 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
944         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
945 }
946 /// A temporary channel ID, until the funding outpoint is announced
947 #[no_mangle]
948 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
949         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
950         &inner_val.0
951 }
952 /// A temporary channel ID, until the funding outpoint is announced
953 #[no_mangle]
954 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
955         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
956 }
957 /// The channel value
958 #[no_mangle]
959 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
960         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
961         *inner_val
962 }
963 /// The channel value
964 #[no_mangle]
965 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
966         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
967 }
968 /// The amount to push to the counterparty as part of the open, in milli-satoshi
969 #[no_mangle]
970 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
971         let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
972         *inner_val
973 }
974 /// The amount to push to the counterparty as part of the open, in milli-satoshi
975 #[no_mangle]
976 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
977         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
978 }
979 /// The threshold below which outputs on transactions broadcast by sender will be omitted
980 #[no_mangle]
981 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
982         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
983         *inner_val
984 }
985 /// The threshold below which outputs on transactions broadcast by sender will be omitted
986 #[no_mangle]
987 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
988         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
989 }
990 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
991 #[no_mangle]
992 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
993         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
994         *inner_val
995 }
996 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
997 #[no_mangle]
998 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
999         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1000 }
1001 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1002 #[no_mangle]
1003 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
1004         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1005         *inner_val
1006 }
1007 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1008 #[no_mangle]
1009 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
1010         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1011 }
1012 /// The minimum HTLC size incoming to sender, in milli-satoshi
1013 #[no_mangle]
1014 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
1015         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1016         *inner_val
1017 }
1018 /// The minimum HTLC size incoming to sender, in milli-satoshi
1019 #[no_mangle]
1020 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
1021         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1022 }
1023 /// The feerate per 1000-weight of sender generated transactions, until updated by
1024 /// [`UpdateFee`]
1025 #[no_mangle]
1026 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
1027         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
1028         *inner_val
1029 }
1030 /// The feerate per 1000-weight of sender generated transactions, until updated by
1031 /// [`UpdateFee`]
1032 #[no_mangle]
1033 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
1034         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
1035 }
1036 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
1037 /// they broadcast a commitment transaction
1038 #[no_mangle]
1039 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
1040         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1041         *inner_val
1042 }
1043 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
1044 /// they broadcast a commitment transaction
1045 #[no_mangle]
1046 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
1047         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1048 }
1049 /// The maximum number of inbound HTLCs towards sender
1050 #[no_mangle]
1051 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
1052         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1053         *inner_val
1054 }
1055 /// The maximum number of inbound HTLCs towards sender
1056 #[no_mangle]
1057 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
1058         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1059 }
1060 /// The sender's key controlling the funding transaction
1061 #[no_mangle]
1062 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1063         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1064         crate::c_types::PublicKey::from_rust(&inner_val)
1065 }
1066 /// The sender's key controlling the funding transaction
1067 #[no_mangle]
1068 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1069         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1070 }
1071 /// Used to derive a revocation key for transactions broadcast by counterparty
1072 #[no_mangle]
1073 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1074         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1075         crate::c_types::PublicKey::from_rust(&inner_val)
1076 }
1077 /// Used to derive a revocation key for transactions broadcast by counterparty
1078 #[no_mangle]
1079 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1080         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1081 }
1082 /// A payment key to sender for transactions broadcast by counterparty
1083 #[no_mangle]
1084 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1085         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1086         crate::c_types::PublicKey::from_rust(&inner_val)
1087 }
1088 /// A payment key to sender for transactions broadcast by counterparty
1089 #[no_mangle]
1090 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1091         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1092 }
1093 /// Used to derive a payment key to sender for transactions broadcast by sender
1094 #[no_mangle]
1095 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1096         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1097         crate::c_types::PublicKey::from_rust(&inner_val)
1098 }
1099 /// Used to derive a payment key to sender for transactions broadcast by sender
1100 #[no_mangle]
1101 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1102         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1103 }
1104 /// Used to derive an HTLC payment key to sender
1105 #[no_mangle]
1106 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1107         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1108         crate::c_types::PublicKey::from_rust(&inner_val)
1109 }
1110 /// Used to derive an HTLC payment key to sender
1111 #[no_mangle]
1112 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1113         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1114 }
1115 /// The first to-be-broadcast-by-sender transaction's per commitment point
1116 #[no_mangle]
1117 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1118         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1119         crate::c_types::PublicKey::from_rust(&inner_val)
1120 }
1121 /// The first to-be-broadcast-by-sender transaction's per commitment point
1122 #[no_mangle]
1123 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1124         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1125 }
1126 /// The channel flags to be used
1127 #[no_mangle]
1128 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
1129         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1130         *inner_val
1131 }
1132 /// The channel flags to be used
1133 #[no_mangle]
1134 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
1135         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1136 }
1137 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1138 #[no_mangle]
1139 pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1140         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1141         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().to_bytes().into() }) };
1142         local_inner_val
1143 }
1144 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1145 #[no_mangle]
1146 pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1147         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
1148         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1149 }
1150 /// The channel type that this channel will represent
1151 ///
1152 /// If this is `None`, we derive the channel type from the intersection of our
1153 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1154 ///
1155 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1156 #[no_mangle]
1157 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1158         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1159         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 };
1160         local_inner_val
1161 }
1162 /// The channel type that this channel will represent
1163 ///
1164 /// If this is `None`, we derive the channel type from the intersection of our
1165 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1166 ///
1167 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1168 #[no_mangle]
1169 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1170         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1171         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1172 }
1173 /// Constructs a new OpenChannel given each field
1174 ///
1175 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1176 #[must_use]
1177 #[no_mangle]
1178 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 {
1179         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::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1180         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()) } }) };
1181         OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1182                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
1183                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1184                 funding_satoshis: funding_satoshis_arg,
1185                 push_msat: push_msat_arg,
1186                 dust_limit_satoshis: dust_limit_satoshis_arg,
1187                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1188                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1189                 htlc_minimum_msat: htlc_minimum_msat_arg,
1190                 feerate_per_kw: feerate_per_kw_arg,
1191                 to_self_delay: to_self_delay_arg,
1192                 max_accepted_htlcs: max_accepted_htlcs_arg,
1193                 funding_pubkey: funding_pubkey_arg.into_rust(),
1194                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1195                 payment_point: payment_point_arg.into_rust(),
1196                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1197                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1198                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1199                 channel_flags: channel_flags_arg,
1200                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1201                 channel_type: local_channel_type_arg,
1202         }), is_owned: true }
1203 }
1204 impl Clone for OpenChannel {
1205         fn clone(&self) -> Self {
1206                 Self {
1207                         inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1208                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1209                         is_owned: true,
1210                 }
1211         }
1212 }
1213 #[allow(unused)]
1214 /// Used only if an object of this type is returned as a trait impl by a method
1215 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1216         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannel)).clone() })) as *mut c_void
1217 }
1218 #[no_mangle]
1219 /// Creates a copy of the OpenChannel
1220 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1221         orig.clone()
1222 }
1223 /// Get a string which allows debug introspection of a OpenChannel object
1224 pub extern "C" fn OpenChannel_debug_str_void(o: *const c_void) -> Str {
1225         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannel }).into()}
1226 /// Generates a non-cryptographic 64-bit hash of the OpenChannel.
1227 #[no_mangle]
1228 pub extern "C" fn OpenChannel_hash(o: &OpenChannel) -> u64 {
1229         if o.inner.is_null() { return 0; }
1230         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1231         #[allow(deprecated)]
1232         let mut hasher = core::hash::SipHasher::new();
1233         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1234         core::hash::Hasher::finish(&hasher)
1235 }
1236 /// Checks if two OpenChannels contain equal inner contents.
1237 /// This ignores pointers and is_owned flags and looks at the values in fields.
1238 /// Two objects with NULL inner values will be considered "equal" here.
1239 #[no_mangle]
1240 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1241         if a.inner == b.inner { return true; }
1242         if a.inner.is_null() || b.inner.is_null() { return false; }
1243         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1244 }
1245
1246 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1247 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1248
1249 /// An open_channel2 message to be sent by or received from the channel initiator.
1250 ///
1251 /// Used in V2 channel establishment
1252 ///
1253 #[must_use]
1254 #[repr(C)]
1255 pub struct OpenChannelV2 {
1256         /// A pointer to the opaque Rust object.
1257
1258         /// Nearly everywhere, inner must be non-null, however in places where
1259         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1260         pub inner: *mut nativeOpenChannelV2,
1261         /// Indicates that this is the only struct which contains the same pointer.
1262
1263         /// Rust functions which take ownership of an object provided via an argument require
1264         /// this to be true and invalidate the object pointed to by inner.
1265         pub is_owned: bool,
1266 }
1267
1268 impl Drop for OpenChannelV2 {
1269         fn drop(&mut self) {
1270                 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1271                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1272                 }
1273         }
1274 }
1275 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1276 #[no_mangle]
1277 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1278 #[allow(unused)]
1279 /// Used only if an object of this type is returned as a trait impl by a method
1280 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1281         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1282 }
1283 #[allow(unused)]
1284 impl OpenChannelV2 {
1285         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1286                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1287         }
1288         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1289                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1290         }
1291         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1292         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1293                 assert!(self.is_owned);
1294                 let ret = ObjOps::untweak_ptr(self.inner);
1295                 self.inner = core::ptr::null_mut();
1296                 ret
1297         }
1298 }
1299 /// The genesis hash of the blockchain where the channel is to be opened
1300 #[no_mangle]
1301 pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1302         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
1303         inner_val.as_ref()
1304 }
1305 /// The genesis hash of the blockchain where the channel is to be opened
1306 #[no_mangle]
1307 pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1308         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
1309 }
1310 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1311 #[no_mangle]
1312 pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1313         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1314         &inner_val.0
1315 }
1316 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1317 #[no_mangle]
1318 pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1319         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1320 }
1321 /// The feerate for the funding transaction set by the channel initiator
1322 #[no_mangle]
1323 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1324         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1325         *inner_val
1326 }
1327 /// The feerate for the funding transaction set by the channel initiator
1328 #[no_mangle]
1329 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1330         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1331 }
1332 /// The feerate for the commitment transaction set by the channel initiator
1333 #[no_mangle]
1334 pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1335         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1336         *inner_val
1337 }
1338 /// The feerate for the commitment transaction set by the channel initiator
1339 #[no_mangle]
1340 pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1341         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1342 }
1343 /// Part of the channel value contributed by the channel initiator
1344 #[no_mangle]
1345 pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1346         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1347         *inner_val
1348 }
1349 /// Part of the channel value contributed by the channel initiator
1350 #[no_mangle]
1351 pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1352         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1353 }
1354 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1355 /// omitted
1356 #[no_mangle]
1357 pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1358         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1359         *inner_val
1360 }
1361 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1362 /// omitted
1363 #[no_mangle]
1364 pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1365         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1366 }
1367 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1368 #[no_mangle]
1369 pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 {
1370         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1371         *inner_val
1372 }
1373 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1374 #[no_mangle]
1375 pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1376         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1377 }
1378 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1379 #[no_mangle]
1380 pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 {
1381         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1382         *inner_val
1383 }
1384 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1385 #[no_mangle]
1386 pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1387         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1388 }
1389 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1390 /// broadcast a commitment transaction
1391 #[no_mangle]
1392 pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 {
1393         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1394         *inner_val
1395 }
1396 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1397 /// broadcast a commitment transaction
1398 #[no_mangle]
1399 pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) {
1400         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1401 }
1402 /// The maximum number of inbound HTLCs towards channel initiator
1403 #[no_mangle]
1404 pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 {
1405         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1406         *inner_val
1407 }
1408 /// The maximum number of inbound HTLCs towards channel initiator
1409 #[no_mangle]
1410 pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) {
1411         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1412 }
1413 /// The locktime for the funding transaction
1414 #[no_mangle]
1415 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1416         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1417         *inner_val
1418 }
1419 /// The locktime for the funding transaction
1420 #[no_mangle]
1421 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1422         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1423 }
1424 /// The channel initiator's key controlling the funding transaction
1425 #[no_mangle]
1426 pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1427         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1428         crate::c_types::PublicKey::from_rust(&inner_val)
1429 }
1430 /// The channel initiator's key controlling the funding transaction
1431 #[no_mangle]
1432 pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1433         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1434 }
1435 /// Used to derive a revocation key for transactions broadcast by counterparty
1436 #[no_mangle]
1437 pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1438         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1439         crate::c_types::PublicKey::from_rust(&inner_val)
1440 }
1441 /// Used to derive a revocation key for transactions broadcast by counterparty
1442 #[no_mangle]
1443 pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1444         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1445 }
1446 /// A payment key to channel initiator for transactions broadcast by counterparty
1447 #[no_mangle]
1448 pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1449         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1450         crate::c_types::PublicKey::from_rust(&inner_val)
1451 }
1452 /// A payment key to channel initiator for transactions broadcast by counterparty
1453 #[no_mangle]
1454 pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1455         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1456 }
1457 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1458 /// initiator
1459 #[no_mangle]
1460 pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1461         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1462         crate::c_types::PublicKey::from_rust(&inner_val)
1463 }
1464 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1465 /// initiator
1466 #[no_mangle]
1467 pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1468         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1469 }
1470 /// Used to derive an HTLC payment key to channel initiator
1471 #[no_mangle]
1472 pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1473         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1474         crate::c_types::PublicKey::from_rust(&inner_val)
1475 }
1476 /// Used to derive an HTLC payment key to channel initiator
1477 #[no_mangle]
1478 pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1479         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1480 }
1481 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1482 #[no_mangle]
1483 pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1484         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1485         crate::c_types::PublicKey::from_rust(&inner_val)
1486 }
1487 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1488 #[no_mangle]
1489 pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1490         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1491 }
1492 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1493 #[no_mangle]
1494 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1495         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1496         crate::c_types::PublicKey::from_rust(&inner_val)
1497 }
1498 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1499 #[no_mangle]
1500 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1501         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1502 }
1503 /// Channel flags
1504 #[no_mangle]
1505 pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 {
1506         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1507         *inner_val
1508 }
1509 /// Channel flags
1510 #[no_mangle]
1511 pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) {
1512         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1513 }
1514 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1515 /// collaboratively close
1516 #[no_mangle]
1517 pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
1518         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1519         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().to_bytes().into() }) };
1520         local_inner_val
1521 }
1522 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1523 /// collaboratively close
1524 #[no_mangle]
1525 pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1526         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
1527         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1528 }
1529 /// The channel type that this channel will represent. If none is set, we derive the channel
1530 /// type from the intersection of our feature bits with our counterparty's feature bits from
1531 /// the Init message.
1532 ///
1533 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1534 #[no_mangle]
1535 pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
1536         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1537         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 };
1538         local_inner_val
1539 }
1540 /// The channel type that this channel will represent. If none is set, we derive the channel
1541 /// type from the intersection of our feature bits with our counterparty's feature bits from
1542 /// the Init message.
1543 ///
1544 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1545 #[no_mangle]
1546 pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1547         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1548         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1549 }
1550 /// Optionally, a requirement that only confirmed inputs can be added
1551 #[no_mangle]
1552 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1553         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1554         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 /*  { () /**/ } */ };
1555         local_inner_val
1556 }
1557 /// Optionally, a requirement that only confirmed inputs can be added
1558 #[no_mangle]
1559 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1560         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1561         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1562 }
1563 /// Constructs a new OpenChannelV2 given each field
1564 ///
1565 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1566 #[must_use]
1567 #[no_mangle]
1568 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 {
1569         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::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1570         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()) } }) };
1571         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1572         OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1573                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
1574                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1575                 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1576                 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1577                 funding_satoshis: funding_satoshis_arg,
1578                 dust_limit_satoshis: dust_limit_satoshis_arg,
1579                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1580                 htlc_minimum_msat: htlc_minimum_msat_arg,
1581                 to_self_delay: to_self_delay_arg,
1582                 max_accepted_htlcs: max_accepted_htlcs_arg,
1583                 locktime: locktime_arg,
1584                 funding_pubkey: funding_pubkey_arg.into_rust(),
1585                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1586                 payment_basepoint: payment_basepoint_arg.into_rust(),
1587                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1588                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1589                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1590                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1591                 channel_flags: channel_flags_arg,
1592                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1593                 channel_type: local_channel_type_arg,
1594                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1595         }), is_owned: true }
1596 }
1597 impl Clone for OpenChannelV2 {
1598         fn clone(&self) -> Self {
1599                 Self {
1600                         inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1601                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1602                         is_owned: true,
1603                 }
1604         }
1605 }
1606 #[allow(unused)]
1607 /// Used only if an object of this type is returned as a trait impl by a method
1608 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1609         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannelV2)).clone() })) as *mut c_void
1610 }
1611 #[no_mangle]
1612 /// Creates a copy of the OpenChannelV2
1613 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1614         orig.clone()
1615 }
1616 /// Get a string which allows debug introspection of a OpenChannelV2 object
1617 pub extern "C" fn OpenChannelV2_debug_str_void(o: *const c_void) -> Str {
1618         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannelV2 }).into()}
1619 /// Generates a non-cryptographic 64-bit hash of the OpenChannelV2.
1620 #[no_mangle]
1621 pub extern "C" fn OpenChannelV2_hash(o: &OpenChannelV2) -> u64 {
1622         if o.inner.is_null() { return 0; }
1623         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1624         #[allow(deprecated)]
1625         let mut hasher = core::hash::SipHasher::new();
1626         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1627         core::hash::Hasher::finish(&hasher)
1628 }
1629 /// Checks if two OpenChannelV2s contain equal inner contents.
1630 /// This ignores pointers and is_owned flags and looks at the values in fields.
1631 /// Two objects with NULL inner values will be considered "equal" here.
1632 #[no_mangle]
1633 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1634         if a.inner == b.inner { return true; }
1635         if a.inner.is_null() || b.inner.is_null() { return false; }
1636         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1637 }
1638
1639 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1640 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1641
1642 /// An [`accept_channel`] message to be sent to or received from a peer.
1643 ///
1644 /// Used in V1 channel establishment
1645 ///
1646 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1647 #[must_use]
1648 #[repr(C)]
1649 pub struct AcceptChannel {
1650         /// A pointer to the opaque Rust object.
1651
1652         /// Nearly everywhere, inner must be non-null, however in places where
1653         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1654         pub inner: *mut nativeAcceptChannel,
1655         /// Indicates that this is the only struct which contains the same pointer.
1656
1657         /// Rust functions which take ownership of an object provided via an argument require
1658         /// this to be true and invalidate the object pointed to by inner.
1659         pub is_owned: bool,
1660 }
1661
1662 impl Drop for AcceptChannel {
1663         fn drop(&mut self) {
1664                 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1665                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1666                 }
1667         }
1668 }
1669 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1670 #[no_mangle]
1671 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1672 #[allow(unused)]
1673 /// Used only if an object of this type is returned as a trait impl by a method
1674 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1675         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1676 }
1677 #[allow(unused)]
1678 impl AcceptChannel {
1679         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1680                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1681         }
1682         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1683                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1684         }
1685         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1686         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1687                 assert!(self.is_owned);
1688                 let ret = ObjOps::untweak_ptr(self.inner);
1689                 self.inner = core::ptr::null_mut();
1690                 ret
1691         }
1692 }
1693 /// A temporary channel ID, until the funding outpoint is announced
1694 #[no_mangle]
1695 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1696         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1697         &inner_val.0
1698 }
1699 /// A temporary channel ID, until the funding outpoint is announced
1700 #[no_mangle]
1701 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1702         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1703 }
1704 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1705 #[no_mangle]
1706 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1707         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1708         *inner_val
1709 }
1710 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1711 #[no_mangle]
1712 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1713         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1714 }
1715 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1716 #[no_mangle]
1717 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1718         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1719         *inner_val
1720 }
1721 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1722 #[no_mangle]
1723 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1724         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1725 }
1726 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1727 #[no_mangle]
1728 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1729         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1730         *inner_val
1731 }
1732 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1733 #[no_mangle]
1734 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1735         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1736 }
1737 /// The minimum HTLC size incoming to sender, in milli-satoshi
1738 #[no_mangle]
1739 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1740         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1741         *inner_val
1742 }
1743 /// The minimum HTLC size incoming to sender, in milli-satoshi
1744 #[no_mangle]
1745 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1746         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1747 }
1748 /// Minimum depth of the funding transaction before the channel is considered open
1749 #[no_mangle]
1750 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1751         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1752         *inner_val
1753 }
1754 /// Minimum depth of the funding transaction before the channel is considered open
1755 #[no_mangle]
1756 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1757         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1758 }
1759 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1760 #[no_mangle]
1761 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1762         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1763         *inner_val
1764 }
1765 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1766 #[no_mangle]
1767 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1768         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1769 }
1770 /// The maximum number of inbound HTLCs towards sender
1771 #[no_mangle]
1772 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1773         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1774         *inner_val
1775 }
1776 /// The maximum number of inbound HTLCs towards sender
1777 #[no_mangle]
1778 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1779         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1780 }
1781 /// The sender's key controlling the funding transaction
1782 #[no_mangle]
1783 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1784         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1785         crate::c_types::PublicKey::from_rust(&inner_val)
1786 }
1787 /// The sender's key controlling the funding transaction
1788 #[no_mangle]
1789 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1790         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1791 }
1792 /// Used to derive a revocation key for transactions broadcast by counterparty
1793 #[no_mangle]
1794 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1795         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1796         crate::c_types::PublicKey::from_rust(&inner_val)
1797 }
1798 /// Used to derive a revocation key for transactions broadcast by counterparty
1799 #[no_mangle]
1800 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1801         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1802 }
1803 /// A payment key to sender for transactions broadcast by counterparty
1804 #[no_mangle]
1805 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1806         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1807         crate::c_types::PublicKey::from_rust(&inner_val)
1808 }
1809 /// A payment key to sender for transactions broadcast by counterparty
1810 #[no_mangle]
1811 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1812         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1813 }
1814 /// Used to derive a payment key to sender for transactions broadcast by sender
1815 #[no_mangle]
1816 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1817         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1818         crate::c_types::PublicKey::from_rust(&inner_val)
1819 }
1820 /// Used to derive a payment key to sender for transactions broadcast by sender
1821 #[no_mangle]
1822 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1823         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1824 }
1825 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1826 #[no_mangle]
1827 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1828         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1829         crate::c_types::PublicKey::from_rust(&inner_val)
1830 }
1831 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1832 #[no_mangle]
1833 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1834         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1835 }
1836 /// The first to-be-broadcast-by-sender transaction's per commitment point
1837 #[no_mangle]
1838 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1839         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1840         crate::c_types::PublicKey::from_rust(&inner_val)
1841 }
1842 /// The first to-be-broadcast-by-sender transaction's per commitment point
1843 #[no_mangle]
1844 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1845         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1846 }
1847 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1848 #[no_mangle]
1849 pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1850         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1851         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().to_bytes().into() }) };
1852         local_inner_val
1853 }
1854 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1855 #[no_mangle]
1856 pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1857         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
1858         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1859 }
1860 /// The channel type that this channel will represent.
1861 ///
1862 /// If this is `None`, we derive the channel type from the intersection of
1863 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1864 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1865 ///
1866 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1867 #[no_mangle]
1868 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1869         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1870         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 };
1871         local_inner_val
1872 }
1873 /// The channel type that this channel will represent.
1874 ///
1875 /// If this is `None`, we derive the channel type from the intersection of
1876 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1877 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1878 ///
1879 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1880 #[no_mangle]
1881 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1882         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1883         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1884 }
1885 /// Constructs a new AcceptChannel given each field
1886 ///
1887 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1888 #[must_use]
1889 #[no_mangle]
1890 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 {
1891         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::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1892         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()) } }) };
1893         AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1894                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1895                 dust_limit_satoshis: dust_limit_satoshis_arg,
1896                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1897                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1898                 htlc_minimum_msat: htlc_minimum_msat_arg,
1899                 minimum_depth: minimum_depth_arg,
1900                 to_self_delay: to_self_delay_arg,
1901                 max_accepted_htlcs: max_accepted_htlcs_arg,
1902                 funding_pubkey: funding_pubkey_arg.into_rust(),
1903                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1904                 payment_point: payment_point_arg.into_rust(),
1905                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1906                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1907                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1908                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1909                 channel_type: local_channel_type_arg,
1910         }), is_owned: true }
1911 }
1912 impl Clone for AcceptChannel {
1913         fn clone(&self) -> Self {
1914                 Self {
1915                         inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1916                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1917                         is_owned: true,
1918                 }
1919         }
1920 }
1921 #[allow(unused)]
1922 /// Used only if an object of this type is returned as a trait impl by a method
1923 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1924         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannel)).clone() })) as *mut c_void
1925 }
1926 #[no_mangle]
1927 /// Creates a copy of the AcceptChannel
1928 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1929         orig.clone()
1930 }
1931 /// Get a string which allows debug introspection of a AcceptChannel object
1932 pub extern "C" fn AcceptChannel_debug_str_void(o: *const c_void) -> Str {
1933         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AcceptChannel }).into()}
1934 /// Generates a non-cryptographic 64-bit hash of the AcceptChannel.
1935 #[no_mangle]
1936 pub extern "C" fn AcceptChannel_hash(o: &AcceptChannel) -> u64 {
1937         if o.inner.is_null() { return 0; }
1938         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1939         #[allow(deprecated)]
1940         let mut hasher = core::hash::SipHasher::new();
1941         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1942         core::hash::Hasher::finish(&hasher)
1943 }
1944 /// Checks if two AcceptChannels contain equal inner contents.
1945 /// This ignores pointers and is_owned flags and looks at the values in fields.
1946 /// Two objects with NULL inner values will be considered "equal" here.
1947 #[no_mangle]
1948 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1949         if a.inner == b.inner { return true; }
1950         if a.inner.is_null() || b.inner.is_null() { return false; }
1951         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1952 }
1953
1954 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1955 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1956
1957 /// An accept_channel2 message to be sent by or received from the channel accepter.
1958 ///
1959 /// Used in V2 channel establishment
1960 ///
1961 #[must_use]
1962 #[repr(C)]
1963 pub struct AcceptChannelV2 {
1964         /// A pointer to the opaque Rust object.
1965
1966         /// Nearly everywhere, inner must be non-null, however in places where
1967         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1968         pub inner: *mut nativeAcceptChannelV2,
1969         /// Indicates that this is the only struct which contains the same pointer.
1970
1971         /// Rust functions which take ownership of an object provided via an argument require
1972         /// this to be true and invalidate the object pointed to by inner.
1973         pub is_owned: bool,
1974 }
1975
1976 impl Drop for AcceptChannelV2 {
1977         fn drop(&mut self) {
1978                 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
1979                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1980                 }
1981         }
1982 }
1983 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
1984 #[no_mangle]
1985 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
1986 #[allow(unused)]
1987 /// Used only if an object of this type is returned as a trait impl by a method
1988 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
1989         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
1990 }
1991 #[allow(unused)]
1992 impl AcceptChannelV2 {
1993         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
1994                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1995         }
1996         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
1997                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1998         }
1999         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2000         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
2001                 assert!(self.is_owned);
2002                 let ret = ObjOps::untweak_ptr(self.inner);
2003                 self.inner = core::ptr::null_mut();
2004                 ret
2005         }
2006 }
2007 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
2008 #[no_mangle]
2009 pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] {
2010         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2011         &inner_val.0
2012 }
2013 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
2014 #[no_mangle]
2015 pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
2016         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
2017 }
2018 /// Part of the channel value contributed by the channel acceptor
2019 #[no_mangle]
2020 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
2021         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
2022         *inner_val
2023 }
2024 /// Part of the channel value contributed by the channel acceptor
2025 #[no_mangle]
2026 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2027         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
2028 }
2029 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
2030 /// omitted
2031 #[no_mangle]
2032 pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
2033         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
2034         *inner_val
2035 }
2036 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
2037 /// omitted
2038 #[no_mangle]
2039 pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2040         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
2041 }
2042 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
2043 #[no_mangle]
2044 pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 {
2045         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
2046         *inner_val
2047 }
2048 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
2049 #[no_mangle]
2050 pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2051         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
2052 }
2053 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
2054 #[no_mangle]
2055 pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 {
2056         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
2057         *inner_val
2058 }
2059 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
2060 #[no_mangle]
2061 pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2062         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
2063 }
2064 /// Minimum depth of the funding transaction before the channel is considered open
2065 #[no_mangle]
2066 pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 {
2067         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
2068         *inner_val
2069 }
2070 /// Minimum depth of the funding transaction before the channel is considered open
2071 #[no_mangle]
2072 pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) {
2073         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
2074 }
2075 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
2076 /// broadcast a commitment transaction
2077 #[no_mangle]
2078 pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 {
2079         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
2080         *inner_val
2081 }
2082 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
2083 /// broadcast a commitment transaction
2084 #[no_mangle]
2085 pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) {
2086         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
2087 }
2088 /// The maximum number of inbound HTLCs towards channel acceptor
2089 #[no_mangle]
2090 pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 {
2091         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
2092         *inner_val
2093 }
2094 /// The maximum number of inbound HTLCs towards channel acceptor
2095 #[no_mangle]
2096 pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) {
2097         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
2098 }
2099 /// The channel acceptor's key controlling the funding transaction
2100 #[no_mangle]
2101 pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2102         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
2103         crate::c_types::PublicKey::from_rust(&inner_val)
2104 }
2105 /// The channel acceptor's key controlling the funding transaction
2106 #[no_mangle]
2107 pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2108         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
2109 }
2110 /// Used to derive a revocation key for transactions broadcast by counterparty
2111 #[no_mangle]
2112 pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2113         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
2114         crate::c_types::PublicKey::from_rust(&inner_val)
2115 }
2116 /// Used to derive a revocation key for transactions broadcast by counterparty
2117 #[no_mangle]
2118 pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2119         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
2120 }
2121 /// A payment key to channel acceptor for transactions broadcast by counterparty
2122 #[no_mangle]
2123 pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2124         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
2125         crate::c_types::PublicKey::from_rust(&inner_val)
2126 }
2127 /// A payment key to channel acceptor for transactions broadcast by counterparty
2128 #[no_mangle]
2129 pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2130         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
2131 }
2132 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2133 /// acceptor
2134 #[no_mangle]
2135 pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2136         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
2137         crate::c_types::PublicKey::from_rust(&inner_val)
2138 }
2139 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2140 /// acceptor
2141 #[no_mangle]
2142 pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2143         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
2144 }
2145 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2146 #[no_mangle]
2147 pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2148         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
2149         crate::c_types::PublicKey::from_rust(&inner_val)
2150 }
2151 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2152 #[no_mangle]
2153 pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2154         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
2155 }
2156 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2157 #[no_mangle]
2158 pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2159         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
2160         crate::c_types::PublicKey::from_rust(&inner_val)
2161 }
2162 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2163 #[no_mangle]
2164 pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2165         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
2166 }
2167 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2168 #[no_mangle]
2169 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2170         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2171         crate::c_types::PublicKey::from_rust(&inner_val)
2172 }
2173 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2174 #[no_mangle]
2175 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2176         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2177 }
2178 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2179 /// collaboratively close
2180 #[no_mangle]
2181 pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
2182         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
2183         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().to_bytes().into() }) };
2184         local_inner_val
2185 }
2186 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2187 /// collaboratively close
2188 #[no_mangle]
2189 pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
2190         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
2191         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
2192 }
2193 /// The channel type that this channel will represent. If none is set, we derive the channel
2194 /// type from the intersection of our feature bits with our counterparty's feature bits from
2195 /// the Init message.
2196 ///
2197 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2198 ///
2199 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2200 #[no_mangle]
2201 pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
2202         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
2203         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 };
2204         local_inner_val
2205 }
2206 /// The channel type that this channel will represent. If none is set, we derive the channel
2207 /// type from the intersection of our feature bits with our counterparty's feature bits from
2208 /// the Init message.
2209 ///
2210 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2211 ///
2212 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
2213 #[no_mangle]
2214 pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
2215         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2216         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
2217 }
2218 /// Optionally, a requirement that only confirmed inputs can be added
2219 #[no_mangle]
2220 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2221         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2222         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 /*  { () /**/ } */ };
2223         local_inner_val
2224 }
2225 /// Optionally, a requirement that only confirmed inputs can be added
2226 #[no_mangle]
2227 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2228         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2229         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2230 }
2231 /// Constructs a new AcceptChannelV2 given each field
2232 ///
2233 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
2234 #[must_use]
2235 #[no_mangle]
2236 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 {
2237         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::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
2238         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()) } }) };
2239         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2240         AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2241                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2242                 funding_satoshis: funding_satoshis_arg,
2243                 dust_limit_satoshis: dust_limit_satoshis_arg,
2244                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
2245                 htlc_minimum_msat: htlc_minimum_msat_arg,
2246                 minimum_depth: minimum_depth_arg,
2247                 to_self_delay: to_self_delay_arg,
2248                 max_accepted_htlcs: max_accepted_htlcs_arg,
2249                 funding_pubkey: funding_pubkey_arg.into_rust(),
2250                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
2251                 payment_basepoint: payment_basepoint_arg.into_rust(),
2252                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
2253                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
2254                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
2255                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2256                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
2257                 channel_type: local_channel_type_arg,
2258                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2259         }), is_owned: true }
2260 }
2261 impl Clone for AcceptChannelV2 {
2262         fn clone(&self) -> Self {
2263                 Self {
2264                         inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2265                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2266                         is_owned: true,
2267                 }
2268         }
2269 }
2270 #[allow(unused)]
2271 /// Used only if an object of this type is returned as a trait impl by a method
2272 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2273         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannelV2)).clone() })) as *mut c_void
2274 }
2275 #[no_mangle]
2276 /// Creates a copy of the AcceptChannelV2
2277 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2278         orig.clone()
2279 }
2280 /// Get a string which allows debug introspection of a AcceptChannelV2 object
2281 pub extern "C" fn AcceptChannelV2_debug_str_void(o: *const c_void) -> Str {
2282         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AcceptChannelV2 }).into()}
2283 /// Generates a non-cryptographic 64-bit hash of the AcceptChannelV2.
2284 #[no_mangle]
2285 pub extern "C" fn AcceptChannelV2_hash(o: &AcceptChannelV2) -> u64 {
2286         if o.inner.is_null() { return 0; }
2287         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2288         #[allow(deprecated)]
2289         let mut hasher = core::hash::SipHasher::new();
2290         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2291         core::hash::Hasher::finish(&hasher)
2292 }
2293 /// Checks if two AcceptChannelV2s contain equal inner contents.
2294 /// This ignores pointers and is_owned flags and looks at the values in fields.
2295 /// Two objects with NULL inner values will be considered "equal" here.
2296 #[no_mangle]
2297 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2298         if a.inner == b.inner { return true; }
2299         if a.inner.is_null() || b.inner.is_null() { return false; }
2300         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2301 }
2302
2303 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2304 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2305
2306 /// A [`funding_created`] message to be sent to or received from a peer.
2307 ///
2308 /// Used in V1 channel establishment
2309 ///
2310 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2311 #[must_use]
2312 #[repr(C)]
2313 pub struct FundingCreated {
2314         /// A pointer to the opaque Rust object.
2315
2316         /// Nearly everywhere, inner must be non-null, however in places where
2317         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2318         pub inner: *mut nativeFundingCreated,
2319         /// Indicates that this is the only struct which contains the same pointer.
2320
2321         /// Rust functions which take ownership of an object provided via an argument require
2322         /// this to be true and invalidate the object pointed to by inner.
2323         pub is_owned: bool,
2324 }
2325
2326 impl Drop for FundingCreated {
2327         fn drop(&mut self) {
2328                 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2329                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2330                 }
2331         }
2332 }
2333 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2334 #[no_mangle]
2335 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2336 #[allow(unused)]
2337 /// Used only if an object of this type is returned as a trait impl by a method
2338 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2339         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2340 }
2341 #[allow(unused)]
2342 impl FundingCreated {
2343         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2344                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2345         }
2346         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2347                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2348         }
2349         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2350         pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2351                 assert!(self.is_owned);
2352                 let ret = ObjOps::untweak_ptr(self.inner);
2353                 self.inner = core::ptr::null_mut();
2354                 ret
2355         }
2356 }
2357 /// A temporary channel ID, until the funding is established
2358 #[no_mangle]
2359 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
2360         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2361         &inner_val.0
2362 }
2363 /// A temporary channel ID, until the funding is established
2364 #[no_mangle]
2365 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2366         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
2367 }
2368 /// The funding transaction ID
2369 #[no_mangle]
2370 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2371         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2372         inner_val.as_ref()
2373 }
2374 /// The funding transaction ID
2375 #[no_mangle]
2376 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2377         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2378 }
2379 /// The specific output index funding this channel
2380 #[no_mangle]
2381 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2382         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2383         *inner_val
2384 }
2385 /// The specific output index funding this channel
2386 #[no_mangle]
2387 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2388         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2389 }
2390 /// The signature of the channel initiator (funder) on the initial commitment transaction
2391 #[no_mangle]
2392 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::ECDSASignature {
2393         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2394         crate::c_types::ECDSASignature::from_rust(&inner_val)
2395 }
2396 /// The signature of the channel initiator (funder) on the initial commitment transaction
2397 #[no_mangle]
2398 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::ECDSASignature) {
2399         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2400 }
2401 /// Constructs a new FundingCreated given each field
2402 #[must_use]
2403 #[no_mangle]
2404 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 {
2405         FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2406                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2407                 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2408                 funding_output_index: funding_output_index_arg,
2409                 signature: signature_arg.into_rust(),
2410         }), is_owned: true }
2411 }
2412 impl Clone for FundingCreated {
2413         fn clone(&self) -> Self {
2414                 Self {
2415                         inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2416                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2417                         is_owned: true,
2418                 }
2419         }
2420 }
2421 #[allow(unused)]
2422 /// Used only if an object of this type is returned as a trait impl by a method
2423 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2424         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingCreated)).clone() })) as *mut c_void
2425 }
2426 #[no_mangle]
2427 /// Creates a copy of the FundingCreated
2428 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2429         orig.clone()
2430 }
2431 /// Get a string which allows debug introspection of a FundingCreated object
2432 pub extern "C" fn FundingCreated_debug_str_void(o: *const c_void) -> Str {
2433         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::FundingCreated }).into()}
2434 /// Generates a non-cryptographic 64-bit hash of the FundingCreated.
2435 #[no_mangle]
2436 pub extern "C" fn FundingCreated_hash(o: &FundingCreated) -> u64 {
2437         if o.inner.is_null() { return 0; }
2438         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2439         #[allow(deprecated)]
2440         let mut hasher = core::hash::SipHasher::new();
2441         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2442         core::hash::Hasher::finish(&hasher)
2443 }
2444 /// Checks if two FundingCreateds contain equal inner contents.
2445 /// This ignores pointers and is_owned flags and looks at the values in fields.
2446 /// Two objects with NULL inner values will be considered "equal" here.
2447 #[no_mangle]
2448 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2449         if a.inner == b.inner { return true; }
2450         if a.inner.is_null() || b.inner.is_null() { return false; }
2451         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2452 }
2453
2454 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2455 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2456
2457 /// A [`funding_signed`] message to be sent to or received from a peer.
2458 ///
2459 /// Used in V1 channel establishment
2460 ///
2461 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2462 #[must_use]
2463 #[repr(C)]
2464 pub struct FundingSigned {
2465         /// A pointer to the opaque Rust object.
2466
2467         /// Nearly everywhere, inner must be non-null, however in places where
2468         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2469         pub inner: *mut nativeFundingSigned,
2470         /// Indicates that this is the only struct which contains the same pointer.
2471
2472         /// Rust functions which take ownership of an object provided via an argument require
2473         /// this to be true and invalidate the object pointed to by inner.
2474         pub is_owned: bool,
2475 }
2476
2477 impl Drop for FundingSigned {
2478         fn drop(&mut self) {
2479                 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2480                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2481                 }
2482         }
2483 }
2484 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2485 #[no_mangle]
2486 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2487 #[allow(unused)]
2488 /// Used only if an object of this type is returned as a trait impl by a method
2489 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2490         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2491 }
2492 #[allow(unused)]
2493 impl FundingSigned {
2494         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2495                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2496         }
2497         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2498                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2499         }
2500         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2501         pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2502                 assert!(self.is_owned);
2503                 let ret = ObjOps::untweak_ptr(self.inner);
2504                 self.inner = core::ptr::null_mut();
2505                 ret
2506         }
2507 }
2508 /// The channel ID
2509 #[no_mangle]
2510 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
2511         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2512         &inner_val.0
2513 }
2514 /// The channel ID
2515 #[no_mangle]
2516 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2517         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2518 }
2519 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2520 #[no_mangle]
2521 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::ECDSASignature {
2522         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2523         crate::c_types::ECDSASignature::from_rust(&inner_val)
2524 }
2525 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2526 #[no_mangle]
2527 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::ECDSASignature) {
2528         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2529 }
2530 /// Constructs a new FundingSigned given each field
2531 #[must_use]
2532 #[no_mangle]
2533 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned {
2534         FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2535                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2536                 signature: signature_arg.into_rust(),
2537         }), is_owned: true }
2538 }
2539 impl Clone for FundingSigned {
2540         fn clone(&self) -> Self {
2541                 Self {
2542                         inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2543                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2544                         is_owned: true,
2545                 }
2546         }
2547 }
2548 #[allow(unused)]
2549 /// Used only if an object of this type is returned as a trait impl by a method
2550 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2551         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingSigned)).clone() })) as *mut c_void
2552 }
2553 #[no_mangle]
2554 /// Creates a copy of the FundingSigned
2555 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2556         orig.clone()
2557 }
2558 /// Get a string which allows debug introspection of a FundingSigned object
2559 pub extern "C" fn FundingSigned_debug_str_void(o: *const c_void) -> Str {
2560         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::FundingSigned }).into()}
2561 /// Generates a non-cryptographic 64-bit hash of the FundingSigned.
2562 #[no_mangle]
2563 pub extern "C" fn FundingSigned_hash(o: &FundingSigned) -> u64 {
2564         if o.inner.is_null() { return 0; }
2565         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2566         #[allow(deprecated)]
2567         let mut hasher = core::hash::SipHasher::new();
2568         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2569         core::hash::Hasher::finish(&hasher)
2570 }
2571 /// Checks if two FundingSigneds contain equal inner contents.
2572 /// This ignores pointers and is_owned flags and looks at the values in fields.
2573 /// Two objects with NULL inner values will be considered "equal" here.
2574 #[no_mangle]
2575 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2576         if a.inner == b.inner { return true; }
2577         if a.inner.is_null() || b.inner.is_null() { return false; }
2578         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2579 }
2580
2581 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2582 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2583
2584 /// A [`channel_ready`] message to be sent to or received from a peer.
2585 ///
2586 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2587 #[must_use]
2588 #[repr(C)]
2589 pub struct ChannelReady {
2590         /// A pointer to the opaque Rust object.
2591
2592         /// Nearly everywhere, inner must be non-null, however in places where
2593         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2594         pub inner: *mut nativeChannelReady,
2595         /// Indicates that this is the only struct which contains the same pointer.
2596
2597         /// Rust functions which take ownership of an object provided via an argument require
2598         /// this to be true and invalidate the object pointed to by inner.
2599         pub is_owned: bool,
2600 }
2601
2602 impl Drop for ChannelReady {
2603         fn drop(&mut self) {
2604                 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2605                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2606                 }
2607         }
2608 }
2609 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2610 #[no_mangle]
2611 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2612 #[allow(unused)]
2613 /// Used only if an object of this type is returned as a trait impl by a method
2614 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2615         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2616 }
2617 #[allow(unused)]
2618 impl ChannelReady {
2619         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2620                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2621         }
2622         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2623                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2624         }
2625         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2626         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2627                 assert!(self.is_owned);
2628                 let ret = ObjOps::untweak_ptr(self.inner);
2629                 self.inner = core::ptr::null_mut();
2630                 ret
2631         }
2632 }
2633 /// The channel ID
2634 #[no_mangle]
2635 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
2636         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2637         &inner_val.0
2638 }
2639 /// The channel ID
2640 #[no_mangle]
2641 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
2642         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2643 }
2644 /// The per-commitment point of the second commitment transaction
2645 #[no_mangle]
2646 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2647         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2648         crate::c_types::PublicKey::from_rust(&inner_val)
2649 }
2650 /// The per-commitment point of the second commitment transaction
2651 #[no_mangle]
2652 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2653         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2654 }
2655 /// If set, provides a `short_channel_id` alias for this channel.
2656 ///
2657 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2658 /// messages' recipient.
2659 #[no_mangle]
2660 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2661         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2662         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() }) };
2663         local_inner_val
2664 }
2665 /// If set, provides a `short_channel_id` alias for this channel.
2666 ///
2667 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2668 /// messages' recipient.
2669 #[no_mangle]
2670 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2671         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2672         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2673 }
2674 /// Constructs a new ChannelReady given each field
2675 #[must_use]
2676 #[no_mangle]
2677 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 {
2678         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 };
2679         ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2680                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2681                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2682                 short_channel_id_alias: local_short_channel_id_alias_arg,
2683         }), is_owned: true }
2684 }
2685 impl Clone for ChannelReady {
2686         fn clone(&self) -> Self {
2687                 Self {
2688                         inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2689                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2690                         is_owned: true,
2691                 }
2692         }
2693 }
2694 #[allow(unused)]
2695 /// Used only if an object of this type is returned as a trait impl by a method
2696 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2697         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReady)).clone() })) as *mut c_void
2698 }
2699 #[no_mangle]
2700 /// Creates a copy of the ChannelReady
2701 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2702         orig.clone()
2703 }
2704 /// Get a string which allows debug introspection of a ChannelReady object
2705 pub extern "C" fn ChannelReady_debug_str_void(o: *const c_void) -> Str {
2706         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelReady }).into()}
2707 /// Generates a non-cryptographic 64-bit hash of the ChannelReady.
2708 #[no_mangle]
2709 pub extern "C" fn ChannelReady_hash(o: &ChannelReady) -> u64 {
2710         if o.inner.is_null() { return 0; }
2711         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2712         #[allow(deprecated)]
2713         let mut hasher = core::hash::SipHasher::new();
2714         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2715         core::hash::Hasher::finish(&hasher)
2716 }
2717 /// Checks if two ChannelReadys contain equal inner contents.
2718 /// This ignores pointers and is_owned flags and looks at the values in fields.
2719 /// Two objects with NULL inner values will be considered "equal" here.
2720 #[no_mangle]
2721 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2722         if a.inner == b.inner { return true; }
2723         if a.inner.is_null() || b.inner.is_null() { return false; }
2724         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2725 }
2726
2727 use lightning::ln::msgs::Stfu as nativeStfuImport;
2728 pub(crate) type nativeStfu = nativeStfuImport;
2729
2730 /// An stfu (quiescence) message to be sent by or received from the stfu initiator.
2731 #[must_use]
2732 #[repr(C)]
2733 pub struct Stfu {
2734         /// A pointer to the opaque Rust object.
2735
2736         /// Nearly everywhere, inner must be non-null, however in places where
2737         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2738         pub inner: *mut nativeStfu,
2739         /// Indicates that this is the only struct which contains the same pointer.
2740
2741         /// Rust functions which take ownership of an object provided via an argument require
2742         /// this to be true and invalidate the object pointed to by inner.
2743         pub is_owned: bool,
2744 }
2745
2746 impl Drop for Stfu {
2747         fn drop(&mut self) {
2748                 if self.is_owned && !<*mut nativeStfu>::is_null(self.inner) {
2749                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2750                 }
2751         }
2752 }
2753 /// Frees any resources used by the Stfu, if is_owned is set and inner is non-NULL.
2754 #[no_mangle]
2755 pub extern "C" fn Stfu_free(this_obj: Stfu) { }
2756 #[allow(unused)]
2757 /// Used only if an object of this type is returned as a trait impl by a method
2758 pub(crate) extern "C" fn Stfu_free_void(this_ptr: *mut c_void) {
2759         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeStfu) };
2760 }
2761 #[allow(unused)]
2762 impl Stfu {
2763         pub(crate) fn get_native_ref(&self) -> &'static nativeStfu {
2764                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2765         }
2766         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeStfu {
2767                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2768         }
2769         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2770         pub(crate) fn take_inner(mut self) -> *mut nativeStfu {
2771                 assert!(self.is_owned);
2772                 let ret = ObjOps::untweak_ptr(self.inner);
2773                 self.inner = core::ptr::null_mut();
2774                 ret
2775         }
2776 }
2777 /// The channel ID where quiescence is intended
2778 #[no_mangle]
2779 pub extern "C" fn Stfu_get_channel_id(this_ptr: &Stfu) -> *const [u8; 32] {
2780         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2781         &inner_val.0
2782 }
2783 /// The channel ID where quiescence is intended
2784 #[no_mangle]
2785 pub extern "C" fn Stfu_set_channel_id(this_ptr: &mut Stfu, mut val: crate::c_types::ThirtyTwoBytes) {
2786         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2787 }
2788 /// Initiator flag, 1 if initiating, 0 if replying to an stfu.
2789 #[no_mangle]
2790 pub extern "C" fn Stfu_get_initiator(this_ptr: &Stfu) -> u8 {
2791         let mut inner_val = &mut this_ptr.get_native_mut_ref().initiator;
2792         *inner_val
2793 }
2794 /// Initiator flag, 1 if initiating, 0 if replying to an stfu.
2795 #[no_mangle]
2796 pub extern "C" fn Stfu_set_initiator(this_ptr: &mut Stfu, mut val: u8) {
2797         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.initiator = val;
2798 }
2799 /// Constructs a new Stfu given each field
2800 #[must_use]
2801 #[no_mangle]
2802 pub extern "C" fn Stfu_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut initiator_arg: u8) -> Stfu {
2803         Stfu { inner: ObjOps::heap_alloc(nativeStfu {
2804                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2805                 initiator: initiator_arg,
2806         }), is_owned: true }
2807 }
2808 impl Clone for Stfu {
2809         fn clone(&self) -> Self {
2810                 Self {
2811                         inner: if <*mut nativeStfu>::is_null(self.inner) { core::ptr::null_mut() } else {
2812                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2813                         is_owned: true,
2814                 }
2815         }
2816 }
2817 #[allow(unused)]
2818 /// Used only if an object of this type is returned as a trait impl by a method
2819 pub(crate) extern "C" fn Stfu_clone_void(this_ptr: *const c_void) -> *mut c_void {
2820         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeStfu)).clone() })) as *mut c_void
2821 }
2822 #[no_mangle]
2823 /// Creates a copy of the Stfu
2824 pub extern "C" fn Stfu_clone(orig: &Stfu) -> Stfu {
2825         orig.clone()
2826 }
2827 /// Get a string which allows debug introspection of a Stfu object
2828 pub extern "C" fn Stfu_debug_str_void(o: *const c_void) -> Str {
2829         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Stfu }).into()}
2830 /// Checks if two Stfus contain equal inner contents.
2831 /// This ignores pointers and is_owned flags and looks at the values in fields.
2832 /// Two objects with NULL inner values will be considered "equal" here.
2833 #[no_mangle]
2834 pub extern "C" fn Stfu_eq(a: &Stfu, b: &Stfu) -> bool {
2835         if a.inner == b.inner { return true; }
2836         if a.inner.is_null() || b.inner.is_null() { return false; }
2837         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2838 }
2839
2840 use lightning::ln::msgs::Splice as nativeSpliceImport;
2841 pub(crate) type nativeSplice = nativeSpliceImport;
2842
2843 /// A splice message to be sent by or received from the stfu initiator (splice initiator).
2844 #[must_use]
2845 #[repr(C)]
2846 pub struct Splice {
2847         /// A pointer to the opaque Rust object.
2848
2849         /// Nearly everywhere, inner must be non-null, however in places where
2850         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2851         pub inner: *mut nativeSplice,
2852         /// Indicates that this is the only struct which contains the same pointer.
2853
2854         /// Rust functions which take ownership of an object provided via an argument require
2855         /// this to be true and invalidate the object pointed to by inner.
2856         pub is_owned: bool,
2857 }
2858
2859 impl Drop for Splice {
2860         fn drop(&mut self) {
2861                 if self.is_owned && !<*mut nativeSplice>::is_null(self.inner) {
2862                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2863                 }
2864         }
2865 }
2866 /// Frees any resources used by the Splice, if is_owned is set and inner is non-NULL.
2867 #[no_mangle]
2868 pub extern "C" fn Splice_free(this_obj: Splice) { }
2869 #[allow(unused)]
2870 /// Used only if an object of this type is returned as a trait impl by a method
2871 pub(crate) extern "C" fn Splice_free_void(this_ptr: *mut c_void) {
2872         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSplice) };
2873 }
2874 #[allow(unused)]
2875 impl Splice {
2876         pub(crate) fn get_native_ref(&self) -> &'static nativeSplice {
2877                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2878         }
2879         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSplice {
2880                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2881         }
2882         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2883         pub(crate) fn take_inner(mut self) -> *mut nativeSplice {
2884                 assert!(self.is_owned);
2885                 let ret = ObjOps::untweak_ptr(self.inner);
2886                 self.inner = core::ptr::null_mut();
2887                 ret
2888         }
2889 }
2890 /// The channel ID where splicing is intended
2891 #[no_mangle]
2892 pub extern "C" fn Splice_get_channel_id(this_ptr: &Splice) -> *const [u8; 32] {
2893         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2894         &inner_val.0
2895 }
2896 /// The channel ID where splicing is intended
2897 #[no_mangle]
2898 pub extern "C" fn Splice_set_channel_id(this_ptr: &mut Splice, mut val: crate::c_types::ThirtyTwoBytes) {
2899         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2900 }
2901 /// The genesis hash of the blockchain where the channel is intended to be spliced
2902 #[no_mangle]
2903 pub extern "C" fn Splice_get_chain_hash(this_ptr: &Splice) -> *const [u8; 32] {
2904         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
2905         inner_val.as_ref()
2906 }
2907 /// The genesis hash of the blockchain where the channel is intended to be spliced
2908 #[no_mangle]
2909 pub extern "C" fn Splice_set_chain_hash(this_ptr: &mut Splice, mut val: crate::c_types::ThirtyTwoBytes) {
2910         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
2911 }
2912 /// The intended change in channel capacity: the amount to be added (positive value)
2913 /// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
2914 #[no_mangle]
2915 pub extern "C" fn Splice_get_relative_satoshis(this_ptr: &Splice) -> i64 {
2916         let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis;
2917         *inner_val
2918 }
2919 /// The intended change in channel capacity: the amount to be added (positive value)
2920 /// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
2921 #[no_mangle]
2922 pub extern "C" fn Splice_set_relative_satoshis(this_ptr: &mut Splice, mut val: i64) {
2923         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val;
2924 }
2925 /// The feerate for the new funding transaction, set by the splice initiator
2926 #[no_mangle]
2927 pub extern "C" fn Splice_get_funding_feerate_perkw(this_ptr: &Splice) -> u32 {
2928         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_perkw;
2929         *inner_val
2930 }
2931 /// The feerate for the new funding transaction, set by the splice initiator
2932 #[no_mangle]
2933 pub extern "C" fn Splice_set_funding_feerate_perkw(this_ptr: &mut Splice, mut val: u32) {
2934         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_perkw = val;
2935 }
2936 /// The locktime for the new funding transaction
2937 #[no_mangle]
2938 pub extern "C" fn Splice_get_locktime(this_ptr: &Splice) -> u32 {
2939         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
2940         *inner_val
2941 }
2942 /// The locktime for the new funding transaction
2943 #[no_mangle]
2944 pub extern "C" fn Splice_set_locktime(this_ptr: &mut Splice, mut val: u32) {
2945         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
2946 }
2947 /// The key of the sender (splice initiator) controlling the new funding transaction
2948 #[no_mangle]
2949 pub extern "C" fn Splice_get_funding_pubkey(this_ptr: &Splice) -> crate::c_types::PublicKey {
2950         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
2951         crate::c_types::PublicKey::from_rust(&inner_val)
2952 }
2953 /// The key of the sender (splice initiator) controlling the new funding transaction
2954 #[no_mangle]
2955 pub extern "C" fn Splice_set_funding_pubkey(this_ptr: &mut Splice, mut val: crate::c_types::PublicKey) {
2956         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
2957 }
2958 /// Constructs a new Splice given each field
2959 #[must_use]
2960 #[no_mangle]
2961 pub extern "C" fn Splice_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_feerate_perkw_arg: u32, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey) -> Splice {
2962         Splice { inner: ObjOps::heap_alloc(nativeSplice {
2963                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2964                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
2965                 relative_satoshis: relative_satoshis_arg,
2966                 funding_feerate_perkw: funding_feerate_perkw_arg,
2967                 locktime: locktime_arg,
2968                 funding_pubkey: funding_pubkey_arg.into_rust(),
2969         }), is_owned: true }
2970 }
2971 impl Clone for Splice {
2972         fn clone(&self) -> Self {
2973                 Self {
2974                         inner: if <*mut nativeSplice>::is_null(self.inner) { core::ptr::null_mut() } else {
2975                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2976                         is_owned: true,
2977                 }
2978         }
2979 }
2980 #[allow(unused)]
2981 /// Used only if an object of this type is returned as a trait impl by a method
2982 pub(crate) extern "C" fn Splice_clone_void(this_ptr: *const c_void) -> *mut c_void {
2983         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSplice)).clone() })) as *mut c_void
2984 }
2985 #[no_mangle]
2986 /// Creates a copy of the Splice
2987 pub extern "C" fn Splice_clone(orig: &Splice) -> Splice {
2988         orig.clone()
2989 }
2990 /// Get a string which allows debug introspection of a Splice object
2991 pub extern "C" fn Splice_debug_str_void(o: *const c_void) -> Str {
2992         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Splice }).into()}
2993 /// Checks if two Splices contain equal inner contents.
2994 /// This ignores pointers and is_owned flags and looks at the values in fields.
2995 /// Two objects with NULL inner values will be considered "equal" here.
2996 #[no_mangle]
2997 pub extern "C" fn Splice_eq(a: &Splice, b: &Splice) -> bool {
2998         if a.inner == b.inner { return true; }
2999         if a.inner.is_null() || b.inner.is_null() { return false; }
3000         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3001 }
3002
3003 use lightning::ln::msgs::SpliceAck as nativeSpliceAckImport;
3004 pub(crate) type nativeSpliceAck = nativeSpliceAckImport;
3005
3006 /// A splice_ack message to be received by or sent to the splice initiator.
3007 ///
3008 #[must_use]
3009 #[repr(C)]
3010 pub struct SpliceAck {
3011         /// A pointer to the opaque Rust object.
3012
3013         /// Nearly everywhere, inner must be non-null, however in places where
3014         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3015         pub inner: *mut nativeSpliceAck,
3016         /// Indicates that this is the only struct which contains the same pointer.
3017
3018         /// Rust functions which take ownership of an object provided via an argument require
3019         /// this to be true and invalidate the object pointed to by inner.
3020         pub is_owned: bool,
3021 }
3022
3023 impl Drop for SpliceAck {
3024         fn drop(&mut self) {
3025                 if self.is_owned && !<*mut nativeSpliceAck>::is_null(self.inner) {
3026                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3027                 }
3028         }
3029 }
3030 /// Frees any resources used by the SpliceAck, if is_owned is set and inner is non-NULL.
3031 #[no_mangle]
3032 pub extern "C" fn SpliceAck_free(this_obj: SpliceAck) { }
3033 #[allow(unused)]
3034 /// Used only if an object of this type is returned as a trait impl by a method
3035 pub(crate) extern "C" fn SpliceAck_free_void(this_ptr: *mut c_void) {
3036         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceAck) };
3037 }
3038 #[allow(unused)]
3039 impl SpliceAck {
3040         pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceAck {
3041                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3042         }
3043         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceAck {
3044                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3045         }
3046         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3047         pub(crate) fn take_inner(mut self) -> *mut nativeSpliceAck {
3048                 assert!(self.is_owned);
3049                 let ret = ObjOps::untweak_ptr(self.inner);
3050                 self.inner = core::ptr::null_mut();
3051                 ret
3052         }
3053 }
3054 /// The channel ID where splicing is intended
3055 #[no_mangle]
3056 pub extern "C" fn SpliceAck_get_channel_id(this_ptr: &SpliceAck) -> *const [u8; 32] {
3057         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3058         &inner_val.0
3059 }
3060 /// The channel ID where splicing is intended
3061 #[no_mangle]
3062 pub extern "C" fn SpliceAck_set_channel_id(this_ptr: &mut SpliceAck, mut val: crate::c_types::ThirtyTwoBytes) {
3063         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3064 }
3065 /// The genesis hash of the blockchain where the channel is intended to be spliced
3066 #[no_mangle]
3067 pub extern "C" fn SpliceAck_get_chain_hash(this_ptr: &SpliceAck) -> *const [u8; 32] {
3068         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3069         inner_val.as_ref()
3070 }
3071 /// The genesis hash of the blockchain where the channel is intended to be spliced
3072 #[no_mangle]
3073 pub extern "C" fn SpliceAck_set_chain_hash(this_ptr: &mut SpliceAck, mut val: crate::c_types::ThirtyTwoBytes) {
3074         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
3075 }
3076 /// The intended change in channel capacity: the amount to be added (positive value)
3077 /// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
3078 #[no_mangle]
3079 pub extern "C" fn SpliceAck_get_relative_satoshis(this_ptr: &SpliceAck) -> i64 {
3080         let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis;
3081         *inner_val
3082 }
3083 /// The intended change in channel capacity: the amount to be added (positive value)
3084 /// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
3085 #[no_mangle]
3086 pub extern "C" fn SpliceAck_set_relative_satoshis(this_ptr: &mut SpliceAck, mut val: i64) {
3087         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val;
3088 }
3089 /// The key of the sender (splice acceptor) controlling the new funding transaction
3090 #[no_mangle]
3091 pub extern "C" fn SpliceAck_get_funding_pubkey(this_ptr: &SpliceAck) -> crate::c_types::PublicKey {
3092         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
3093         crate::c_types::PublicKey::from_rust(&inner_val)
3094 }
3095 /// The key of the sender (splice acceptor) controlling the new funding transaction
3096 #[no_mangle]
3097 pub extern "C" fn SpliceAck_set_funding_pubkey(this_ptr: &mut SpliceAck, mut val: crate::c_types::PublicKey) {
3098         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
3099 }
3100 /// Constructs a new SpliceAck given each field
3101 #[must_use]
3102 #[no_mangle]
3103 pub extern "C" fn SpliceAck_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_pubkey_arg: crate::c_types::PublicKey) -> SpliceAck {
3104         SpliceAck { inner: ObjOps::heap_alloc(nativeSpliceAck {
3105                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3106                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
3107                 relative_satoshis: relative_satoshis_arg,
3108                 funding_pubkey: funding_pubkey_arg.into_rust(),
3109         }), is_owned: true }
3110 }
3111 impl Clone for SpliceAck {
3112         fn clone(&self) -> Self {
3113                 Self {
3114                         inner: if <*mut nativeSpliceAck>::is_null(self.inner) { core::ptr::null_mut() } else {
3115                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3116                         is_owned: true,
3117                 }
3118         }
3119 }
3120 #[allow(unused)]
3121 /// Used only if an object of this type is returned as a trait impl by a method
3122 pub(crate) extern "C" fn SpliceAck_clone_void(this_ptr: *const c_void) -> *mut c_void {
3123         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceAck)).clone() })) as *mut c_void
3124 }
3125 #[no_mangle]
3126 /// Creates a copy of the SpliceAck
3127 pub extern "C" fn SpliceAck_clone(orig: &SpliceAck) -> SpliceAck {
3128         orig.clone()
3129 }
3130 /// Get a string which allows debug introspection of a SpliceAck object
3131 pub extern "C" fn SpliceAck_debug_str_void(o: *const c_void) -> Str {
3132         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceAck }).into()}
3133 /// Checks if two SpliceAcks contain equal inner contents.
3134 /// This ignores pointers and is_owned flags and looks at the values in fields.
3135 /// Two objects with NULL inner values will be considered "equal" here.
3136 #[no_mangle]
3137 pub extern "C" fn SpliceAck_eq(a: &SpliceAck, b: &SpliceAck) -> bool {
3138         if a.inner == b.inner { return true; }
3139         if a.inner.is_null() || b.inner.is_null() { return false; }
3140         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3141 }
3142
3143 use lightning::ln::msgs::SpliceLocked as nativeSpliceLockedImport;
3144 pub(crate) type nativeSpliceLocked = nativeSpliceLockedImport;
3145
3146 /// A splice_locked message to be sent to or received from a peer.
3147 ///
3148 #[must_use]
3149 #[repr(C)]
3150 pub struct SpliceLocked {
3151         /// A pointer to the opaque Rust object.
3152
3153         /// Nearly everywhere, inner must be non-null, however in places where
3154         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3155         pub inner: *mut nativeSpliceLocked,
3156         /// Indicates that this is the only struct which contains the same pointer.
3157
3158         /// Rust functions which take ownership of an object provided via an argument require
3159         /// this to be true and invalidate the object pointed to by inner.
3160         pub is_owned: bool,
3161 }
3162
3163 impl Drop for SpliceLocked {
3164         fn drop(&mut self) {
3165                 if self.is_owned && !<*mut nativeSpliceLocked>::is_null(self.inner) {
3166                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3167                 }
3168         }
3169 }
3170 /// Frees any resources used by the SpliceLocked, if is_owned is set and inner is non-NULL.
3171 #[no_mangle]
3172 pub extern "C" fn SpliceLocked_free(this_obj: SpliceLocked) { }
3173 #[allow(unused)]
3174 /// Used only if an object of this type is returned as a trait impl by a method
3175 pub(crate) extern "C" fn SpliceLocked_free_void(this_ptr: *mut c_void) {
3176         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceLocked) };
3177 }
3178 #[allow(unused)]
3179 impl SpliceLocked {
3180         pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceLocked {
3181                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3182         }
3183         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceLocked {
3184                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3185         }
3186         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3187         pub(crate) fn take_inner(mut self) -> *mut nativeSpliceLocked {
3188                 assert!(self.is_owned);
3189                 let ret = ObjOps::untweak_ptr(self.inner);
3190                 self.inner = core::ptr::null_mut();
3191                 ret
3192         }
3193 }
3194 /// The channel ID
3195 #[no_mangle]
3196 pub extern "C" fn SpliceLocked_get_channel_id(this_ptr: &SpliceLocked) -> *const [u8; 32] {
3197         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3198         &inner_val.0
3199 }
3200 /// The channel ID
3201 #[no_mangle]
3202 pub extern "C" fn SpliceLocked_set_channel_id(this_ptr: &mut SpliceLocked, mut val: crate::c_types::ThirtyTwoBytes) {
3203         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3204 }
3205 /// Constructs a new SpliceLocked given each field
3206 #[must_use]
3207 #[no_mangle]
3208 pub extern "C" fn SpliceLocked_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> SpliceLocked {
3209         SpliceLocked { inner: ObjOps::heap_alloc(nativeSpliceLocked {
3210                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3211         }), is_owned: true }
3212 }
3213 impl Clone for SpliceLocked {
3214         fn clone(&self) -> Self {
3215                 Self {
3216                         inner: if <*mut nativeSpliceLocked>::is_null(self.inner) { core::ptr::null_mut() } else {
3217                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3218                         is_owned: true,
3219                 }
3220         }
3221 }
3222 #[allow(unused)]
3223 /// Used only if an object of this type is returned as a trait impl by a method
3224 pub(crate) extern "C" fn SpliceLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
3225         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceLocked)).clone() })) as *mut c_void
3226 }
3227 #[no_mangle]
3228 /// Creates a copy of the SpliceLocked
3229 pub extern "C" fn SpliceLocked_clone(orig: &SpliceLocked) -> SpliceLocked {
3230         orig.clone()
3231 }
3232 /// Get a string which allows debug introspection of a SpliceLocked object
3233 pub extern "C" fn SpliceLocked_debug_str_void(o: *const c_void) -> Str {
3234         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceLocked }).into()}
3235 /// Checks if two SpliceLockeds contain equal inner contents.
3236 /// This ignores pointers and is_owned flags and looks at the values in fields.
3237 /// Two objects with NULL inner values will be considered "equal" here.
3238 #[no_mangle]
3239 pub extern "C" fn SpliceLocked_eq(a: &SpliceLocked, b: &SpliceLocked) -> bool {
3240         if a.inner == b.inner { return true; }
3241         if a.inner.is_null() || b.inner.is_null() { return false; }
3242         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3243 }
3244
3245 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
3246 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
3247
3248 /// A tx_add_input message for adding an input during interactive transaction construction
3249 ///
3250 #[must_use]
3251 #[repr(C)]
3252 pub struct TxAddInput {
3253         /// A pointer to the opaque Rust object.
3254
3255         /// Nearly everywhere, inner must be non-null, however in places where
3256         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3257         pub inner: *mut nativeTxAddInput,
3258         /// Indicates that this is the only struct which contains the same pointer.
3259
3260         /// Rust functions which take ownership of an object provided via an argument require
3261         /// this to be true and invalidate the object pointed to by inner.
3262         pub is_owned: bool,
3263 }
3264
3265 impl Drop for TxAddInput {
3266         fn drop(&mut self) {
3267                 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
3268                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3269                 }
3270         }
3271 }
3272 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
3273 #[no_mangle]
3274 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
3275 #[allow(unused)]
3276 /// Used only if an object of this type is returned as a trait impl by a method
3277 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
3278         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
3279 }
3280 #[allow(unused)]
3281 impl TxAddInput {
3282         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
3283                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3284         }
3285         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
3286                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3287         }
3288         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3289         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
3290                 assert!(self.is_owned);
3291                 let ret = ObjOps::untweak_ptr(self.inner);
3292                 self.inner = core::ptr::null_mut();
3293                 ret
3294         }
3295 }
3296 /// The channel ID
3297 #[no_mangle]
3298 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] {
3299         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3300         &inner_val.0
3301 }
3302 /// The channel ID
3303 #[no_mangle]
3304 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) {
3305         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3306 }
3307 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
3308 /// non-initiators.
3309 #[no_mangle]
3310 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
3311         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3312         *inner_val
3313 }
3314 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
3315 /// non-initiators.
3316 #[no_mangle]
3317 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
3318         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3319 }
3320 /// Serialized transaction that contains the output this input spends to verify that it is non
3321 /// malleable.
3322 #[no_mangle]
3323 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
3324         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
3325         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 }
3326 }
3327 /// Serialized transaction that contains the output this input spends to verify that it is non
3328 /// malleable.
3329 #[no_mangle]
3330 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
3331         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
3332 }
3333 /// The index of the output being spent
3334 #[no_mangle]
3335 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
3336         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
3337         *inner_val
3338 }
3339 /// The index of the output being spent
3340 #[no_mangle]
3341 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
3342         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
3343 }
3344 /// The sequence number of this input
3345 #[no_mangle]
3346 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
3347         let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
3348         *inner_val
3349 }
3350 /// The sequence number of this input
3351 #[no_mangle]
3352 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
3353         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
3354 }
3355 /// Constructs a new TxAddInput given each field
3356 #[must_use]
3357 #[no_mangle]
3358 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 {
3359         TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
3360                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3361                 serial_id: serial_id_arg,
3362                 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
3363                 prevtx_out: prevtx_out_arg,
3364                 sequence: sequence_arg,
3365         }), is_owned: true }
3366 }
3367 impl Clone for TxAddInput {
3368         fn clone(&self) -> Self {
3369                 Self {
3370                         inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
3371                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3372                         is_owned: true,
3373                 }
3374         }
3375 }
3376 #[allow(unused)]
3377 /// Used only if an object of this type is returned as a trait impl by a method
3378 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3379         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddInput)).clone() })) as *mut c_void
3380 }
3381 #[no_mangle]
3382 /// Creates a copy of the TxAddInput
3383 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
3384         orig.clone()
3385 }
3386 /// Get a string which allows debug introspection of a TxAddInput object
3387 pub extern "C" fn TxAddInput_debug_str_void(o: *const c_void) -> Str {
3388         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAddInput }).into()}
3389 /// Generates a non-cryptographic 64-bit hash of the TxAddInput.
3390 #[no_mangle]
3391 pub extern "C" fn TxAddInput_hash(o: &TxAddInput) -> u64 {
3392         if o.inner.is_null() { return 0; }
3393         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3394         #[allow(deprecated)]
3395         let mut hasher = core::hash::SipHasher::new();
3396         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3397         core::hash::Hasher::finish(&hasher)
3398 }
3399 /// Checks if two TxAddInputs contain equal inner contents.
3400 /// This ignores pointers and is_owned flags and looks at the values in fields.
3401 /// Two objects with NULL inner values will be considered "equal" here.
3402 #[no_mangle]
3403 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
3404         if a.inner == b.inner { return true; }
3405         if a.inner.is_null() || b.inner.is_null() { return false; }
3406         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3407 }
3408
3409 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
3410 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
3411
3412 /// A tx_add_output message for adding an output during interactive transaction construction.
3413 ///
3414 #[must_use]
3415 #[repr(C)]
3416 pub struct TxAddOutput {
3417         /// A pointer to the opaque Rust object.
3418
3419         /// Nearly everywhere, inner must be non-null, however in places where
3420         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3421         pub inner: *mut nativeTxAddOutput,
3422         /// Indicates that this is the only struct which contains the same pointer.
3423
3424         /// Rust functions which take ownership of an object provided via an argument require
3425         /// this to be true and invalidate the object pointed to by inner.
3426         pub is_owned: bool,
3427 }
3428
3429 impl Drop for TxAddOutput {
3430         fn drop(&mut self) {
3431                 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
3432                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3433                 }
3434         }
3435 }
3436 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
3437 #[no_mangle]
3438 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
3439 #[allow(unused)]
3440 /// Used only if an object of this type is returned as a trait impl by a method
3441 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
3442         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
3443 }
3444 #[allow(unused)]
3445 impl TxAddOutput {
3446         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
3447                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3448         }
3449         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
3450                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3451         }
3452         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3453         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
3454                 assert!(self.is_owned);
3455                 let ret = ObjOps::untweak_ptr(self.inner);
3456                 self.inner = core::ptr::null_mut();
3457                 ret
3458         }
3459 }
3460 /// The channel ID
3461 #[no_mangle]
3462 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] {
3463         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3464         &inner_val.0
3465 }
3466 /// The channel ID
3467 #[no_mangle]
3468 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) {
3469         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3470 }
3471 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
3472 /// non-initiators.
3473 #[no_mangle]
3474 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
3475         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3476         *inner_val
3477 }
3478 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
3479 /// non-initiators.
3480 #[no_mangle]
3481 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
3482         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3483 }
3484 /// The satoshi value of the output
3485 #[no_mangle]
3486 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
3487         let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
3488         *inner_val
3489 }
3490 /// The satoshi value of the output
3491 #[no_mangle]
3492 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
3493         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
3494 }
3495 /// The scriptPubKey for the output
3496 #[no_mangle]
3497 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
3498         let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
3499         inner_val.as_bytes().to_vec().into()
3500 }
3501 /// The scriptPubKey for the output
3502 #[no_mangle]
3503 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
3504         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust());
3505 }
3506 /// Constructs a new TxAddOutput given each field
3507 #[must_use]
3508 #[no_mangle]
3509 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 {
3510         TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
3511                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3512                 serial_id: serial_id_arg,
3513                 sats: sats_arg,
3514                 script: ::bitcoin::blockdata::script::ScriptBuf::from(script_arg.into_rust()),
3515         }), is_owned: true }
3516 }
3517 impl Clone for TxAddOutput {
3518         fn clone(&self) -> Self {
3519                 Self {
3520                         inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3521                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3522                         is_owned: true,
3523                 }
3524         }
3525 }
3526 #[allow(unused)]
3527 /// Used only if an object of this type is returned as a trait impl by a method
3528 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3529         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddOutput)).clone() })) as *mut c_void
3530 }
3531 #[no_mangle]
3532 /// Creates a copy of the TxAddOutput
3533 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
3534         orig.clone()
3535 }
3536 /// Get a string which allows debug introspection of a TxAddOutput object
3537 pub extern "C" fn TxAddOutput_debug_str_void(o: *const c_void) -> Str {
3538         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAddOutput }).into()}
3539 /// Generates a non-cryptographic 64-bit hash of the TxAddOutput.
3540 #[no_mangle]
3541 pub extern "C" fn TxAddOutput_hash(o: &TxAddOutput) -> u64 {
3542         if o.inner.is_null() { return 0; }
3543         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3544         #[allow(deprecated)]
3545         let mut hasher = core::hash::SipHasher::new();
3546         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3547         core::hash::Hasher::finish(&hasher)
3548 }
3549 /// Checks if two TxAddOutputs contain equal inner contents.
3550 /// This ignores pointers and is_owned flags and looks at the values in fields.
3551 /// Two objects with NULL inner values will be considered "equal" here.
3552 #[no_mangle]
3553 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
3554         if a.inner == b.inner { return true; }
3555         if a.inner.is_null() || b.inner.is_null() { return false; }
3556         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3557 }
3558
3559 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
3560 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
3561
3562 /// A tx_remove_input message for removing an input during interactive transaction construction.
3563 ///
3564 #[must_use]
3565 #[repr(C)]
3566 pub struct TxRemoveInput {
3567         /// A pointer to the opaque Rust object.
3568
3569         /// Nearly everywhere, inner must be non-null, however in places where
3570         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3571         pub inner: *mut nativeTxRemoveInput,
3572         /// Indicates that this is the only struct which contains the same pointer.
3573
3574         /// Rust functions which take ownership of an object provided via an argument require
3575         /// this to be true and invalidate the object pointed to by inner.
3576         pub is_owned: bool,
3577 }
3578
3579 impl Drop for TxRemoveInput {
3580         fn drop(&mut self) {
3581                 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
3582                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3583                 }
3584         }
3585 }
3586 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
3587 #[no_mangle]
3588 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
3589 #[allow(unused)]
3590 /// Used only if an object of this type is returned as a trait impl by a method
3591 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
3592         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
3593 }
3594 #[allow(unused)]
3595 impl TxRemoveInput {
3596         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
3597                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3598         }
3599         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
3600                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3601         }
3602         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3603         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
3604                 assert!(self.is_owned);
3605                 let ret = ObjOps::untweak_ptr(self.inner);
3606                 self.inner = core::ptr::null_mut();
3607                 ret
3608         }
3609 }
3610 /// The channel ID
3611 #[no_mangle]
3612 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] {
3613         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3614         &inner_val.0
3615 }
3616 /// The channel ID
3617 #[no_mangle]
3618 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) {
3619         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3620 }
3621 /// The serial ID of the input to be removed
3622 #[no_mangle]
3623 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
3624         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3625         *inner_val
3626 }
3627 /// The serial ID of the input to be removed
3628 #[no_mangle]
3629 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
3630         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3631 }
3632 /// Constructs a new TxRemoveInput given each field
3633 #[must_use]
3634 #[no_mangle]
3635 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput {
3636         TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
3637                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3638                 serial_id: serial_id_arg,
3639         }), is_owned: true }
3640 }
3641 impl Clone for TxRemoveInput {
3642         fn clone(&self) -> Self {
3643                 Self {
3644                         inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
3645                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3646                         is_owned: true,
3647                 }
3648         }
3649 }
3650 #[allow(unused)]
3651 /// Used only if an object of this type is returned as a trait impl by a method
3652 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3653         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveInput)).clone() })) as *mut c_void
3654 }
3655 #[no_mangle]
3656 /// Creates a copy of the TxRemoveInput
3657 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
3658         orig.clone()
3659 }
3660 /// Get a string which allows debug introspection of a TxRemoveInput object
3661 pub extern "C" fn TxRemoveInput_debug_str_void(o: *const c_void) -> Str {
3662         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxRemoveInput }).into()}
3663 /// Generates a non-cryptographic 64-bit hash of the TxRemoveInput.
3664 #[no_mangle]
3665 pub extern "C" fn TxRemoveInput_hash(o: &TxRemoveInput) -> u64 {
3666         if o.inner.is_null() { return 0; }
3667         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3668         #[allow(deprecated)]
3669         let mut hasher = core::hash::SipHasher::new();
3670         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3671         core::hash::Hasher::finish(&hasher)
3672 }
3673 /// Checks if two TxRemoveInputs contain equal inner contents.
3674 /// This ignores pointers and is_owned flags and looks at the values in fields.
3675 /// Two objects with NULL inner values will be considered "equal" here.
3676 #[no_mangle]
3677 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
3678         if a.inner == b.inner { return true; }
3679         if a.inner.is_null() || b.inner.is_null() { return false; }
3680         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3681 }
3682
3683 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
3684 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
3685
3686 /// A tx_remove_output message for removing an output during interactive transaction construction.
3687 ///
3688 #[must_use]
3689 #[repr(C)]
3690 pub struct TxRemoveOutput {
3691         /// A pointer to the opaque Rust object.
3692
3693         /// Nearly everywhere, inner must be non-null, however in places where
3694         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3695         pub inner: *mut nativeTxRemoveOutput,
3696         /// Indicates that this is the only struct which contains the same pointer.
3697
3698         /// Rust functions which take ownership of an object provided via an argument require
3699         /// this to be true and invalidate the object pointed to by inner.
3700         pub is_owned: bool,
3701 }
3702
3703 impl Drop for TxRemoveOutput {
3704         fn drop(&mut self) {
3705                 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
3706                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3707                 }
3708         }
3709 }
3710 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
3711 #[no_mangle]
3712 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
3713 #[allow(unused)]
3714 /// Used only if an object of this type is returned as a trait impl by a method
3715 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
3716         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
3717 }
3718 #[allow(unused)]
3719 impl TxRemoveOutput {
3720         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
3721                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3722         }
3723         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
3724                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3725         }
3726         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3727         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
3728                 assert!(self.is_owned);
3729                 let ret = ObjOps::untweak_ptr(self.inner);
3730                 self.inner = core::ptr::null_mut();
3731                 ret
3732         }
3733 }
3734 /// The channel ID
3735 #[no_mangle]
3736 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] {
3737         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3738         &inner_val.0
3739 }
3740 /// The channel ID
3741 #[no_mangle]
3742 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) {
3743         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3744 }
3745 /// The serial ID of the output to be removed
3746 #[no_mangle]
3747 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3748         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3749         *inner_val
3750 }
3751 /// The serial ID of the output to be removed
3752 #[no_mangle]
3753 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3754         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3755 }
3756 /// Constructs a new TxRemoveOutput given each field
3757 #[must_use]
3758 #[no_mangle]
3759 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput {
3760         TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3761                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3762                 serial_id: serial_id_arg,
3763         }), is_owned: true }
3764 }
3765 impl Clone for TxRemoveOutput {
3766         fn clone(&self) -> Self {
3767                 Self {
3768                         inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3769                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3770                         is_owned: true,
3771                 }
3772         }
3773 }
3774 #[allow(unused)]
3775 /// Used only if an object of this type is returned as a trait impl by a method
3776 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3777         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveOutput)).clone() })) as *mut c_void
3778 }
3779 #[no_mangle]
3780 /// Creates a copy of the TxRemoveOutput
3781 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3782         orig.clone()
3783 }
3784 /// Get a string which allows debug introspection of a TxRemoveOutput object
3785 pub extern "C" fn TxRemoveOutput_debug_str_void(o: *const c_void) -> Str {
3786         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxRemoveOutput }).into()}
3787 /// Generates a non-cryptographic 64-bit hash of the TxRemoveOutput.
3788 #[no_mangle]
3789 pub extern "C" fn TxRemoveOutput_hash(o: &TxRemoveOutput) -> u64 {
3790         if o.inner.is_null() { return 0; }
3791         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3792         #[allow(deprecated)]
3793         let mut hasher = core::hash::SipHasher::new();
3794         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3795         core::hash::Hasher::finish(&hasher)
3796 }
3797 /// Checks if two TxRemoveOutputs contain equal inner contents.
3798 /// This ignores pointers and is_owned flags and looks at the values in fields.
3799 /// Two objects with NULL inner values will be considered "equal" here.
3800 #[no_mangle]
3801 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3802         if a.inner == b.inner { return true; }
3803         if a.inner.is_null() || b.inner.is_null() { return false; }
3804         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3805 }
3806
3807 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3808 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3809
3810 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3811 /// interactive transaction construction.
3812 ///
3813 #[must_use]
3814 #[repr(C)]
3815 pub struct TxComplete {
3816         /// A pointer to the opaque Rust object.
3817
3818         /// Nearly everywhere, inner must be non-null, however in places where
3819         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3820         pub inner: *mut nativeTxComplete,
3821         /// Indicates that this is the only struct which contains the same pointer.
3822
3823         /// Rust functions which take ownership of an object provided via an argument require
3824         /// this to be true and invalidate the object pointed to by inner.
3825         pub is_owned: bool,
3826 }
3827
3828 impl Drop for TxComplete {
3829         fn drop(&mut self) {
3830                 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3831                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3832                 }
3833         }
3834 }
3835 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3836 #[no_mangle]
3837 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3838 #[allow(unused)]
3839 /// Used only if an object of this type is returned as a trait impl by a method
3840 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3841         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3842 }
3843 #[allow(unused)]
3844 impl TxComplete {
3845         pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3846                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3847         }
3848         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3849                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3850         }
3851         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3852         pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3853                 assert!(self.is_owned);
3854                 let ret = ObjOps::untweak_ptr(self.inner);
3855                 self.inner = core::ptr::null_mut();
3856                 ret
3857         }
3858 }
3859 /// The channel ID
3860 #[no_mangle]
3861 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] {
3862         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3863         &inner_val.0
3864 }
3865 /// The channel ID
3866 #[no_mangle]
3867 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) {
3868         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3869 }
3870 /// Constructs a new TxComplete given each field
3871 #[must_use]
3872 #[no_mangle]
3873 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete {
3874         TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3875                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3876         }), is_owned: true }
3877 }
3878 impl Clone for TxComplete {
3879         fn clone(&self) -> Self {
3880                 Self {
3881                         inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3882                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3883                         is_owned: true,
3884                 }
3885         }
3886 }
3887 #[allow(unused)]
3888 /// Used only if an object of this type is returned as a trait impl by a method
3889 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3890         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxComplete)).clone() })) as *mut c_void
3891 }
3892 #[no_mangle]
3893 /// Creates a copy of the TxComplete
3894 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3895         orig.clone()
3896 }
3897 /// Get a string which allows debug introspection of a TxComplete object
3898 pub extern "C" fn TxComplete_debug_str_void(o: *const c_void) -> Str {
3899         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxComplete }).into()}
3900 /// Generates a non-cryptographic 64-bit hash of the TxComplete.
3901 #[no_mangle]
3902 pub extern "C" fn TxComplete_hash(o: &TxComplete) -> u64 {
3903         if o.inner.is_null() { return 0; }
3904         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3905         #[allow(deprecated)]
3906         let mut hasher = core::hash::SipHasher::new();
3907         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3908         core::hash::Hasher::finish(&hasher)
3909 }
3910 /// Checks if two TxCompletes contain equal inner contents.
3911 /// This ignores pointers and is_owned flags and looks at the values in fields.
3912 /// Two objects with NULL inner values will be considered "equal" here.
3913 #[no_mangle]
3914 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3915         if a.inner == b.inner { return true; }
3916         if a.inner.is_null() || b.inner.is_null() { return false; }
3917         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3918 }
3919
3920 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3921 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3922
3923 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3924 /// interactive transaction construction.
3925 ///
3926 #[must_use]
3927 #[repr(C)]
3928 pub struct TxSignatures {
3929         /// A pointer to the opaque Rust object.
3930
3931         /// Nearly everywhere, inner must be non-null, however in places where
3932         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3933         pub inner: *mut nativeTxSignatures,
3934         /// Indicates that this is the only struct which contains the same pointer.
3935
3936         /// Rust functions which take ownership of an object provided via an argument require
3937         /// this to be true and invalidate the object pointed to by inner.
3938         pub is_owned: bool,
3939 }
3940
3941 impl Drop for TxSignatures {
3942         fn drop(&mut self) {
3943                 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3944                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3945                 }
3946         }
3947 }
3948 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3949 #[no_mangle]
3950 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3951 #[allow(unused)]
3952 /// Used only if an object of this type is returned as a trait impl by a method
3953 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3954         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3955 }
3956 #[allow(unused)]
3957 impl TxSignatures {
3958         pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3959                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3960         }
3961         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3962                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3963         }
3964         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3965         pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3966                 assert!(self.is_owned);
3967                 let ret = ObjOps::untweak_ptr(self.inner);
3968                 self.inner = core::ptr::null_mut();
3969                 ret
3970         }
3971 }
3972 /// The channel ID
3973 #[no_mangle]
3974 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] {
3975         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3976         &inner_val.0
3977 }
3978 /// The channel ID
3979 #[no_mangle]
3980 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3981         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3982 }
3983 /// The TXID
3984 #[no_mangle]
3985 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3986         let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3987         inner_val.as_ref()
3988 }
3989 /// The TXID
3990 #[no_mangle]
3991 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3992         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3993 }
3994 /// The list of witnesses
3995 ///
3996 /// Returns a copy of the field.
3997 #[no_mangle]
3998 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3999         let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
4000         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) }); };
4001         local_inner_val.into()
4002 }
4003 /// The list of witnesses
4004 #[no_mangle]
4005 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
4006         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
4007         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
4008 }
4009 /// Constructs a new TxSignatures given each field
4010 #[must_use]
4011 #[no_mangle]
4012 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 {
4013         let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
4014         TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
4015                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4016                 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
4017                 witnesses: local_witnesses_arg,
4018         }), is_owned: true }
4019 }
4020 impl Clone for TxSignatures {
4021         fn clone(&self) -> Self {
4022                 Self {
4023                         inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
4024                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4025                         is_owned: true,
4026                 }
4027         }
4028 }
4029 #[allow(unused)]
4030 /// Used only if an object of this type is returned as a trait impl by a method
4031 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
4032         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxSignatures)).clone() })) as *mut c_void
4033 }
4034 #[no_mangle]
4035 /// Creates a copy of the TxSignatures
4036 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
4037         orig.clone()
4038 }
4039 /// Get a string which allows debug introspection of a TxSignatures object
4040 pub extern "C" fn TxSignatures_debug_str_void(o: *const c_void) -> Str {
4041         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxSignatures }).into()}
4042 /// Generates a non-cryptographic 64-bit hash of the TxSignatures.
4043 #[no_mangle]
4044 pub extern "C" fn TxSignatures_hash(o: &TxSignatures) -> u64 {
4045         if o.inner.is_null() { return 0; }
4046         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4047         #[allow(deprecated)]
4048         let mut hasher = core::hash::SipHasher::new();
4049         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4050         core::hash::Hasher::finish(&hasher)
4051 }
4052 /// Checks if two TxSignaturess contain equal inner contents.
4053 /// This ignores pointers and is_owned flags and looks at the values in fields.
4054 /// Two objects with NULL inner values will be considered "equal" here.
4055 #[no_mangle]
4056 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
4057         if a.inner == b.inner { return true; }
4058         if a.inner.is_null() || b.inner.is_null() { return false; }
4059         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4060 }
4061
4062 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
4063 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
4064
4065 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
4066 /// completed.
4067 ///
4068 #[must_use]
4069 #[repr(C)]
4070 pub struct TxInitRbf {
4071         /// A pointer to the opaque Rust object.
4072
4073         /// Nearly everywhere, inner must be non-null, however in places where
4074         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4075         pub inner: *mut nativeTxInitRbf,
4076         /// Indicates that this is the only struct which contains the same pointer.
4077
4078         /// Rust functions which take ownership of an object provided via an argument require
4079         /// this to be true and invalidate the object pointed to by inner.
4080         pub is_owned: bool,
4081 }
4082
4083 impl Drop for TxInitRbf {
4084         fn drop(&mut self) {
4085                 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
4086                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4087                 }
4088         }
4089 }
4090 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
4091 #[no_mangle]
4092 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
4093 #[allow(unused)]
4094 /// Used only if an object of this type is returned as a trait impl by a method
4095 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
4096         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
4097 }
4098 #[allow(unused)]
4099 impl TxInitRbf {
4100         pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
4101                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4102         }
4103         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
4104                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4105         }
4106         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4107         pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
4108                 assert!(self.is_owned);
4109                 let ret = ObjOps::untweak_ptr(self.inner);
4110                 self.inner = core::ptr::null_mut();
4111                 ret
4112         }
4113 }
4114 /// The channel ID
4115 #[no_mangle]
4116 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] {
4117         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4118         &inner_val.0
4119 }
4120 /// The channel ID
4121 #[no_mangle]
4122 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) {
4123         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4124 }
4125 /// The locktime of the transaction
4126 #[no_mangle]
4127 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
4128         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
4129         *inner_val
4130 }
4131 /// The locktime of the transaction
4132 #[no_mangle]
4133 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
4134         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
4135 }
4136 /// The feerate of the transaction
4137 #[no_mangle]
4138 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
4139         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
4140         *inner_val
4141 }
4142 /// The feerate of the transaction
4143 #[no_mangle]
4144 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
4145         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
4146 }
4147 /// The number of satoshis the sender will contribute to or, if negative, remove from
4148 /// (e.g. splice-out) the funding output of the transaction
4149 #[no_mangle]
4150 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
4151         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
4152         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() }) };
4153         local_inner_val
4154 }
4155 /// The number of satoshis the sender will contribute to or, if negative, remove from
4156 /// (e.g. splice-out) the funding output of the transaction
4157 #[no_mangle]
4158 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
4159         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4160         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
4161 }
4162 /// Constructs a new TxInitRbf given each field
4163 #[must_use]
4164 #[no_mangle]
4165 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 {
4166         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
4167         TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
4168                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4169                 locktime: locktime_arg,
4170                 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
4171                 funding_output_contribution: local_funding_output_contribution_arg,
4172         }), is_owned: true }
4173 }
4174 impl Clone for TxInitRbf {
4175         fn clone(&self) -> Self {
4176                 Self {
4177                         inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
4178                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4179                         is_owned: true,
4180                 }
4181         }
4182 }
4183 #[allow(unused)]
4184 /// Used only if an object of this type is returned as a trait impl by a method
4185 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
4186         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxInitRbf)).clone() })) as *mut c_void
4187 }
4188 #[no_mangle]
4189 /// Creates a copy of the TxInitRbf
4190 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
4191         orig.clone()
4192 }
4193 /// Get a string which allows debug introspection of a TxInitRbf object
4194 pub extern "C" fn TxInitRbf_debug_str_void(o: *const c_void) -> Str {
4195         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxInitRbf }).into()}
4196 /// Generates a non-cryptographic 64-bit hash of the TxInitRbf.
4197 #[no_mangle]
4198 pub extern "C" fn TxInitRbf_hash(o: &TxInitRbf) -> u64 {
4199         if o.inner.is_null() { return 0; }
4200         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4201         #[allow(deprecated)]
4202         let mut hasher = core::hash::SipHasher::new();
4203         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4204         core::hash::Hasher::finish(&hasher)
4205 }
4206 /// Checks if two TxInitRbfs contain equal inner contents.
4207 /// This ignores pointers and is_owned flags and looks at the values in fields.
4208 /// Two objects with NULL inner values will be considered "equal" here.
4209 #[no_mangle]
4210 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
4211         if a.inner == b.inner { return true; }
4212         if a.inner.is_null() || b.inner.is_null() { return false; }
4213         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4214 }
4215
4216 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
4217 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
4218
4219 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
4220 /// completed.
4221 ///
4222 #[must_use]
4223 #[repr(C)]
4224 pub struct TxAckRbf {
4225         /// A pointer to the opaque Rust object.
4226
4227         /// Nearly everywhere, inner must be non-null, however in places where
4228         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4229         pub inner: *mut nativeTxAckRbf,
4230         /// Indicates that this is the only struct which contains the same pointer.
4231
4232         /// Rust functions which take ownership of an object provided via an argument require
4233         /// this to be true and invalidate the object pointed to by inner.
4234         pub is_owned: bool,
4235 }
4236
4237 impl Drop for TxAckRbf {
4238         fn drop(&mut self) {
4239                 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
4240                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4241                 }
4242         }
4243 }
4244 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
4245 #[no_mangle]
4246 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
4247 #[allow(unused)]
4248 /// Used only if an object of this type is returned as a trait impl by a method
4249 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
4250         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
4251 }
4252 #[allow(unused)]
4253 impl TxAckRbf {
4254         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
4255                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4256         }
4257         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
4258                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4259         }
4260         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4261         pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
4262                 assert!(self.is_owned);
4263                 let ret = ObjOps::untweak_ptr(self.inner);
4264                 self.inner = core::ptr::null_mut();
4265                 ret
4266         }
4267 }
4268 /// The channel ID
4269 #[no_mangle]
4270 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] {
4271         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4272         &inner_val.0
4273 }
4274 /// The channel ID
4275 #[no_mangle]
4276 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) {
4277         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4278 }
4279 /// The number of satoshis the sender will contribute to or, if negative, remove from
4280 /// (e.g. splice-out) the funding output of the transaction
4281 #[no_mangle]
4282 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
4283         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
4284         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() }) };
4285         local_inner_val
4286 }
4287 /// The number of satoshis the sender will contribute to or, if negative, remove from
4288 /// (e.g. splice-out) the funding output of the transaction
4289 #[no_mangle]
4290 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
4291         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4292         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
4293 }
4294 /// Constructs a new TxAckRbf given each field
4295 #[must_use]
4296 #[no_mangle]
4297 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 {
4298         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
4299         TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
4300                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4301                 funding_output_contribution: local_funding_output_contribution_arg,
4302         }), is_owned: true }
4303 }
4304 impl Clone for TxAckRbf {
4305         fn clone(&self) -> Self {
4306                 Self {
4307                         inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
4308                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4309                         is_owned: true,
4310                 }
4311         }
4312 }
4313 #[allow(unused)]
4314 /// Used only if an object of this type is returned as a trait impl by a method
4315 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
4316         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAckRbf)).clone() })) as *mut c_void
4317 }
4318 #[no_mangle]
4319 /// Creates a copy of the TxAckRbf
4320 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
4321         orig.clone()
4322 }
4323 /// Get a string which allows debug introspection of a TxAckRbf object
4324 pub extern "C" fn TxAckRbf_debug_str_void(o: *const c_void) -> Str {
4325         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAckRbf }).into()}
4326 /// Generates a non-cryptographic 64-bit hash of the TxAckRbf.
4327 #[no_mangle]
4328 pub extern "C" fn TxAckRbf_hash(o: &TxAckRbf) -> u64 {
4329         if o.inner.is_null() { return 0; }
4330         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4331         #[allow(deprecated)]
4332         let mut hasher = core::hash::SipHasher::new();
4333         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4334         core::hash::Hasher::finish(&hasher)
4335 }
4336 /// Checks if two TxAckRbfs contain equal inner contents.
4337 /// This ignores pointers and is_owned flags and looks at the values in fields.
4338 /// Two objects with NULL inner values will be considered "equal" here.
4339 #[no_mangle]
4340 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
4341         if a.inner == b.inner { return true; }
4342         if a.inner.is_null() || b.inner.is_null() { return false; }
4343         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4344 }
4345
4346 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
4347 pub(crate) type nativeTxAbort = nativeTxAbortImport;
4348
4349 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
4350 ///
4351 #[must_use]
4352 #[repr(C)]
4353 pub struct TxAbort {
4354         /// A pointer to the opaque Rust object.
4355
4356         /// Nearly everywhere, inner must be non-null, however in places where
4357         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4358         pub inner: *mut nativeTxAbort,
4359         /// Indicates that this is the only struct which contains the same pointer.
4360
4361         /// Rust functions which take ownership of an object provided via an argument require
4362         /// this to be true and invalidate the object pointed to by inner.
4363         pub is_owned: bool,
4364 }
4365
4366 impl Drop for TxAbort {
4367         fn drop(&mut self) {
4368                 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
4369                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4370                 }
4371         }
4372 }
4373 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
4374 #[no_mangle]
4375 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
4376 #[allow(unused)]
4377 /// Used only if an object of this type is returned as a trait impl by a method
4378 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
4379         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
4380 }
4381 #[allow(unused)]
4382 impl TxAbort {
4383         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
4384                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4385         }
4386         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
4387                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4388         }
4389         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4390         pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
4391                 assert!(self.is_owned);
4392                 let ret = ObjOps::untweak_ptr(self.inner);
4393                 self.inner = core::ptr::null_mut();
4394                 ret
4395         }
4396 }
4397 /// The channel ID
4398 #[no_mangle]
4399 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] {
4400         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4401         &inner_val.0
4402 }
4403 /// The channel ID
4404 #[no_mangle]
4405 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) {
4406         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4407 }
4408 /// Message data
4409 ///
4410 /// Returns a copy of the field.
4411 #[no_mangle]
4412 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
4413         let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
4414         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4415         local_inner_val.into()
4416 }
4417 /// Message data
4418 #[no_mangle]
4419 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
4420         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4421         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
4422 }
4423 /// Constructs a new TxAbort given each field
4424 #[must_use]
4425 #[no_mangle]
4426 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
4427         let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
4428         TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
4429                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4430                 data: local_data_arg,
4431         }), is_owned: true }
4432 }
4433 impl Clone for TxAbort {
4434         fn clone(&self) -> Self {
4435                 Self {
4436                         inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
4437                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4438                         is_owned: true,
4439                 }
4440         }
4441 }
4442 #[allow(unused)]
4443 /// Used only if an object of this type is returned as a trait impl by a method
4444 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
4445         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAbort)).clone() })) as *mut c_void
4446 }
4447 #[no_mangle]
4448 /// Creates a copy of the TxAbort
4449 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
4450         orig.clone()
4451 }
4452 /// Get a string which allows debug introspection of a TxAbort object
4453 pub extern "C" fn TxAbort_debug_str_void(o: *const c_void) -> Str {
4454         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAbort }).into()}
4455 /// Generates a non-cryptographic 64-bit hash of the TxAbort.
4456 #[no_mangle]
4457 pub extern "C" fn TxAbort_hash(o: &TxAbort) -> u64 {
4458         if o.inner.is_null() { return 0; }
4459         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4460         #[allow(deprecated)]
4461         let mut hasher = core::hash::SipHasher::new();
4462         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4463         core::hash::Hasher::finish(&hasher)
4464 }
4465 /// Checks if two TxAborts contain equal inner contents.
4466 /// This ignores pointers and is_owned flags and looks at the values in fields.
4467 /// Two objects with NULL inner values will be considered "equal" here.
4468 #[no_mangle]
4469 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
4470         if a.inner == b.inner { return true; }
4471         if a.inner.is_null() || b.inner.is_null() { return false; }
4472         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4473 }
4474
4475 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
4476 pub(crate) type nativeShutdown = nativeShutdownImport;
4477
4478 /// A [`shutdown`] message to be sent to or received from a peer.
4479 ///
4480 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
4481 #[must_use]
4482 #[repr(C)]
4483 pub struct Shutdown {
4484         /// A pointer to the opaque Rust object.
4485
4486         /// Nearly everywhere, inner must be non-null, however in places where
4487         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4488         pub inner: *mut nativeShutdown,
4489         /// Indicates that this is the only struct which contains the same pointer.
4490
4491         /// Rust functions which take ownership of an object provided via an argument require
4492         /// this to be true and invalidate the object pointed to by inner.
4493         pub is_owned: bool,
4494 }
4495
4496 impl Drop for Shutdown {
4497         fn drop(&mut self) {
4498                 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
4499                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4500                 }
4501         }
4502 }
4503 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
4504 #[no_mangle]
4505 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
4506 #[allow(unused)]
4507 /// Used only if an object of this type is returned as a trait impl by a method
4508 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
4509         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
4510 }
4511 #[allow(unused)]
4512 impl Shutdown {
4513         pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
4514                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4515         }
4516         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
4517                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4518         }
4519         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4520         pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
4521                 assert!(self.is_owned);
4522                 let ret = ObjOps::untweak_ptr(self.inner);
4523                 self.inner = core::ptr::null_mut();
4524                 ret
4525         }
4526 }
4527 /// The channel ID
4528 #[no_mangle]
4529 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
4530         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4531         &inner_val.0
4532 }
4533 /// The channel ID
4534 #[no_mangle]
4535 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
4536         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4537 }
4538 /// The destination of this peer's funds on closing.
4539 ///
4540 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
4541 #[no_mangle]
4542 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
4543         let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
4544         inner_val.as_bytes().to_vec().into()
4545 }
4546 /// The destination of this peer's funds on closing.
4547 ///
4548 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
4549 #[no_mangle]
4550 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
4551         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust());
4552 }
4553 /// Constructs a new Shutdown given each field
4554 #[must_use]
4555 #[no_mangle]
4556 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
4557         Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
4558                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4559                 scriptpubkey: ::bitcoin::blockdata::script::ScriptBuf::from(scriptpubkey_arg.into_rust()),
4560         }), is_owned: true }
4561 }
4562 impl Clone for Shutdown {
4563         fn clone(&self) -> Self {
4564                 Self {
4565                         inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
4566                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4567                         is_owned: true,
4568                 }
4569         }
4570 }
4571 #[allow(unused)]
4572 /// Used only if an object of this type is returned as a trait impl by a method
4573 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
4574         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeShutdown)).clone() })) as *mut c_void
4575 }
4576 #[no_mangle]
4577 /// Creates a copy of the Shutdown
4578 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
4579         orig.clone()
4580 }
4581 /// Get a string which allows debug introspection of a Shutdown object
4582 pub extern "C" fn Shutdown_debug_str_void(o: *const c_void) -> Str {
4583         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Shutdown }).into()}
4584 /// Generates a non-cryptographic 64-bit hash of the Shutdown.
4585 #[no_mangle]
4586 pub extern "C" fn Shutdown_hash(o: &Shutdown) -> u64 {
4587         if o.inner.is_null() { return 0; }
4588         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4589         #[allow(deprecated)]
4590         let mut hasher = core::hash::SipHasher::new();
4591         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4592         core::hash::Hasher::finish(&hasher)
4593 }
4594 /// Checks if two Shutdowns contain equal inner contents.
4595 /// This ignores pointers and is_owned flags and looks at the values in fields.
4596 /// Two objects with NULL inner values will be considered "equal" here.
4597 #[no_mangle]
4598 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
4599         if a.inner == b.inner { return true; }
4600         if a.inner.is_null() || b.inner.is_null() { return false; }
4601         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4602 }
4603
4604 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
4605 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
4606
4607 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
4608 ///
4609 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
4610 /// to use.
4611 #[must_use]
4612 #[repr(C)]
4613 pub struct ClosingSignedFeeRange {
4614         /// A pointer to the opaque Rust object.
4615
4616         /// Nearly everywhere, inner must be non-null, however in places where
4617         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4618         pub inner: *mut nativeClosingSignedFeeRange,
4619         /// Indicates that this is the only struct which contains the same pointer.
4620
4621         /// Rust functions which take ownership of an object provided via an argument require
4622         /// this to be true and invalidate the object pointed to by inner.
4623         pub is_owned: bool,
4624 }
4625
4626 impl Drop for ClosingSignedFeeRange {
4627         fn drop(&mut self) {
4628                 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
4629                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4630                 }
4631         }
4632 }
4633 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
4634 #[no_mangle]
4635 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
4636 #[allow(unused)]
4637 /// Used only if an object of this type is returned as a trait impl by a method
4638 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
4639         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
4640 }
4641 #[allow(unused)]
4642 impl ClosingSignedFeeRange {
4643         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
4644                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4645         }
4646         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
4647                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4648         }
4649         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4650         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
4651                 assert!(self.is_owned);
4652                 let ret = ObjOps::untweak_ptr(self.inner);
4653                 self.inner = core::ptr::null_mut();
4654                 ret
4655         }
4656 }
4657 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
4658 /// transaction.
4659 #[no_mangle]
4660 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
4661         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
4662         *inner_val
4663 }
4664 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
4665 /// transaction.
4666 #[no_mangle]
4667 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
4668         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
4669 }
4670 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
4671 /// transaction.
4672 #[no_mangle]
4673 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
4674         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
4675         *inner_val
4676 }
4677 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
4678 /// transaction.
4679 #[no_mangle]
4680 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
4681         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
4682 }
4683 /// Constructs a new ClosingSignedFeeRange given each field
4684 #[must_use]
4685 #[no_mangle]
4686 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
4687         ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
4688                 min_fee_satoshis: min_fee_satoshis_arg,
4689                 max_fee_satoshis: max_fee_satoshis_arg,
4690         }), is_owned: true }
4691 }
4692 impl Clone for ClosingSignedFeeRange {
4693         fn clone(&self) -> Self {
4694                 Self {
4695                         inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4696                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4697                         is_owned: true,
4698                 }
4699         }
4700 }
4701 #[allow(unused)]
4702 /// Used only if an object of this type is returned as a trait impl by a method
4703 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4704         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSignedFeeRange)).clone() })) as *mut c_void
4705 }
4706 #[no_mangle]
4707 /// Creates a copy of the ClosingSignedFeeRange
4708 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
4709         orig.clone()
4710 }
4711 /// Get a string which allows debug introspection of a ClosingSignedFeeRange object
4712 pub extern "C" fn ClosingSignedFeeRange_debug_str_void(o: *const c_void) -> Str {
4713         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ClosingSignedFeeRange }).into()}
4714 /// Generates a non-cryptographic 64-bit hash of the ClosingSignedFeeRange.
4715 #[no_mangle]
4716 pub extern "C" fn ClosingSignedFeeRange_hash(o: &ClosingSignedFeeRange) -> u64 {
4717         if o.inner.is_null() { return 0; }
4718         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4719         #[allow(deprecated)]
4720         let mut hasher = core::hash::SipHasher::new();
4721         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4722         core::hash::Hasher::finish(&hasher)
4723 }
4724 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
4725 /// This ignores pointers and is_owned flags and looks at the values in fields.
4726 /// Two objects with NULL inner values will be considered "equal" here.
4727 #[no_mangle]
4728 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
4729         if a.inner == b.inner { return true; }
4730         if a.inner.is_null() || b.inner.is_null() { return false; }
4731         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4732 }
4733
4734 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
4735 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
4736
4737 /// A [`closing_signed`] message to be sent to or received from a peer.
4738 ///
4739 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
4740 #[must_use]
4741 #[repr(C)]
4742 pub struct ClosingSigned {
4743         /// A pointer to the opaque Rust object.
4744
4745         /// Nearly everywhere, inner must be non-null, however in places where
4746         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4747         pub inner: *mut nativeClosingSigned,
4748         /// Indicates that this is the only struct which contains the same pointer.
4749
4750         /// Rust functions which take ownership of an object provided via an argument require
4751         /// this to be true and invalidate the object pointed to by inner.
4752         pub is_owned: bool,
4753 }
4754
4755 impl Drop for ClosingSigned {
4756         fn drop(&mut self) {
4757                 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
4758                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4759                 }
4760         }
4761 }
4762 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
4763 #[no_mangle]
4764 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
4765 #[allow(unused)]
4766 /// Used only if an object of this type is returned as a trait impl by a method
4767 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
4768         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
4769 }
4770 #[allow(unused)]
4771 impl ClosingSigned {
4772         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
4773                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4774         }
4775         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
4776                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4777         }
4778         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4779         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
4780                 assert!(self.is_owned);
4781                 let ret = ObjOps::untweak_ptr(self.inner);
4782                 self.inner = core::ptr::null_mut();
4783                 ret
4784         }
4785 }
4786 /// The channel ID
4787 #[no_mangle]
4788 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
4789         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4790         &inner_val.0
4791 }
4792 /// The channel ID
4793 #[no_mangle]
4794 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
4795         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4796 }
4797 /// The proposed total fee for the closing transaction
4798 #[no_mangle]
4799 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
4800         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
4801         *inner_val
4802 }
4803 /// The proposed total fee for the closing transaction
4804 #[no_mangle]
4805 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
4806         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
4807 }
4808 /// A signature on the closing transaction
4809 #[no_mangle]
4810 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::ECDSASignature {
4811         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4812         crate::c_types::ECDSASignature::from_rust(&inner_val)
4813 }
4814 /// A signature on the closing transaction
4815 #[no_mangle]
4816 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ECDSASignature) {
4817         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4818 }
4819 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4820 /// nodes.
4821 ///
4822 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4823 #[no_mangle]
4824 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
4825         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
4826         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 };
4827         local_inner_val
4828 }
4829 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4830 /// nodes.
4831 ///
4832 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4833 #[no_mangle]
4834 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
4835         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4836         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
4837 }
4838 /// Constructs a new ClosingSigned given each field
4839 ///
4840 /// Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4841 #[must_use]
4842 #[no_mangle]
4843 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 {
4844         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()) } }) };
4845         ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
4846                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4847                 fee_satoshis: fee_satoshis_arg,
4848                 signature: signature_arg.into_rust(),
4849                 fee_range: local_fee_range_arg,
4850         }), is_owned: true }
4851 }
4852 impl Clone for ClosingSigned {
4853         fn clone(&self) -> Self {
4854                 Self {
4855                         inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4856                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4857                         is_owned: true,
4858                 }
4859         }
4860 }
4861 #[allow(unused)]
4862 /// Used only if an object of this type is returned as a trait impl by a method
4863 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4864         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSigned)).clone() })) as *mut c_void
4865 }
4866 #[no_mangle]
4867 /// Creates a copy of the ClosingSigned
4868 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4869         orig.clone()
4870 }
4871 /// Get a string which allows debug introspection of a ClosingSigned object
4872 pub extern "C" fn ClosingSigned_debug_str_void(o: *const c_void) -> Str {
4873         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ClosingSigned }).into()}
4874 /// Generates a non-cryptographic 64-bit hash of the ClosingSigned.
4875 #[no_mangle]
4876 pub extern "C" fn ClosingSigned_hash(o: &ClosingSigned) -> u64 {
4877         if o.inner.is_null() { return 0; }
4878         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4879         #[allow(deprecated)]
4880         let mut hasher = core::hash::SipHasher::new();
4881         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4882         core::hash::Hasher::finish(&hasher)
4883 }
4884 /// Checks if two ClosingSigneds contain equal inner contents.
4885 /// This ignores pointers and is_owned flags and looks at the values in fields.
4886 /// Two objects with NULL inner values will be considered "equal" here.
4887 #[no_mangle]
4888 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4889         if a.inner == b.inner { return true; }
4890         if a.inner.is_null() || b.inner.is_null() { return false; }
4891         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4892 }
4893
4894 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4895 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4896
4897 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4898 ///
4899 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4900 #[must_use]
4901 #[repr(C)]
4902 pub struct UpdateAddHTLC {
4903         /// A pointer to the opaque Rust object.
4904
4905         /// Nearly everywhere, inner must be non-null, however in places where
4906         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4907         pub inner: *mut nativeUpdateAddHTLC,
4908         /// Indicates that this is the only struct which contains the same pointer.
4909
4910         /// Rust functions which take ownership of an object provided via an argument require
4911         /// this to be true and invalidate the object pointed to by inner.
4912         pub is_owned: bool,
4913 }
4914
4915 impl Drop for UpdateAddHTLC {
4916         fn drop(&mut self) {
4917                 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4918                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4919                 }
4920         }
4921 }
4922 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4923 #[no_mangle]
4924 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4925 #[allow(unused)]
4926 /// Used only if an object of this type is returned as a trait impl by a method
4927 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4928         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4929 }
4930 #[allow(unused)]
4931 impl UpdateAddHTLC {
4932         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4933                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4934         }
4935         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4936                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4937         }
4938         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4939         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4940                 assert!(self.is_owned);
4941                 let ret = ObjOps::untweak_ptr(self.inner);
4942                 self.inner = core::ptr::null_mut();
4943                 ret
4944         }
4945 }
4946 /// The channel ID
4947 #[no_mangle]
4948 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4949         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4950         &inner_val.0
4951 }
4952 /// The channel ID
4953 #[no_mangle]
4954 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4955         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4956 }
4957 /// The HTLC ID
4958 #[no_mangle]
4959 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4960         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4961         *inner_val
4962 }
4963 /// The HTLC ID
4964 #[no_mangle]
4965 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4966         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4967 }
4968 /// The HTLC value in milli-satoshi
4969 #[no_mangle]
4970 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4971         let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4972         *inner_val
4973 }
4974 /// The HTLC value in milli-satoshi
4975 #[no_mangle]
4976 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4977         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4978 }
4979 /// The payment hash, the pre-image of which controls HTLC redemption
4980 #[no_mangle]
4981 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4982         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4983         &inner_val.0
4984 }
4985 /// The payment hash, the pre-image of which controls HTLC redemption
4986 #[no_mangle]
4987 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4988         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
4989 }
4990 /// The expiry height of the HTLC
4991 #[no_mangle]
4992 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4993         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4994         *inner_val
4995 }
4996 /// The expiry height of the HTLC
4997 #[no_mangle]
4998 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4999         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
5000 }
5001 /// The extra fee skimmed by the sender of this message. See
5002 /// [`ChannelConfig::accept_underpaying_htlcs`].
5003 ///
5004 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
5005 #[no_mangle]
5006 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
5007         let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
5008         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() }) };
5009         local_inner_val
5010 }
5011 /// The extra fee skimmed by the sender of this message. See
5012 /// [`ChannelConfig::accept_underpaying_htlcs`].
5013 ///
5014 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
5015 #[no_mangle]
5016 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
5017         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
5018         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
5019 }
5020 /// The onion routing packet with encrypted data for the next hop.
5021 #[no_mangle]
5022 pub extern "C" fn UpdateAddHTLC_get_onion_routing_packet(this_ptr: &UpdateAddHTLC) -> crate::lightning::ln::msgs::OnionPacket {
5023         let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
5024         crate::lightning::ln::msgs::OnionPacket { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::OnionPacket<>) as *mut _) }, is_owned: false }
5025 }
5026 /// The onion routing packet with encrypted data for the next hop.
5027 #[no_mangle]
5028 pub extern "C" fn UpdateAddHTLC_set_onion_routing_packet(this_ptr: &mut UpdateAddHTLC, mut val: crate::lightning::ln::msgs::OnionPacket) {
5029         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
5030 }
5031 /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
5032 /// routing packet and the recipient-provided encrypted payload within.
5033 ///
5034 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
5035 #[no_mangle]
5036 pub extern "C" fn UpdateAddHTLC_get_blinding_point(this_ptr: &UpdateAddHTLC) -> crate::c_types::PublicKey {
5037         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
5038         let mut local_inner_val = if inner_val.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(inner_val.unwrap())) } };
5039         local_inner_val
5040 }
5041 /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
5042 /// routing packet and the recipient-provided encrypted payload within.
5043 ///
5044 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
5045 #[no_mangle]
5046 pub extern "C" fn UpdateAddHTLC_set_blinding_point(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::PublicKey) {
5047         let mut local_val = if val.is_null() { None } else { Some( { val.into_rust() }) };
5048         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = local_val;
5049 }
5050 /// Constructs a new UpdateAddHTLC given each field
5051 ///
5052 /// Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
5053 #[must_use]
5054 #[no_mangle]
5055 pub extern "C" fn UpdateAddHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut amount_msat_arg: u64, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut cltv_expiry_arg: u32, mut skimmed_fee_msat_arg: crate::c_types::derived::COption_u64Z, mut onion_routing_packet_arg: crate::lightning::ln::msgs::OnionPacket, mut blinding_point_arg: crate::c_types::PublicKey) -> UpdateAddHTLC {
5056         let mut local_skimmed_fee_msat_arg = if skimmed_fee_msat_arg.is_some() { Some( { skimmed_fee_msat_arg.take() }) } else { None };
5057         let mut local_blinding_point_arg = if blinding_point_arg.is_null() { None } else { Some( { blinding_point_arg.into_rust() }) };
5058         UpdateAddHTLC { inner: ObjOps::heap_alloc(nativeUpdateAddHTLC {
5059                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5060                 htlc_id: htlc_id_arg,
5061                 amount_msat: amount_msat_arg,
5062                 payment_hash: ::lightning::ln::PaymentHash(payment_hash_arg.data),
5063                 cltv_expiry: cltv_expiry_arg,
5064                 skimmed_fee_msat: local_skimmed_fee_msat_arg,
5065                 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
5066                 blinding_point: local_blinding_point_arg,
5067         }), is_owned: true }
5068 }
5069 impl Clone for UpdateAddHTLC {
5070         fn clone(&self) -> Self {
5071                 Self {
5072                         inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5073                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5074                         is_owned: true,
5075                 }
5076         }
5077 }
5078 #[allow(unused)]
5079 /// Used only if an object of this type is returned as a trait impl by a method
5080 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5081         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateAddHTLC)).clone() })) as *mut c_void
5082 }
5083 #[no_mangle]
5084 /// Creates a copy of the UpdateAddHTLC
5085 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
5086         orig.clone()
5087 }
5088 /// Get a string which allows debug introspection of a UpdateAddHTLC object
5089 pub extern "C" fn UpdateAddHTLC_debug_str_void(o: *const c_void) -> Str {
5090         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateAddHTLC }).into()}
5091 /// Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC.
5092 #[no_mangle]
5093 pub extern "C" fn UpdateAddHTLC_hash(o: &UpdateAddHTLC) -> u64 {
5094         if o.inner.is_null() { return 0; }
5095         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5096         #[allow(deprecated)]
5097         let mut hasher = core::hash::SipHasher::new();
5098         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5099         core::hash::Hasher::finish(&hasher)
5100 }
5101 /// Checks if two UpdateAddHTLCs contain equal inner contents.
5102 /// This ignores pointers and is_owned flags and looks at the values in fields.
5103 /// Two objects with NULL inner values will be considered "equal" here.
5104 #[no_mangle]
5105 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
5106         if a.inner == b.inner { return true; }
5107         if a.inner.is_null() || b.inner.is_null() { return false; }
5108         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5109 }
5110
5111 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
5112 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
5113
5114 /// An onion message to be sent to or received from a peer.
5115 ///
5116 #[must_use]
5117 #[repr(C)]
5118 pub struct OnionMessage {
5119         /// A pointer to the opaque Rust object.
5120
5121         /// Nearly everywhere, inner must be non-null, however in places where
5122         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5123         pub inner: *mut nativeOnionMessage,
5124         /// Indicates that this is the only struct which contains the same pointer.
5125
5126         /// Rust functions which take ownership of an object provided via an argument require
5127         /// this to be true and invalidate the object pointed to by inner.
5128         pub is_owned: bool,
5129 }
5130
5131 impl Drop for OnionMessage {
5132         fn drop(&mut self) {
5133                 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
5134                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5135                 }
5136         }
5137 }
5138 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
5139 #[no_mangle]
5140 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
5141 #[allow(unused)]
5142 /// Used only if an object of this type is returned as a trait impl by a method
5143 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
5144         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
5145 }
5146 #[allow(unused)]
5147 impl OnionMessage {
5148         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
5149                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5150         }
5151         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
5152                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5153         }
5154         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5155         pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
5156                 assert!(self.is_owned);
5157                 let ret = ObjOps::untweak_ptr(self.inner);
5158                 self.inner = core::ptr::null_mut();
5159                 ret
5160         }
5161 }
5162 /// Used in decrypting the onion packet's payload.
5163 #[no_mangle]
5164 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
5165         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
5166         crate::c_types::PublicKey::from_rust(&inner_val)
5167 }
5168 /// Used in decrypting the onion packet's payload.
5169 #[no_mangle]
5170 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
5171         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
5172 }
5173 /// The full onion packet including hop data, pubkey, and hmac
5174 #[no_mangle]
5175 pub extern "C" fn OnionMessage_get_onion_routing_packet(this_ptr: &OnionMessage) -> crate::lightning::onion_message::packet::Packet {
5176         let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
5177         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 }
5178 }
5179 /// The full onion packet including hop data, pubkey, and hmac
5180 #[no_mangle]
5181 pub extern "C" fn OnionMessage_set_onion_routing_packet(this_ptr: &mut OnionMessage, mut val: crate::lightning::onion_message::packet::Packet) {
5182         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
5183 }
5184 /// Constructs a new OnionMessage given each field
5185 #[must_use]
5186 #[no_mangle]
5187 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 {
5188         OnionMessage { inner: ObjOps::heap_alloc(nativeOnionMessage {
5189                 blinding_point: blinding_point_arg.into_rust(),
5190                 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
5191         }), is_owned: true }
5192 }
5193 impl Clone for OnionMessage {
5194         fn clone(&self) -> Self {
5195                 Self {
5196                         inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
5197                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5198                         is_owned: true,
5199                 }
5200         }
5201 }
5202 #[allow(unused)]
5203 /// Used only if an object of this type is returned as a trait impl by a method
5204 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
5205         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionMessage)).clone() })) as *mut c_void
5206 }
5207 #[no_mangle]
5208 /// Creates a copy of the OnionMessage
5209 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
5210         orig.clone()
5211 }
5212 /// Get a string which allows debug introspection of a OnionMessage object
5213 pub extern "C" fn OnionMessage_debug_str_void(o: *const c_void) -> Str {
5214         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionMessage }).into()}
5215 /// Generates a non-cryptographic 64-bit hash of the OnionMessage.
5216 #[no_mangle]
5217 pub extern "C" fn OnionMessage_hash(o: &OnionMessage) -> u64 {
5218         if o.inner.is_null() { return 0; }
5219         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5220         #[allow(deprecated)]
5221         let mut hasher = core::hash::SipHasher::new();
5222         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5223         core::hash::Hasher::finish(&hasher)
5224 }
5225 /// Checks if two OnionMessages contain equal inner contents.
5226 /// This ignores pointers and is_owned flags and looks at the values in fields.
5227 /// Two objects with NULL inner values will be considered "equal" here.
5228 #[no_mangle]
5229 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
5230         if a.inner == b.inner { return true; }
5231         if a.inner.is_null() || b.inner.is_null() { return false; }
5232         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5233 }
5234
5235 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
5236 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
5237
5238 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
5239 ///
5240 /// [`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
5241 #[must_use]
5242 #[repr(C)]
5243 pub struct UpdateFulfillHTLC {
5244         /// A pointer to the opaque Rust object.
5245
5246         /// Nearly everywhere, inner must be non-null, however in places where
5247         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5248         pub inner: *mut nativeUpdateFulfillHTLC,
5249         /// Indicates that this is the only struct which contains the same pointer.
5250
5251         /// Rust functions which take ownership of an object provided via an argument require
5252         /// this to be true and invalidate the object pointed to by inner.
5253         pub is_owned: bool,
5254 }
5255
5256 impl Drop for UpdateFulfillHTLC {
5257         fn drop(&mut self) {
5258                 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
5259                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5260                 }
5261         }
5262 }
5263 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
5264 #[no_mangle]
5265 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
5266 #[allow(unused)]
5267 /// Used only if an object of this type is returned as a trait impl by a method
5268 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
5269         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
5270 }
5271 #[allow(unused)]
5272 impl UpdateFulfillHTLC {
5273         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
5274                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5275         }
5276         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
5277                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5278         }
5279         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5280         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
5281                 assert!(self.is_owned);
5282                 let ret = ObjOps::untweak_ptr(self.inner);
5283                 self.inner = core::ptr::null_mut();
5284                 ret
5285         }
5286 }
5287 /// The channel ID
5288 #[no_mangle]
5289 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
5290         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5291         &inner_val.0
5292 }
5293 /// The channel ID
5294 #[no_mangle]
5295 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5296         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5297 }
5298 /// The HTLC ID
5299 #[no_mangle]
5300 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
5301         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5302         *inner_val
5303 }
5304 /// The HTLC ID
5305 #[no_mangle]
5306 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
5307         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5308 }
5309 /// The pre-image of the payment hash, allowing HTLC redemption
5310 #[no_mangle]
5311 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
5312         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
5313         &inner_val.0
5314 }
5315 /// The pre-image of the payment hash, allowing HTLC redemption
5316 #[no_mangle]
5317 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5318         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
5319 }
5320 /// Constructs a new UpdateFulfillHTLC given each field
5321 #[must_use]
5322 #[no_mangle]
5323 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 {
5324         UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
5325                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5326                 htlc_id: htlc_id_arg,
5327                 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
5328         }), is_owned: true }
5329 }
5330 impl Clone for UpdateFulfillHTLC {
5331         fn clone(&self) -> Self {
5332                 Self {
5333                         inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5334                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5335                         is_owned: true,
5336                 }
5337         }
5338 }
5339 #[allow(unused)]
5340 /// Used only if an object of this type is returned as a trait impl by a method
5341 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5342         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
5343 }
5344 #[no_mangle]
5345 /// Creates a copy of the UpdateFulfillHTLC
5346 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
5347         orig.clone()
5348 }
5349 /// Get a string which allows debug introspection of a UpdateFulfillHTLC object
5350 pub extern "C" fn UpdateFulfillHTLC_debug_str_void(o: *const c_void) -> Str {
5351         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFulfillHTLC }).into()}
5352 /// Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC.
5353 #[no_mangle]
5354 pub extern "C" fn UpdateFulfillHTLC_hash(o: &UpdateFulfillHTLC) -> u64 {
5355         if o.inner.is_null() { return 0; }
5356         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5357         #[allow(deprecated)]
5358         let mut hasher = core::hash::SipHasher::new();
5359         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5360         core::hash::Hasher::finish(&hasher)
5361 }
5362 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
5363 /// This ignores pointers and is_owned flags and looks at the values in fields.
5364 /// Two objects with NULL inner values will be considered "equal" here.
5365 #[no_mangle]
5366 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
5367         if a.inner == b.inner { return true; }
5368         if a.inner.is_null() || b.inner.is_null() { return false; }
5369         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5370 }
5371
5372 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
5373 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
5374
5375 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
5376 ///
5377 /// [`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
5378 #[must_use]
5379 #[repr(C)]
5380 pub struct UpdateFailHTLC {
5381         /// A pointer to the opaque Rust object.
5382
5383         /// Nearly everywhere, inner must be non-null, however in places where
5384         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5385         pub inner: *mut nativeUpdateFailHTLC,
5386         /// Indicates that this is the only struct which contains the same pointer.
5387
5388         /// Rust functions which take ownership of an object provided via an argument require
5389         /// this to be true and invalidate the object pointed to by inner.
5390         pub is_owned: bool,
5391 }
5392
5393 impl Drop for UpdateFailHTLC {
5394         fn drop(&mut self) {
5395                 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
5396                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5397                 }
5398         }
5399 }
5400 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
5401 #[no_mangle]
5402 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
5403 #[allow(unused)]
5404 /// Used only if an object of this type is returned as a trait impl by a method
5405 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
5406         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
5407 }
5408 #[allow(unused)]
5409 impl UpdateFailHTLC {
5410         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
5411                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5412         }
5413         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
5414                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5415         }
5416         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5417         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
5418                 assert!(self.is_owned);
5419                 let ret = ObjOps::untweak_ptr(self.inner);
5420                 self.inner = core::ptr::null_mut();
5421                 ret
5422         }
5423 }
5424 /// The channel ID
5425 #[no_mangle]
5426 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
5427         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5428         &inner_val.0
5429 }
5430 /// The channel ID
5431 #[no_mangle]
5432 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5433         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5434 }
5435 /// The HTLC ID
5436 #[no_mangle]
5437 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
5438         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5439         *inner_val
5440 }
5441 /// The HTLC ID
5442 #[no_mangle]
5443 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
5444         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5445 }
5446 impl Clone for UpdateFailHTLC {
5447         fn clone(&self) -> Self {
5448                 Self {
5449                         inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5450                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5451                         is_owned: true,
5452                 }
5453         }
5454 }
5455 #[allow(unused)]
5456 /// Used only if an object of this type is returned as a trait impl by a method
5457 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5458         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailHTLC)).clone() })) as *mut c_void
5459 }
5460 #[no_mangle]
5461 /// Creates a copy of the UpdateFailHTLC
5462 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
5463         orig.clone()
5464 }
5465 /// Get a string which allows debug introspection of a UpdateFailHTLC object
5466 pub extern "C" fn UpdateFailHTLC_debug_str_void(o: *const c_void) -> Str {
5467         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailHTLC }).into()}
5468 /// Generates a non-cryptographic 64-bit hash of the UpdateFailHTLC.
5469 #[no_mangle]
5470 pub extern "C" fn UpdateFailHTLC_hash(o: &UpdateFailHTLC) -> u64 {
5471         if o.inner.is_null() { return 0; }
5472         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5473         #[allow(deprecated)]
5474         let mut hasher = core::hash::SipHasher::new();
5475         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5476         core::hash::Hasher::finish(&hasher)
5477 }
5478 /// Checks if two UpdateFailHTLCs contain equal inner contents.
5479 /// This ignores pointers and is_owned flags and looks at the values in fields.
5480 /// Two objects with NULL inner values will be considered "equal" here.
5481 #[no_mangle]
5482 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
5483         if a.inner == b.inner { return true; }
5484         if a.inner.is_null() || b.inner.is_null() { return false; }
5485         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5486 }
5487
5488 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
5489 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
5490
5491 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
5492 ///
5493 /// [`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
5494 #[must_use]
5495 #[repr(C)]
5496 pub struct UpdateFailMalformedHTLC {
5497         /// A pointer to the opaque Rust object.
5498
5499         /// Nearly everywhere, inner must be non-null, however in places where
5500         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5501         pub inner: *mut nativeUpdateFailMalformedHTLC,
5502         /// Indicates that this is the only struct which contains the same pointer.
5503
5504         /// Rust functions which take ownership of an object provided via an argument require
5505         /// this to be true and invalidate the object pointed to by inner.
5506         pub is_owned: bool,
5507 }
5508
5509 impl Drop for UpdateFailMalformedHTLC {
5510         fn drop(&mut self) {
5511                 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
5512                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5513                 }
5514         }
5515 }
5516 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
5517 #[no_mangle]
5518 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
5519 #[allow(unused)]
5520 /// Used only if an object of this type is returned as a trait impl by a method
5521 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
5522         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
5523 }
5524 #[allow(unused)]
5525 impl UpdateFailMalformedHTLC {
5526         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
5527                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5528         }
5529         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
5530                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5531         }
5532         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5533         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
5534                 assert!(self.is_owned);
5535                 let ret = ObjOps::untweak_ptr(self.inner);
5536                 self.inner = core::ptr::null_mut();
5537                 ret
5538         }
5539 }
5540 /// The channel ID
5541 #[no_mangle]
5542 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
5543         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5544         &inner_val.0
5545 }
5546 /// The channel ID
5547 #[no_mangle]
5548 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5549         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5550 }
5551 /// The HTLC ID
5552 #[no_mangle]
5553 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
5554         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5555         *inner_val
5556 }
5557 /// The HTLC ID
5558 #[no_mangle]
5559 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
5560         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5561 }
5562 /// The failure code
5563 #[no_mangle]
5564 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
5565         let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
5566         *inner_val
5567 }
5568 /// The failure code
5569 #[no_mangle]
5570 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
5571         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
5572 }
5573 impl Clone for UpdateFailMalformedHTLC {
5574         fn clone(&self) -> Self {
5575                 Self {
5576                         inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5577                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5578                         is_owned: true,
5579                 }
5580         }
5581 }
5582 #[allow(unused)]
5583 /// Used only if an object of this type is returned as a trait impl by a method
5584 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5585         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
5586 }
5587 #[no_mangle]
5588 /// Creates a copy of the UpdateFailMalformedHTLC
5589 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
5590         orig.clone()
5591 }
5592 /// Get a string which allows debug introspection of a UpdateFailMalformedHTLC object
5593 pub extern "C" fn UpdateFailMalformedHTLC_debug_str_void(o: *const c_void) -> Str {
5594         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailMalformedHTLC }).into()}
5595 /// Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC.
5596 #[no_mangle]
5597 pub extern "C" fn UpdateFailMalformedHTLC_hash(o: &UpdateFailMalformedHTLC) -> u64 {
5598         if o.inner.is_null() { return 0; }
5599         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5600         #[allow(deprecated)]
5601         let mut hasher = core::hash::SipHasher::new();
5602         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5603         core::hash::Hasher::finish(&hasher)
5604 }
5605 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
5606 /// This ignores pointers and is_owned flags and looks at the values in fields.
5607 /// Two objects with NULL inner values will be considered "equal" here.
5608 #[no_mangle]
5609 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
5610         if a.inner == b.inner { return true; }
5611         if a.inner.is_null() || b.inner.is_null() { return false; }
5612         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5613 }
5614
5615 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
5616 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
5617
5618 /// A [`commitment_signed`] message to be sent to or received from a peer.
5619 ///
5620 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
5621 #[must_use]
5622 #[repr(C)]
5623 pub struct CommitmentSigned {
5624         /// A pointer to the opaque Rust object.
5625
5626         /// Nearly everywhere, inner must be non-null, however in places where
5627         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5628         pub inner: *mut nativeCommitmentSigned,
5629         /// Indicates that this is the only struct which contains the same pointer.
5630
5631         /// Rust functions which take ownership of an object provided via an argument require
5632         /// this to be true and invalidate the object pointed to by inner.
5633         pub is_owned: bool,
5634 }
5635
5636 impl Drop for CommitmentSigned {
5637         fn drop(&mut self) {
5638                 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
5639                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5640                 }
5641         }
5642 }
5643 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
5644 #[no_mangle]
5645 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
5646 #[allow(unused)]
5647 /// Used only if an object of this type is returned as a trait impl by a method
5648 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
5649         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
5650 }
5651 #[allow(unused)]
5652 impl CommitmentSigned {
5653         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
5654                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5655         }
5656         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
5657                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5658         }
5659         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5660         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
5661                 assert!(self.is_owned);
5662                 let ret = ObjOps::untweak_ptr(self.inner);
5663                 self.inner = core::ptr::null_mut();
5664                 ret
5665         }
5666 }
5667 /// The channel ID
5668 #[no_mangle]
5669 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
5670         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5671         &inner_val.0
5672 }
5673 /// The channel ID
5674 #[no_mangle]
5675 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
5676         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5677 }
5678 /// A signature on the commitment transaction
5679 #[no_mangle]
5680 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::ECDSASignature {
5681         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
5682         crate::c_types::ECDSASignature::from_rust(&inner_val)
5683 }
5684 /// A signature on the commitment transaction
5685 #[no_mangle]
5686 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ECDSASignature) {
5687         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
5688 }
5689 /// Signatures on the HTLC transactions
5690 ///
5691 /// Returns a copy of the field.
5692 #[no_mangle]
5693 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_ECDSASignatureZ {
5694         let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
5695         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) }); };
5696         local_inner_val.into()
5697 }
5698 /// Signatures on the HTLC transactions
5699 #[no_mangle]
5700 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_ECDSASignatureZ) {
5701         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
5702         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
5703 }
5704 /// Constructs a new CommitmentSigned given each field
5705 #[must_use]
5706 #[no_mangle]
5707 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 {
5708         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() }); };
5709         CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
5710                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5711                 signature: signature_arg.into_rust(),
5712                 htlc_signatures: local_htlc_signatures_arg,
5713         }), is_owned: true }
5714 }
5715 impl Clone for CommitmentSigned {
5716         fn clone(&self) -> Self {
5717                 Self {
5718                         inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
5719                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5720                         is_owned: true,
5721                 }
5722         }
5723 }
5724 #[allow(unused)]
5725 /// Used only if an object of this type is returned as a trait impl by a method
5726 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
5727         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentSigned)).clone() })) as *mut c_void
5728 }
5729 #[no_mangle]
5730 /// Creates a copy of the CommitmentSigned
5731 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
5732         orig.clone()
5733 }
5734 /// Get a string which allows debug introspection of a CommitmentSigned object
5735 pub extern "C" fn CommitmentSigned_debug_str_void(o: *const c_void) -> Str {
5736         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentSigned }).into()}
5737 /// Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
5738 #[no_mangle]
5739 pub extern "C" fn CommitmentSigned_hash(o: &CommitmentSigned) -> u64 {
5740         if o.inner.is_null() { return 0; }
5741         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5742         #[allow(deprecated)]
5743         let mut hasher = core::hash::SipHasher::new();
5744         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5745         core::hash::Hasher::finish(&hasher)
5746 }
5747 /// Checks if two CommitmentSigneds contain equal inner contents.
5748 /// This ignores pointers and is_owned flags and looks at the values in fields.
5749 /// Two objects with NULL inner values will be considered "equal" here.
5750 #[no_mangle]
5751 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
5752         if a.inner == b.inner { return true; }
5753         if a.inner.is_null() || b.inner.is_null() { return false; }
5754         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5755 }
5756
5757 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
5758 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
5759
5760 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
5761 ///
5762 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
5763 #[must_use]
5764 #[repr(C)]
5765 pub struct RevokeAndACK {
5766         /// A pointer to the opaque Rust object.
5767
5768         /// Nearly everywhere, inner must be non-null, however in places where
5769         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5770         pub inner: *mut nativeRevokeAndACK,
5771         /// Indicates that this is the only struct which contains the same pointer.
5772
5773         /// Rust functions which take ownership of an object provided via an argument require
5774         /// this to be true and invalidate the object pointed to by inner.
5775         pub is_owned: bool,
5776 }
5777
5778 impl Drop for RevokeAndACK {
5779         fn drop(&mut self) {
5780                 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
5781                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5782                 }
5783         }
5784 }
5785 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
5786 #[no_mangle]
5787 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
5788 #[allow(unused)]
5789 /// Used only if an object of this type is returned as a trait impl by a method
5790 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
5791         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
5792 }
5793 #[allow(unused)]
5794 impl RevokeAndACK {
5795         pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
5796                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5797         }
5798         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
5799                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5800         }
5801         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5802         pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
5803                 assert!(self.is_owned);
5804                 let ret = ObjOps::untweak_ptr(self.inner);
5805                 self.inner = core::ptr::null_mut();
5806                 ret
5807         }
5808 }
5809 /// The channel ID
5810 #[no_mangle]
5811 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
5812         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5813         &inner_val.0
5814 }
5815 /// The channel ID
5816 #[no_mangle]
5817 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
5818         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5819 }
5820 /// The secret corresponding to the per-commitment point
5821 #[no_mangle]
5822 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
5823         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
5824         inner_val
5825 }
5826 /// The secret corresponding to the per-commitment point
5827 #[no_mangle]
5828 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
5829         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
5830 }
5831 /// The next sender-broadcast commitment transaction's per-commitment point
5832 #[no_mangle]
5833 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
5834         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
5835         crate::c_types::PublicKey::from_rust(&inner_val)
5836 }
5837 /// The next sender-broadcast commitment transaction's per-commitment point
5838 #[no_mangle]
5839 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
5840         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
5841 }
5842 /// Constructs a new RevokeAndACK given each field
5843 #[must_use]
5844 #[no_mangle]
5845 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 {
5846         RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
5847                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5848                 per_commitment_secret: per_commitment_secret_arg.data,
5849                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
5850         }), is_owned: true }
5851 }
5852 impl Clone for RevokeAndACK {
5853         fn clone(&self) -> Self {
5854                 Self {
5855                         inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
5856                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5857                         is_owned: true,
5858                 }
5859         }
5860 }
5861 #[allow(unused)]
5862 /// Used only if an object of this type is returned as a trait impl by a method
5863 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
5864         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRevokeAndACK)).clone() })) as *mut c_void
5865 }
5866 #[no_mangle]
5867 /// Creates a copy of the RevokeAndACK
5868 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
5869         orig.clone()
5870 }
5871 /// Get a string which allows debug introspection of a RevokeAndACK object
5872 pub extern "C" fn RevokeAndACK_debug_str_void(o: *const c_void) -> Str {
5873         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::RevokeAndACK }).into()}
5874 /// Generates a non-cryptographic 64-bit hash of the RevokeAndACK.
5875 #[no_mangle]
5876 pub extern "C" fn RevokeAndACK_hash(o: &RevokeAndACK) -> u64 {
5877         if o.inner.is_null() { return 0; }
5878         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5879         #[allow(deprecated)]
5880         let mut hasher = core::hash::SipHasher::new();
5881         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5882         core::hash::Hasher::finish(&hasher)
5883 }
5884 /// Checks if two RevokeAndACKs contain equal inner contents.
5885 /// This ignores pointers and is_owned flags and looks at the values in fields.
5886 /// Two objects with NULL inner values will be considered "equal" here.
5887 #[no_mangle]
5888 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
5889         if a.inner == b.inner { return true; }
5890         if a.inner.is_null() || b.inner.is_null() { return false; }
5891         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5892 }
5893
5894 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
5895 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
5896
5897 /// An [`update_fee`] message to be sent to or received from a peer
5898 ///
5899 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
5900 #[must_use]
5901 #[repr(C)]
5902 pub struct UpdateFee {
5903         /// A pointer to the opaque Rust object.
5904
5905         /// Nearly everywhere, inner must be non-null, however in places where
5906         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5907         pub inner: *mut nativeUpdateFee,
5908         /// Indicates that this is the only struct which contains the same pointer.
5909
5910         /// Rust functions which take ownership of an object provided via an argument require
5911         /// this to be true and invalidate the object pointed to by inner.
5912         pub is_owned: bool,
5913 }
5914
5915 impl Drop for UpdateFee {
5916         fn drop(&mut self) {
5917                 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
5918                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5919                 }
5920         }
5921 }
5922 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
5923 #[no_mangle]
5924 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
5925 #[allow(unused)]
5926 /// Used only if an object of this type is returned as a trait impl by a method
5927 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
5928         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
5929 }
5930 #[allow(unused)]
5931 impl UpdateFee {
5932         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
5933                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5934         }
5935         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
5936                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5937         }
5938         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5939         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
5940                 assert!(self.is_owned);
5941                 let ret = ObjOps::untweak_ptr(self.inner);
5942                 self.inner = core::ptr::null_mut();
5943                 ret
5944         }
5945 }
5946 /// The channel ID
5947 #[no_mangle]
5948 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
5949         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5950         &inner_val.0
5951 }
5952 /// The channel ID
5953 #[no_mangle]
5954 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
5955         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5956 }
5957 /// Fee rate per 1000-weight of the transaction
5958 #[no_mangle]
5959 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
5960         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
5961         *inner_val
5962 }
5963 /// Fee rate per 1000-weight of the transaction
5964 #[no_mangle]
5965 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
5966         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
5967 }
5968 /// Constructs a new UpdateFee given each field
5969 #[must_use]
5970 #[no_mangle]
5971 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
5972         UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
5973                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5974                 feerate_per_kw: feerate_per_kw_arg,
5975         }), is_owned: true }
5976 }
5977 impl Clone for UpdateFee {
5978         fn clone(&self) -> Self {
5979                 Self {
5980                         inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
5981                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5982                         is_owned: true,
5983                 }
5984         }
5985 }
5986 #[allow(unused)]
5987 /// Used only if an object of this type is returned as a trait impl by a method
5988 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
5989         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFee)).clone() })) as *mut c_void
5990 }
5991 #[no_mangle]
5992 /// Creates a copy of the UpdateFee
5993 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
5994         orig.clone()
5995 }
5996 /// Get a string which allows debug introspection of a UpdateFee object
5997 pub extern "C" fn UpdateFee_debug_str_void(o: *const c_void) -> Str {
5998         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFee }).into()}
5999 /// Generates a non-cryptographic 64-bit hash of the UpdateFee.
6000 #[no_mangle]
6001 pub extern "C" fn UpdateFee_hash(o: &UpdateFee) -> u64 {
6002         if o.inner.is_null() { return 0; }
6003         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6004         #[allow(deprecated)]
6005         let mut hasher = core::hash::SipHasher::new();
6006         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6007         core::hash::Hasher::finish(&hasher)
6008 }
6009 /// Checks if two UpdateFees contain equal inner contents.
6010 /// This ignores pointers and is_owned flags and looks at the values in fields.
6011 /// Two objects with NULL inner values will be considered "equal" here.
6012 #[no_mangle]
6013 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
6014         if a.inner == b.inner { return true; }
6015         if a.inner.is_null() || b.inner.is_null() { return false; }
6016         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6017 }
6018
6019 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
6020 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
6021
6022 /// A [`channel_reestablish`] message to be sent to or received from a peer.
6023 ///
6024 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
6025 #[must_use]
6026 #[repr(C)]
6027 pub struct ChannelReestablish {
6028         /// A pointer to the opaque Rust object.
6029
6030         /// Nearly everywhere, inner must be non-null, however in places where
6031         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6032         pub inner: *mut nativeChannelReestablish,
6033         /// Indicates that this is the only struct which contains the same pointer.
6034
6035         /// Rust functions which take ownership of an object provided via an argument require
6036         /// this to be true and invalidate the object pointed to by inner.
6037         pub is_owned: bool,
6038 }
6039
6040 impl Drop for ChannelReestablish {
6041         fn drop(&mut self) {
6042                 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
6043                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6044                 }
6045         }
6046 }
6047 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
6048 #[no_mangle]
6049 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
6050 #[allow(unused)]
6051 /// Used only if an object of this type is returned as a trait impl by a method
6052 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
6053         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
6054 }
6055 #[allow(unused)]
6056 impl ChannelReestablish {
6057         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
6058                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6059         }
6060         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
6061                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6062         }
6063         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6064         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
6065                 assert!(self.is_owned);
6066                 let ret = ObjOps::untweak_ptr(self.inner);
6067                 self.inner = core::ptr::null_mut();
6068                 ret
6069         }
6070 }
6071 /// The channel ID
6072 #[no_mangle]
6073 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
6074         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
6075         &inner_val.0
6076 }
6077 /// The channel ID
6078 #[no_mangle]
6079 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
6080         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
6081 }
6082 /// The next commitment number for the sender
6083 #[no_mangle]
6084 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
6085         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
6086         *inner_val
6087 }
6088 /// The next commitment number for the sender
6089 #[no_mangle]
6090 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
6091         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
6092 }
6093 /// The next commitment number for the recipient
6094 #[no_mangle]
6095 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
6096         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
6097         *inner_val
6098 }
6099 /// The next commitment number for the recipient
6100 #[no_mangle]
6101 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
6102         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
6103 }
6104 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
6105 /// belonging to the recipient
6106 #[no_mangle]
6107 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
6108         let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
6109         inner_val
6110 }
6111 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
6112 /// belonging to the recipient
6113 #[no_mangle]
6114 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
6115         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
6116 }
6117 /// The sender's per-commitment point for their current commitment transaction
6118 #[no_mangle]
6119 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
6120         let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
6121         crate::c_types::PublicKey::from_rust(&inner_val)
6122 }
6123 /// The sender's per-commitment point for their current commitment transaction
6124 #[no_mangle]
6125 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
6126         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
6127 }
6128 /// The next funding transaction ID
6129 #[no_mangle]
6130 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
6131         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
6132         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().as_ref() } }) };
6133         local_inner_val
6134 }
6135 /// The next funding transaction ID
6136 #[no_mangle]
6137 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
6138         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() }})} };
6139         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
6140 }
6141 /// Constructs a new ChannelReestablish given each field
6142 #[must_use]
6143 #[no_mangle]
6144 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 {
6145         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() }})} };
6146         ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
6147                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
6148                 next_local_commitment_number: next_local_commitment_number_arg,
6149                 next_remote_commitment_number: next_remote_commitment_number_arg,
6150                 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
6151                 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
6152                 next_funding_txid: local_next_funding_txid_arg,
6153         }), is_owned: true }
6154 }
6155 impl Clone for ChannelReestablish {
6156         fn clone(&self) -> Self {
6157                 Self {
6158                         inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
6159                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6160                         is_owned: true,
6161                 }
6162         }
6163 }
6164 #[allow(unused)]
6165 /// Used only if an object of this type is returned as a trait impl by a method
6166 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
6167         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReestablish)).clone() })) as *mut c_void
6168 }
6169 #[no_mangle]
6170 /// Creates a copy of the ChannelReestablish
6171 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
6172         orig.clone()
6173 }
6174 /// Get a string which allows debug introspection of a ChannelReestablish object
6175 pub extern "C" fn ChannelReestablish_debug_str_void(o: *const c_void) -> Str {
6176         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelReestablish }).into()}
6177 /// Generates a non-cryptographic 64-bit hash of the ChannelReestablish.
6178 #[no_mangle]
6179 pub extern "C" fn ChannelReestablish_hash(o: &ChannelReestablish) -> u64 {
6180         if o.inner.is_null() { return 0; }
6181         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6182         #[allow(deprecated)]
6183         let mut hasher = core::hash::SipHasher::new();
6184         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6185         core::hash::Hasher::finish(&hasher)
6186 }
6187 /// Checks if two ChannelReestablishs contain equal inner contents.
6188 /// This ignores pointers and is_owned flags and looks at the values in fields.
6189 /// Two objects with NULL inner values will be considered "equal" here.
6190 #[no_mangle]
6191 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
6192         if a.inner == b.inner { return true; }
6193         if a.inner.is_null() || b.inner.is_null() { return false; }
6194         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6195 }
6196
6197 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
6198 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
6199
6200 /// An [`announcement_signatures`] message to be sent to or received from a peer.
6201 ///
6202 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
6203 #[must_use]
6204 #[repr(C)]
6205 pub struct AnnouncementSignatures {
6206         /// A pointer to the opaque Rust object.
6207
6208         /// Nearly everywhere, inner must be non-null, however in places where
6209         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6210         pub inner: *mut nativeAnnouncementSignatures,
6211         /// Indicates that this is the only struct which contains the same pointer.
6212
6213         /// Rust functions which take ownership of an object provided via an argument require
6214         /// this to be true and invalidate the object pointed to by inner.
6215         pub is_owned: bool,
6216 }
6217
6218 impl Drop for AnnouncementSignatures {
6219         fn drop(&mut self) {
6220                 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
6221                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6222                 }
6223         }
6224 }
6225 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
6226 #[no_mangle]
6227 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
6228 #[allow(unused)]
6229 /// Used only if an object of this type is returned as a trait impl by a method
6230 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
6231         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
6232 }
6233 #[allow(unused)]
6234 impl AnnouncementSignatures {
6235         pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
6236                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6237         }
6238         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
6239                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6240         }
6241         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6242         pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
6243                 assert!(self.is_owned);
6244                 let ret = ObjOps::untweak_ptr(self.inner);
6245                 self.inner = core::ptr::null_mut();
6246                 ret
6247         }
6248 }
6249 /// The channel ID
6250 #[no_mangle]
6251 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
6252         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
6253         &inner_val.0
6254 }
6255 /// The channel ID
6256 #[no_mangle]
6257 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
6258         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
6259 }
6260 /// The short channel ID
6261 #[no_mangle]
6262 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
6263         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6264         *inner_val
6265 }
6266 /// The short channel ID
6267 #[no_mangle]
6268 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
6269         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6270 }
6271 /// A signature by the node key
6272 #[no_mangle]
6273 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
6274         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
6275         crate::c_types::ECDSASignature::from_rust(&inner_val)
6276 }
6277 /// A signature by the node key
6278 #[no_mangle]
6279 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
6280         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
6281 }
6282 /// A signature by the funding key
6283 #[no_mangle]
6284 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
6285         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
6286         crate::c_types::ECDSASignature::from_rust(&inner_val)
6287 }
6288 /// A signature by the funding key
6289 #[no_mangle]
6290 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
6291         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
6292 }
6293 /// Constructs a new AnnouncementSignatures given each field
6294 #[must_use]
6295 #[no_mangle]
6296 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 {
6297         AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
6298                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
6299                 short_channel_id: short_channel_id_arg,
6300                 node_signature: node_signature_arg.into_rust(),
6301                 bitcoin_signature: bitcoin_signature_arg.into_rust(),
6302         }), is_owned: true }
6303 }
6304 impl Clone for AnnouncementSignatures {
6305         fn clone(&self) -> Self {
6306                 Self {
6307                         inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
6308                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6309                         is_owned: true,
6310                 }
6311         }
6312 }
6313 #[allow(unused)]
6314 /// Used only if an object of this type is returned as a trait impl by a method
6315 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
6316         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAnnouncementSignatures)).clone() })) as *mut c_void
6317 }
6318 #[no_mangle]
6319 /// Creates a copy of the AnnouncementSignatures
6320 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
6321         orig.clone()
6322 }
6323 /// Get a string which allows debug introspection of a AnnouncementSignatures object
6324 pub extern "C" fn AnnouncementSignatures_debug_str_void(o: *const c_void) -> Str {
6325         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AnnouncementSignatures }).into()}
6326 /// Generates a non-cryptographic 64-bit hash of the AnnouncementSignatures.
6327 #[no_mangle]
6328 pub extern "C" fn AnnouncementSignatures_hash(o: &AnnouncementSignatures) -> u64 {
6329         if o.inner.is_null() { return 0; }
6330         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6331         #[allow(deprecated)]
6332         let mut hasher = core::hash::SipHasher::new();
6333         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6334         core::hash::Hasher::finish(&hasher)
6335 }
6336 /// Checks if two AnnouncementSignaturess contain equal inner contents.
6337 /// This ignores pointers and is_owned flags and looks at the values in fields.
6338 /// Two objects with NULL inner values will be considered "equal" here.
6339 #[no_mangle]
6340 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
6341         if a.inner == b.inner { return true; }
6342         if a.inner.is_null() || b.inner.is_null() { return false; }
6343         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6344 }
6345 /// An address which can be used to connect to a remote peer.
6346 #[derive(Clone)]
6347 #[must_use]
6348 #[repr(C)]
6349 pub enum SocketAddress {
6350         /// An IPv4 address and port on which the peer is listening.
6351         TcpIpV4 {
6352                 /// The 4-byte IPv4 address
6353                 addr: crate::c_types::FourBytes,
6354                 /// The port on which the node is listening
6355                 port: u16,
6356         },
6357         /// An IPv6 address and port on which the peer is listening.
6358         TcpIpV6 {
6359                 /// The 16-byte IPv6 address
6360                 addr: crate::c_types::SixteenBytes,
6361                 /// The port on which the node is listening
6362                 port: u16,
6363         },
6364         /// An old-style Tor onion address/port on which the peer is listening.
6365         ///
6366         /// This field is deprecated and the Tor network generally no longer supports V2 Onion
6367         /// addresses. Thus, the details are not parsed here.
6368         OnionV2(
6369                 crate::c_types::TwelveBytes),
6370         /// A new-style Tor onion address/port on which the peer is listening.
6371         ///
6372         /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
6373         /// wrap as base32 and append \".onion\".
6374         OnionV3 {
6375                 /// The ed25519 long-term public key of the peer
6376                 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
6377                 /// The checksum of the pubkey and version, as included in the onion address
6378                 checksum: u16,
6379                 /// The version byte, as defined by the Tor Onion v3 spec.
6380                 version: u8,
6381                 /// The port on which the node is listening
6382                 port: u16,
6383         },
6384         /// A hostname/port on which the peer is listening.
6385         Hostname {
6386                 /// The hostname on which the node is listening.
6387                 hostname: crate::lightning::util::ser::Hostname,
6388                 /// The port on which the node is listening.
6389                 port: u16,
6390         },
6391 }
6392 use lightning::ln::msgs::SocketAddress as SocketAddressImport;
6393 pub(crate) type nativeSocketAddress = SocketAddressImport;
6394
6395 impl SocketAddress {
6396         #[allow(unused)]
6397         pub(crate) fn to_native(&self) -> nativeSocketAddress {
6398                 match self {
6399                         SocketAddress::TcpIpV4 {ref addr, ref port, } => {
6400                                 let mut addr_nonref = Clone::clone(addr);
6401                                 let mut port_nonref = Clone::clone(port);
6402                                 nativeSocketAddress::TcpIpV4 {
6403                                         addr: addr_nonref.data,
6404                                         port: port_nonref,
6405                                 }
6406                         },
6407                         SocketAddress::TcpIpV6 {ref addr, ref port, } => {
6408                                 let mut addr_nonref = Clone::clone(addr);
6409                                 let mut port_nonref = Clone::clone(port);
6410                                 nativeSocketAddress::TcpIpV6 {
6411                                         addr: addr_nonref.data,
6412                                         port: port_nonref,
6413                                 }
6414                         },
6415                         SocketAddress::OnionV2 (ref a, ) => {
6416                                 let mut a_nonref = Clone::clone(a);
6417                                 nativeSocketAddress::OnionV2 (
6418                                         a_nonref.data,
6419                                 )
6420                         },
6421                         SocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
6422                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
6423                                 let mut checksum_nonref = Clone::clone(checksum);
6424                                 let mut version_nonref = Clone::clone(version);
6425                                 let mut port_nonref = Clone::clone(port);
6426                                 nativeSocketAddress::OnionV3 {
6427                                         ed25519_pubkey: ed25519_pubkey_nonref.data,
6428                                         checksum: checksum_nonref,
6429                                         version: version_nonref,
6430                                         port: port_nonref,
6431                                 }
6432                         },
6433                         SocketAddress::Hostname {ref hostname, ref port, } => {
6434                                 let mut hostname_nonref = Clone::clone(hostname);
6435                                 let mut port_nonref = Clone::clone(port);
6436                                 nativeSocketAddress::Hostname {
6437                                         hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
6438                                         port: port_nonref,
6439                                 }
6440                         },
6441                 }
6442         }
6443         #[allow(unused)]
6444         pub(crate) fn into_native(self) -> nativeSocketAddress {
6445                 match self {
6446                         SocketAddress::TcpIpV4 {mut addr, mut port, } => {
6447                                 nativeSocketAddress::TcpIpV4 {
6448                                         addr: addr.data,
6449                                         port: port,
6450                                 }
6451                         },
6452                         SocketAddress::TcpIpV6 {mut addr, mut port, } => {
6453                                 nativeSocketAddress::TcpIpV6 {
6454                                         addr: addr.data,
6455                                         port: port,
6456                                 }
6457                         },
6458                         SocketAddress::OnionV2 (mut a, ) => {
6459                                 nativeSocketAddress::OnionV2 (
6460                                         a.data,
6461                                 )
6462                         },
6463                         SocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
6464                                 nativeSocketAddress::OnionV3 {
6465                                         ed25519_pubkey: ed25519_pubkey.data,
6466                                         checksum: checksum,
6467                                         version: version,
6468                                         port: port,
6469                                 }
6470                         },
6471                         SocketAddress::Hostname {mut hostname, mut port, } => {
6472                                 nativeSocketAddress::Hostname {
6473                                         hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
6474                                         port: port,
6475                                 }
6476                         },
6477                 }
6478         }
6479         #[allow(unused)]
6480         pub(crate) fn from_native(native: &SocketAddressImport) -> Self {
6481                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSocketAddress) };
6482                 match native {
6483                         nativeSocketAddress::TcpIpV4 {ref addr, ref port, } => {
6484                                 let mut addr_nonref = Clone::clone(addr);
6485                                 let mut port_nonref = Clone::clone(port);
6486                                 SocketAddress::TcpIpV4 {
6487                                         addr: crate::c_types::FourBytes { data: addr_nonref },
6488                                         port: port_nonref,
6489                                 }
6490                         },
6491                         nativeSocketAddress::TcpIpV6 {ref addr, ref port, } => {
6492                                 let mut addr_nonref = Clone::clone(addr);
6493                                 let mut port_nonref = Clone::clone(port);
6494                                 SocketAddress::TcpIpV6 {
6495                                         addr: crate::c_types::SixteenBytes { data: addr_nonref },
6496                                         port: port_nonref,
6497                                 }
6498                         },
6499                         nativeSocketAddress::OnionV2 (ref a, ) => {
6500                                 let mut a_nonref = Clone::clone(a);
6501                                 SocketAddress::OnionV2 (
6502                                         crate::c_types::TwelveBytes { data: a_nonref },
6503                                 )
6504                         },
6505                         nativeSocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
6506                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
6507                                 let mut checksum_nonref = Clone::clone(checksum);
6508                                 let mut version_nonref = Clone::clone(version);
6509                                 let mut port_nonref = Clone::clone(port);
6510                                 SocketAddress::OnionV3 {
6511                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
6512                                         checksum: checksum_nonref,
6513                                         version: version_nonref,
6514                                         port: port_nonref,
6515                                 }
6516                         },
6517                         nativeSocketAddress::Hostname {ref hostname, ref port, } => {
6518                                 let mut hostname_nonref = Clone::clone(hostname);
6519                                 let mut port_nonref = Clone::clone(port);
6520                                 SocketAddress::Hostname {
6521                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
6522                                         port: port_nonref,
6523                                 }
6524                         },
6525                 }
6526         }
6527         #[allow(unused)]
6528         pub(crate) fn native_into(native: nativeSocketAddress) -> Self {
6529                 match native {
6530                         nativeSocketAddress::TcpIpV4 {mut addr, mut port, } => {
6531                                 SocketAddress::TcpIpV4 {
6532                                         addr: crate::c_types::FourBytes { data: addr },
6533                                         port: port,
6534                                 }
6535                         },
6536                         nativeSocketAddress::TcpIpV6 {mut addr, mut port, } => {
6537                                 SocketAddress::TcpIpV6 {
6538                                         addr: crate::c_types::SixteenBytes { data: addr },
6539                                         port: port,
6540                                 }
6541                         },
6542                         nativeSocketAddress::OnionV2 (mut a, ) => {
6543                                 SocketAddress::OnionV2 (
6544                                         crate::c_types::TwelveBytes { data: a },
6545                                 )
6546                         },
6547                         nativeSocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
6548                                 SocketAddress::OnionV3 {
6549                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
6550                                         checksum: checksum,
6551                                         version: version,
6552                                         port: port,
6553                                 }
6554                         },
6555                         nativeSocketAddress::Hostname {mut hostname, mut port, } => {
6556                                 SocketAddress::Hostname {
6557                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
6558                                         port: port,
6559                                 }
6560                         },
6561                 }
6562         }
6563 }
6564 /// Frees any resources used by the SocketAddress
6565 #[no_mangle]
6566 pub extern "C" fn SocketAddress_free(this_ptr: SocketAddress) { }
6567 /// Creates a copy of the SocketAddress
6568 #[no_mangle]
6569 pub extern "C" fn SocketAddress_clone(orig: &SocketAddress) -> SocketAddress {
6570         orig.clone()
6571 }
6572 #[allow(unused)]
6573 /// Used only if an object of this type is returned as a trait impl by a method
6574 pub(crate) extern "C" fn SocketAddress_clone_void(this_ptr: *const c_void) -> *mut c_void {
6575         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddress)).clone() })) as *mut c_void
6576 }
6577 #[allow(unused)]
6578 /// Used only if an object of this type is returned as a trait impl by a method
6579 pub(crate) extern "C" fn SocketAddress_free_void(this_ptr: *mut c_void) {
6580         let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddress) };
6581 }
6582 #[no_mangle]
6583 /// Utility method to constructs a new TcpIpV4-variant SocketAddress
6584 pub extern "C" fn SocketAddress_tcp_ip_v4(addr: crate::c_types::FourBytes, port: u16) -> SocketAddress {
6585         SocketAddress::TcpIpV4 {
6586                 addr,
6587                 port,
6588         }
6589 }
6590 #[no_mangle]
6591 /// Utility method to constructs a new TcpIpV6-variant SocketAddress
6592 pub extern "C" fn SocketAddress_tcp_ip_v6(addr: crate::c_types::SixteenBytes, port: u16) -> SocketAddress {
6593         SocketAddress::TcpIpV6 {
6594                 addr,
6595                 port,
6596         }
6597 }
6598 #[no_mangle]
6599 /// Utility method to constructs a new OnionV2-variant SocketAddress
6600 pub extern "C" fn SocketAddress_onion_v2(a: crate::c_types::TwelveBytes) -> SocketAddress {
6601         SocketAddress::OnionV2(a, )
6602 }
6603 #[no_mangle]
6604 /// Utility method to constructs a new OnionV3-variant SocketAddress
6605 pub extern "C" fn SocketAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> SocketAddress {
6606         SocketAddress::OnionV3 {
6607                 ed25519_pubkey,
6608                 checksum,
6609                 version,
6610                 port,
6611         }
6612 }
6613 #[no_mangle]
6614 /// Utility method to constructs a new Hostname-variant SocketAddress
6615 pub extern "C" fn SocketAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> SocketAddress {
6616         SocketAddress::Hostname {
6617                 hostname,
6618                 port,
6619         }
6620 }
6621 /// Get a string which allows debug introspection of a SocketAddress object
6622 pub extern "C" fn SocketAddress_debug_str_void(o: *const c_void) -> Str {
6623         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SocketAddress }).into()}
6624 /// Generates a non-cryptographic 64-bit hash of the SocketAddress.
6625 #[no_mangle]
6626 pub extern "C" fn SocketAddress_hash(o: &SocketAddress) -> u64 {
6627         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6628         #[allow(deprecated)]
6629         let mut hasher = core::hash::SipHasher::new();
6630         core::hash::Hash::hash(&o.to_native(), &mut hasher);
6631         core::hash::Hasher::finish(&hasher)
6632 }
6633 /// Checks if two SocketAddresss contain equal inner contents.
6634 /// This ignores pointers and is_owned flags and looks at the values in fields.
6635 #[no_mangle]
6636 pub extern "C" fn SocketAddress_eq(a: &SocketAddress, b: &SocketAddress) -> bool {
6637         if &a.to_native() == &b.to_native() { true } else { false }
6638 }
6639 #[no_mangle]
6640 /// Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read
6641 pub extern "C" fn SocketAddress_write(obj: &crate::lightning::ln::msgs::SocketAddress) -> crate::c_types::derived::CVec_u8Z {
6642         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6643 }
6644 #[allow(unused)]
6645 pub(crate) extern "C" fn SocketAddress_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6646         SocketAddress_write(unsafe { &*(obj as *const SocketAddress) })
6647 }
6648 #[no_mangle]
6649 /// Read a SocketAddress from a byte array, created by SocketAddress_write
6650 pub extern "C" fn SocketAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SocketAddressDecodeErrorZ {
6651         let res: Result<lightning::ln::msgs::SocketAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6652         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() };
6653         local_res
6654 }
6655 /// [`SocketAddress`] error variants
6656 #[derive(Clone)]
6657 #[must_use]
6658 #[repr(C)]
6659 pub enum SocketAddressParseError {
6660         /// Socket address (IPv4/IPv6) parsing error
6661         SocketAddrParse,
6662         /// Invalid input format
6663         InvalidInput,
6664         /// Invalid port
6665         InvalidPort,
6666         /// Invalid onion v3 address
6667         InvalidOnionV3,
6668 }
6669 use lightning::ln::msgs::SocketAddressParseError as SocketAddressParseErrorImport;
6670 pub(crate) type nativeSocketAddressParseError = SocketAddressParseErrorImport;
6671
6672 impl SocketAddressParseError {
6673         #[allow(unused)]
6674         pub(crate) fn to_native(&self) -> nativeSocketAddressParseError {
6675                 match self {
6676                         SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
6677                         SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
6678                         SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
6679                         SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
6680                 }
6681         }
6682         #[allow(unused)]
6683         pub(crate) fn into_native(self) -> nativeSocketAddressParseError {
6684                 match self {
6685                         SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
6686                         SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
6687                         SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
6688                         SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
6689                 }
6690         }
6691         #[allow(unused)]
6692         pub(crate) fn from_native(native: &SocketAddressParseErrorImport) -> Self {
6693                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSocketAddressParseError) };
6694                 match native {
6695                         nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
6696                         nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
6697                         nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
6698                         nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
6699                 }
6700         }
6701         #[allow(unused)]
6702         pub(crate) fn native_into(native: nativeSocketAddressParseError) -> Self {
6703                 match native {
6704                         nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
6705                         nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
6706                         nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
6707                         nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
6708                 }
6709         }
6710 }
6711 /// Creates a copy of the SocketAddressParseError
6712 #[no_mangle]
6713 pub extern "C" fn SocketAddressParseError_clone(orig: &SocketAddressParseError) -> SocketAddressParseError {
6714         orig.clone()
6715 }
6716 #[allow(unused)]
6717 /// Used only if an object of this type is returned as a trait impl by a method
6718 pub(crate) extern "C" fn SocketAddressParseError_clone_void(this_ptr: *const c_void) -> *mut c_void {
6719         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddressParseError)).clone() })) as *mut c_void
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 SocketAddressParseError_free_void(this_ptr: *mut c_void) {
6724         let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddressParseError) };
6725 }
6726 #[no_mangle]
6727 /// Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError
6728 pub extern "C" fn SocketAddressParseError_socket_addr_parse() -> SocketAddressParseError {
6729         SocketAddressParseError::SocketAddrParse}
6730 #[no_mangle]
6731 /// Utility method to constructs a new InvalidInput-variant SocketAddressParseError
6732 pub extern "C" fn SocketAddressParseError_invalid_input() -> SocketAddressParseError {
6733         SocketAddressParseError::InvalidInput}
6734 #[no_mangle]
6735 /// Utility method to constructs a new InvalidPort-variant SocketAddressParseError
6736 pub extern "C" fn SocketAddressParseError_invalid_port() -> SocketAddressParseError {
6737         SocketAddressParseError::InvalidPort}
6738 #[no_mangle]
6739 /// Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError
6740 pub extern "C" fn SocketAddressParseError_invalid_onion_v3() -> SocketAddressParseError {
6741         SocketAddressParseError::InvalidOnionV3}
6742 /// Get a string which allows debug introspection of a SocketAddressParseError object
6743 pub extern "C" fn SocketAddressParseError_debug_str_void(o: *const c_void) -> Str {
6744         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SocketAddressParseError }).into()}
6745 /// Generates a non-cryptographic 64-bit hash of the SocketAddressParseError.
6746 #[no_mangle]
6747 pub extern "C" fn SocketAddressParseError_hash(o: &SocketAddressParseError) -> u64 {
6748         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6749         #[allow(deprecated)]
6750         let mut hasher = core::hash::SipHasher::new();
6751         core::hash::Hash::hash(&o.to_native(), &mut hasher);
6752         core::hash::Hasher::finish(&hasher)
6753 }
6754 /// Checks if two SocketAddressParseErrors contain equal inner contents.
6755 /// This ignores pointers and is_owned flags and looks at the values in fields.
6756 #[no_mangle]
6757 pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool {
6758         if &a.to_native() == &b.to_native() { true } else { false }
6759 }
6760 /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
6761 ///
6762 /// The host part must end with \".onion\".
6763 #[no_mangle]
6764 pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6765         let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
6766         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() };
6767         local_ret
6768 }
6769
6770 #[no_mangle]
6771 /// Get the string representation of a SocketAddress object
6772 pub extern "C" fn SocketAddress_to_str(o: &crate::lightning::ln::msgs::SocketAddress) -> Str {
6773         alloc::format!("{}", &o.to_native()).into()
6774 }
6775 #[no_mangle]
6776 /// Read a SocketAddress object from a string
6777 pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6778         match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
6779                 Ok(r) => {
6780                         crate::c_types::CResultTempl::ok(
6781                                 crate::lightning::ln::msgs::SocketAddress::native_into(r)
6782                         )
6783                 },
6784                 Err(e) => {
6785                         crate::c_types::CResultTempl::err(
6786                                 crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
6787                         )
6788                 },
6789         }.into()
6790 }
6791 /// Represents the set of gossip messages that require a signature from a node's identity key.
6792 #[derive(Clone)]
6793 #[must_use]
6794 #[repr(C)]
6795 pub enum UnsignedGossipMessage {
6796         /// An unsigned channel announcement.
6797         ChannelAnnouncement(
6798                 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
6799         /// An unsigned channel update.
6800         ChannelUpdate(
6801                 crate::lightning::ln::msgs::UnsignedChannelUpdate),
6802         /// An unsigned node announcement.
6803         NodeAnnouncement(
6804                 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
6805 }
6806 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
6807 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
6808
6809 impl UnsignedGossipMessage {
6810         #[allow(unused)]
6811         pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
6812                 match self {
6813                         UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6814                                 let mut a_nonref = Clone::clone(a);
6815                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
6816                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
6817                                 )
6818                         },
6819                         UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6820                                 let mut a_nonref = Clone::clone(a);
6821                                 nativeUnsignedGossipMessage::ChannelUpdate (
6822                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
6823                                 )
6824                         },
6825                         UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6826                                 let mut a_nonref = Clone::clone(a);
6827                                 nativeUnsignedGossipMessage::NodeAnnouncement (
6828                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
6829                                 )
6830                         },
6831                 }
6832         }
6833         #[allow(unused)]
6834         pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
6835                 match self {
6836                         UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6837                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
6838                                         *unsafe { Box::from_raw(a.take_inner()) },
6839                                 )
6840                         },
6841                         UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6842                                 nativeUnsignedGossipMessage::ChannelUpdate (
6843                                         *unsafe { Box::from_raw(a.take_inner()) },
6844                                 )
6845                         },
6846                         UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6847                                 nativeUnsignedGossipMessage::NodeAnnouncement (
6848                                         *unsafe { Box::from_raw(a.take_inner()) },
6849                                 )
6850                         },
6851                 }
6852         }
6853         #[allow(unused)]
6854         pub(crate) fn from_native(native: &UnsignedGossipMessageImport) -> Self {
6855                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeUnsignedGossipMessage) };
6856                 match native {
6857                         nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6858                                 let mut a_nonref = Clone::clone(a);
6859                                 UnsignedGossipMessage::ChannelAnnouncement (
6860                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6861                                 )
6862                         },
6863                         nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6864                                 let mut a_nonref = Clone::clone(a);
6865                                 UnsignedGossipMessage::ChannelUpdate (
6866                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6867                                 )
6868                         },
6869                         nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6870                                 let mut a_nonref = Clone::clone(a);
6871                                 UnsignedGossipMessage::NodeAnnouncement (
6872                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6873                                 )
6874                         },
6875                 }
6876         }
6877         #[allow(unused)]
6878         pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
6879                 match native {
6880                         nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6881                                 UnsignedGossipMessage::ChannelAnnouncement (
6882                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6883                                 )
6884                         },
6885                         nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6886                                 UnsignedGossipMessage::ChannelUpdate (
6887                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
6888                                 )
6889                         },
6890                         nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6891                                 UnsignedGossipMessage::NodeAnnouncement (
6892                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6893                                 )
6894                         },
6895                 }
6896         }
6897 }
6898 /// Frees any resources used by the UnsignedGossipMessage
6899 #[no_mangle]
6900 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
6901 /// Creates a copy of the UnsignedGossipMessage
6902 #[no_mangle]
6903 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
6904         orig.clone()
6905 }
6906 #[allow(unused)]
6907 /// Used only if an object of this type is returned as a trait impl by a method
6908 pub(crate) extern "C" fn UnsignedGossipMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
6909         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const UnsignedGossipMessage)).clone() })) as *mut c_void
6910 }
6911 #[allow(unused)]
6912 /// Used only if an object of this type is returned as a trait impl by a method
6913 pub(crate) extern "C" fn UnsignedGossipMessage_free_void(this_ptr: *mut c_void) {
6914         let _ = unsafe { Box::from_raw(this_ptr as *mut UnsignedGossipMessage) };
6915 }
6916 #[no_mangle]
6917 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
6918 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
6919         UnsignedGossipMessage::ChannelAnnouncement(a, )
6920 }
6921 #[no_mangle]
6922 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
6923 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
6924         UnsignedGossipMessage::ChannelUpdate(a, )
6925 }
6926 #[no_mangle]
6927 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
6928 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
6929         UnsignedGossipMessage::NodeAnnouncement(a, )
6930 }
6931 #[no_mangle]
6932 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
6933 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
6934         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6935 }
6936 #[allow(unused)]
6937 pub(crate) extern "C" fn UnsignedGossipMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6938         UnsignedGossipMessage_write(unsafe { &*(obj as *const UnsignedGossipMessage) })
6939 }
6940
6941 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
6942 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
6943
6944 /// The unsigned part of a [`node_announcement`] message.
6945 ///
6946 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
6947 #[must_use]
6948 #[repr(C)]
6949 pub struct UnsignedNodeAnnouncement {
6950         /// A pointer to the opaque Rust object.
6951
6952         /// Nearly everywhere, inner must be non-null, however in places where
6953         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6954         pub inner: *mut nativeUnsignedNodeAnnouncement,
6955         /// Indicates that this is the only struct which contains the same pointer.
6956
6957         /// Rust functions which take ownership of an object provided via an argument require
6958         /// this to be true and invalidate the object pointed to by inner.
6959         pub is_owned: bool,
6960 }
6961
6962 impl Drop for UnsignedNodeAnnouncement {
6963         fn drop(&mut self) {
6964                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
6965                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6966                 }
6967         }
6968 }
6969 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
6970 #[no_mangle]
6971 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
6972 #[allow(unused)]
6973 /// Used only if an object of this type is returned as a trait impl by a method
6974 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
6975         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
6976 }
6977 #[allow(unused)]
6978 impl UnsignedNodeAnnouncement {
6979         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
6980                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6981         }
6982         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
6983                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6984         }
6985         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6986         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
6987                 assert!(self.is_owned);
6988                 let ret = ObjOps::untweak_ptr(self.inner);
6989                 self.inner = core::ptr::null_mut();
6990                 ret
6991         }
6992 }
6993 /// The advertised features
6994 #[no_mangle]
6995 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
6996         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6997         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 }
6998 }
6999 /// The advertised features
7000 #[no_mangle]
7001 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
7002         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
7003 }
7004 /// A strictly monotonic announcement counter, with gaps allowed
7005 #[no_mangle]
7006 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
7007         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
7008         *inner_val
7009 }
7010 /// A strictly monotonic announcement counter, with gaps allowed
7011 #[no_mangle]
7012 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
7013         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
7014 }
7015 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
7016 /// to this node).
7017 #[no_mangle]
7018 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7019         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
7020         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 }
7021 }
7022 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
7023 /// to this node).
7024 #[no_mangle]
7025 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7026         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
7027 }
7028 /// An RGB color for UI purposes
7029 #[no_mangle]
7030 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
7031         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
7032         inner_val
7033 }
7034 /// An RGB color for UI purposes
7035 #[no_mangle]
7036 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
7037         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
7038 }
7039 /// An alias, for UI purposes.
7040 ///
7041 /// This should be sanitized before use. There is no guarantee of uniqueness.
7042 #[no_mangle]
7043 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
7044         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
7045         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 }
7046 }
7047 /// An alias, for UI purposes.
7048 ///
7049 /// This should be sanitized before use. There is no guarantee of uniqueness.
7050 #[no_mangle]
7051 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
7052         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
7053 }
7054 /// List of addresses on which this node is reachable
7055 ///
7056 /// Returns a copy of the field.
7057 #[no_mangle]
7058 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
7059         let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
7060         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) }); };
7061         local_inner_val.into()
7062 }
7063 /// List of addresses on which this node is reachable
7064 #[no_mangle]
7065 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
7066         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
7067         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
7068 }
7069 impl Clone for UnsignedNodeAnnouncement {
7070         fn clone(&self) -> Self {
7071                 Self {
7072                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7073                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7074                         is_owned: true,
7075                 }
7076         }
7077 }
7078 #[allow(unused)]
7079 /// Used only if an object of this type is returned as a trait impl by a method
7080 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7081         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
7082 }
7083 #[no_mangle]
7084 /// Creates a copy of the UnsignedNodeAnnouncement
7085 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
7086         orig.clone()
7087 }
7088 /// Get a string which allows debug introspection of a UnsignedNodeAnnouncement object
7089 pub extern "C" fn UnsignedNodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7090         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedNodeAnnouncement }).into()}
7091 /// Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement.
7092 #[no_mangle]
7093 pub extern "C" fn UnsignedNodeAnnouncement_hash(o: &UnsignedNodeAnnouncement) -> u64 {
7094         if o.inner.is_null() { return 0; }
7095         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7096         #[allow(deprecated)]
7097         let mut hasher = core::hash::SipHasher::new();
7098         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7099         core::hash::Hasher::finish(&hasher)
7100 }
7101 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
7102 /// This ignores pointers and is_owned flags and looks at the values in fields.
7103 /// Two objects with NULL inner values will be considered "equal" here.
7104 #[no_mangle]
7105 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
7106         if a.inner == b.inner { return true; }
7107         if a.inner.is_null() || b.inner.is_null() { return false; }
7108         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7109 }
7110
7111 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
7112 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
7113
7114 /// A [`node_announcement`] message to be sent to or received from a peer.
7115 ///
7116 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
7117 #[must_use]
7118 #[repr(C)]
7119 pub struct NodeAnnouncement {
7120         /// A pointer to the opaque Rust object.
7121
7122         /// Nearly everywhere, inner must be non-null, however in places where
7123         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7124         pub inner: *mut nativeNodeAnnouncement,
7125         /// Indicates that this is the only struct which contains the same pointer.
7126
7127         /// Rust functions which take ownership of an object provided via an argument require
7128         /// this to be true and invalidate the object pointed to by inner.
7129         pub is_owned: bool,
7130 }
7131
7132 impl Drop for NodeAnnouncement {
7133         fn drop(&mut self) {
7134                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
7135                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7136                 }
7137         }
7138 }
7139 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
7140 #[no_mangle]
7141 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
7142 #[allow(unused)]
7143 /// Used only if an object of this type is returned as a trait impl by a method
7144 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
7145         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
7146 }
7147 #[allow(unused)]
7148 impl NodeAnnouncement {
7149         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
7150                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7151         }
7152         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
7153                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7154         }
7155         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7156         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
7157                 assert!(self.is_owned);
7158                 let ret = ObjOps::untweak_ptr(self.inner);
7159                 self.inner = core::ptr::null_mut();
7160                 ret
7161         }
7162 }
7163 /// The signature by the node key
7164 #[no_mangle]
7165 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
7166         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7167         crate::c_types::ECDSASignature::from_rust(&inner_val)
7168 }
7169 /// The signature by the node key
7170 #[no_mangle]
7171 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
7172         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7173 }
7174 /// The actual content of the announcement
7175 #[no_mangle]
7176 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
7177         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7178         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 }
7179 }
7180 /// The actual content of the announcement
7181 #[no_mangle]
7182 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
7183         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7184 }
7185 /// Constructs a new NodeAnnouncement given each field
7186 #[must_use]
7187 #[no_mangle]
7188 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
7189         NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
7190                 signature: signature_arg.into_rust(),
7191                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7192         }), is_owned: true }
7193 }
7194 impl Clone for NodeAnnouncement {
7195         fn clone(&self) -> Self {
7196                 Self {
7197                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7198                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7199                         is_owned: true,
7200                 }
7201         }
7202 }
7203 #[allow(unused)]
7204 /// Used only if an object of this type is returned as a trait impl by a method
7205 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7206         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncement)).clone() })) as *mut c_void
7207 }
7208 #[no_mangle]
7209 /// Creates a copy of the NodeAnnouncement
7210 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
7211         orig.clone()
7212 }
7213 /// Get a string which allows debug introspection of a NodeAnnouncement object
7214 pub extern "C" fn NodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7215         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::NodeAnnouncement }).into()}
7216 /// Generates a non-cryptographic 64-bit hash of the NodeAnnouncement.
7217 #[no_mangle]
7218 pub extern "C" fn NodeAnnouncement_hash(o: &NodeAnnouncement) -> u64 {
7219         if o.inner.is_null() { return 0; }
7220         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7221         #[allow(deprecated)]
7222         let mut hasher = core::hash::SipHasher::new();
7223         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7224         core::hash::Hasher::finish(&hasher)
7225 }
7226 /// Checks if two NodeAnnouncements contain equal inner contents.
7227 /// This ignores pointers and is_owned flags and looks at the values in fields.
7228 /// Two objects with NULL inner values will be considered "equal" here.
7229 #[no_mangle]
7230 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
7231         if a.inner == b.inner { return true; }
7232         if a.inner.is_null() || b.inner.is_null() { return false; }
7233         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7234 }
7235
7236 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
7237 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
7238
7239 /// The unsigned part of a [`channel_announcement`] message.
7240 ///
7241 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7242 #[must_use]
7243 #[repr(C)]
7244 pub struct UnsignedChannelAnnouncement {
7245         /// A pointer to the opaque Rust object.
7246
7247         /// Nearly everywhere, inner must be non-null, however in places where
7248         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7249         pub inner: *mut nativeUnsignedChannelAnnouncement,
7250         /// Indicates that this is the only struct which contains the same pointer.
7251
7252         /// Rust functions which take ownership of an object provided via an argument require
7253         /// this to be true and invalidate the object pointed to by inner.
7254         pub is_owned: bool,
7255 }
7256
7257 impl Drop for UnsignedChannelAnnouncement {
7258         fn drop(&mut self) {
7259                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
7260                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7261                 }
7262         }
7263 }
7264 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
7265 #[no_mangle]
7266 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
7267 #[allow(unused)]
7268 /// Used only if an object of this type is returned as a trait impl by a method
7269 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7270         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
7271 }
7272 #[allow(unused)]
7273 impl UnsignedChannelAnnouncement {
7274         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
7275                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7276         }
7277         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
7278                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7279         }
7280         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7281         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
7282                 assert!(self.is_owned);
7283                 let ret = ObjOps::untweak_ptr(self.inner);
7284                 self.inner = core::ptr::null_mut();
7285                 ret
7286         }
7287 }
7288 /// The advertised channel features
7289 #[no_mangle]
7290 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
7291         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
7292         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 }
7293 }
7294 /// The advertised channel features
7295 #[no_mangle]
7296 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
7297         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
7298 }
7299 /// The genesis hash of the blockchain where the channel is to be opened
7300 #[no_mangle]
7301 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
7302         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7303         inner_val.as_ref()
7304 }
7305 /// The genesis hash of the blockchain where the channel is to be opened
7306 #[no_mangle]
7307 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
7308         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7309 }
7310 /// The short channel ID
7311 #[no_mangle]
7312 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
7313         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7314         *inner_val
7315 }
7316 /// The short channel ID
7317 #[no_mangle]
7318 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
7319         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7320 }
7321 /// One of the two `node_id`s which are endpoints of this channel
7322 #[no_mangle]
7323 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7324         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
7325         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 }
7326 }
7327 /// One of the two `node_id`s which are endpoints of this channel
7328 #[no_mangle]
7329 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7330         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
7331 }
7332 /// The other of the two `node_id`s which are endpoints of this channel
7333 #[no_mangle]
7334 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7335         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
7336         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 }
7337 }
7338 /// The other of the two `node_id`s which are endpoints of this channel
7339 #[no_mangle]
7340 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7341         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
7342 }
7343 /// The funding key for the first node
7344 #[no_mangle]
7345 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7346         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
7347         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 }
7348 }
7349 /// The funding key for the first node
7350 #[no_mangle]
7351 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7352         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
7353 }
7354 /// The funding key for the second node
7355 #[no_mangle]
7356 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7357         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
7358         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 }
7359 }
7360 /// The funding key for the second node
7361 #[no_mangle]
7362 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7363         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
7364 }
7365 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7366 /// to decode.
7367 ///
7368 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7369 ///
7370 /// Returns a copy of the field.
7371 #[no_mangle]
7372 pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
7373         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7374         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7375         local_inner_val.into()
7376 }
7377 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7378 /// to decode.
7379 ///
7380 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7381 #[no_mangle]
7382 pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
7383         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7384         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7385 }
7386 /// Constructs a new UnsignedChannelAnnouncement given each field
7387 #[must_use]
7388 #[no_mangle]
7389 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 {
7390         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7391         UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
7392                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
7393                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7394                 short_channel_id: short_channel_id_arg,
7395                 node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
7396                 node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
7397                 bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
7398                 bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
7399                 excess_data: local_excess_data_arg,
7400         }), is_owned: true }
7401 }
7402 impl Clone for UnsignedChannelAnnouncement {
7403         fn clone(&self) -> Self {
7404                 Self {
7405                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7406                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7407                         is_owned: true,
7408                 }
7409         }
7410 }
7411 #[allow(unused)]
7412 /// Used only if an object of this type is returned as a trait impl by a method
7413 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7414         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
7415 }
7416 #[no_mangle]
7417 /// Creates a copy of the UnsignedChannelAnnouncement
7418 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
7419         orig.clone()
7420 }
7421 /// Get a string which allows debug introspection of a UnsignedChannelAnnouncement object
7422 pub extern "C" fn UnsignedChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7423         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelAnnouncement }).into()}
7424 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement.
7425 #[no_mangle]
7426 pub extern "C" fn UnsignedChannelAnnouncement_hash(o: &UnsignedChannelAnnouncement) -> u64 {
7427         if o.inner.is_null() { return 0; }
7428         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7429         #[allow(deprecated)]
7430         let mut hasher = core::hash::SipHasher::new();
7431         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7432         core::hash::Hasher::finish(&hasher)
7433 }
7434 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
7435 /// This ignores pointers and is_owned flags and looks at the values in fields.
7436 /// Two objects with NULL inner values will be considered "equal" here.
7437 #[no_mangle]
7438 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
7439         if a.inner == b.inner { return true; }
7440         if a.inner.is_null() || b.inner.is_null() { return false; }
7441         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7442 }
7443
7444 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
7445 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
7446
7447 /// A [`channel_announcement`] message to be sent to or received from a peer.
7448 ///
7449 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7450 #[must_use]
7451 #[repr(C)]
7452 pub struct ChannelAnnouncement {
7453         /// A pointer to the opaque Rust object.
7454
7455         /// Nearly everywhere, inner must be non-null, however in places where
7456         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7457         pub inner: *mut nativeChannelAnnouncement,
7458         /// Indicates that this is the only struct which contains the same pointer.
7459
7460         /// Rust functions which take ownership of an object provided via an argument require
7461         /// this to be true and invalidate the object pointed to by inner.
7462         pub is_owned: bool,
7463 }
7464
7465 impl Drop for ChannelAnnouncement {
7466         fn drop(&mut self) {
7467                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
7468                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7469                 }
7470         }
7471 }
7472 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
7473 #[no_mangle]
7474 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
7475 #[allow(unused)]
7476 /// Used only if an object of this type is returned as a trait impl by a method
7477 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7478         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
7479 }
7480 #[allow(unused)]
7481 impl ChannelAnnouncement {
7482         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
7483                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7484         }
7485         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
7486                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7487         }
7488         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7489         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
7490                 assert!(self.is_owned);
7491                 let ret = ObjOps::untweak_ptr(self.inner);
7492                 self.inner = core::ptr::null_mut();
7493                 ret
7494         }
7495 }
7496 /// Authentication of the announcement by the first public node
7497 #[no_mangle]
7498 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7499         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
7500         crate::c_types::ECDSASignature::from_rust(&inner_val)
7501 }
7502 /// Authentication of the announcement by the first public node
7503 #[no_mangle]
7504 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7505         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
7506 }
7507 /// Authentication of the announcement by the second public node
7508 #[no_mangle]
7509 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7510         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
7511         crate::c_types::ECDSASignature::from_rust(&inner_val)
7512 }
7513 /// Authentication of the announcement by the second public node
7514 #[no_mangle]
7515 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7516         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
7517 }
7518 /// Proof of funding UTXO ownership by the first public node
7519 #[no_mangle]
7520 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7521         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
7522         crate::c_types::ECDSASignature::from_rust(&inner_val)
7523 }
7524 /// Proof of funding UTXO ownership by the first public node
7525 #[no_mangle]
7526 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7527         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
7528 }
7529 /// Proof of funding UTXO ownership by the second public node
7530 #[no_mangle]
7531 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7532         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
7533         crate::c_types::ECDSASignature::from_rust(&inner_val)
7534 }
7535 /// Proof of funding UTXO ownership by the second public node
7536 #[no_mangle]
7537 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7538         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
7539 }
7540 /// The actual announcement
7541 #[no_mangle]
7542 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
7543         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7544         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 }
7545 }
7546 /// The actual announcement
7547 #[no_mangle]
7548 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
7549         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7550 }
7551 /// Constructs a new ChannelAnnouncement given each field
7552 #[must_use]
7553 #[no_mangle]
7554 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 {
7555         ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
7556                 node_signature_1: node_signature_1_arg.into_rust(),
7557                 node_signature_2: node_signature_2_arg.into_rust(),
7558                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
7559                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
7560                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7561         }), is_owned: true }
7562 }
7563 impl Clone for ChannelAnnouncement {
7564         fn clone(&self) -> Self {
7565                 Self {
7566                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7567                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7568                         is_owned: true,
7569                 }
7570         }
7571 }
7572 #[allow(unused)]
7573 /// Used only if an object of this type is returned as a trait impl by a method
7574 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7575         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelAnnouncement)).clone() })) as *mut c_void
7576 }
7577 #[no_mangle]
7578 /// Creates a copy of the ChannelAnnouncement
7579 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
7580         orig.clone()
7581 }
7582 /// Get a string which allows debug introspection of a ChannelAnnouncement object
7583 pub extern "C" fn ChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7584         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelAnnouncement }).into()}
7585 /// Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement.
7586 #[no_mangle]
7587 pub extern "C" fn ChannelAnnouncement_hash(o: &ChannelAnnouncement) -> u64 {
7588         if o.inner.is_null() { return 0; }
7589         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7590         #[allow(deprecated)]
7591         let mut hasher = core::hash::SipHasher::new();
7592         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7593         core::hash::Hasher::finish(&hasher)
7594 }
7595 /// Checks if two ChannelAnnouncements contain equal inner contents.
7596 /// This ignores pointers and is_owned flags and looks at the values in fields.
7597 /// Two objects with NULL inner values will be considered "equal" here.
7598 #[no_mangle]
7599 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
7600         if a.inner == b.inner { return true; }
7601         if a.inner.is_null() || b.inner.is_null() { return false; }
7602         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7603 }
7604
7605 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
7606 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
7607
7608 /// The unsigned part of a [`channel_update`] message.
7609 ///
7610 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7611 #[must_use]
7612 #[repr(C)]
7613 pub struct UnsignedChannelUpdate {
7614         /// A pointer to the opaque Rust object.
7615
7616         /// Nearly everywhere, inner must be non-null, however in places where
7617         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7618         pub inner: *mut nativeUnsignedChannelUpdate,
7619         /// Indicates that this is the only struct which contains the same pointer.
7620
7621         /// Rust functions which take ownership of an object provided via an argument require
7622         /// this to be true and invalidate the object pointed to by inner.
7623         pub is_owned: bool,
7624 }
7625
7626 impl Drop for UnsignedChannelUpdate {
7627         fn drop(&mut self) {
7628                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
7629                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7630                 }
7631         }
7632 }
7633 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
7634 #[no_mangle]
7635 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
7636 #[allow(unused)]
7637 /// Used only if an object of this type is returned as a trait impl by a method
7638 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
7639         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
7640 }
7641 #[allow(unused)]
7642 impl UnsignedChannelUpdate {
7643         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
7644                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7645         }
7646         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
7647                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7648         }
7649         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7650         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
7651                 assert!(self.is_owned);
7652                 let ret = ObjOps::untweak_ptr(self.inner);
7653                 self.inner = core::ptr::null_mut();
7654                 ret
7655         }
7656 }
7657 /// The genesis hash of the blockchain where the channel is to be opened
7658 #[no_mangle]
7659 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
7660         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7661         inner_val.as_ref()
7662 }
7663 /// The genesis hash of the blockchain where the channel is to be opened
7664 #[no_mangle]
7665 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
7666         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7667 }
7668 /// The short channel ID
7669 #[no_mangle]
7670 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
7671         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7672         *inner_val
7673 }
7674 /// The short channel ID
7675 #[no_mangle]
7676 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7677         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7678 }
7679 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7680 #[no_mangle]
7681 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
7682         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
7683         *inner_val
7684 }
7685 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7686 #[no_mangle]
7687 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7688         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
7689 }
7690 /// Channel flags
7691 #[no_mangle]
7692 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
7693         let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
7694         *inner_val
7695 }
7696 /// Channel flags
7697 #[no_mangle]
7698 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
7699         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
7700 }
7701 /// The number of blocks such that if:
7702 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7703 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7704 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7705 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7706 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7707 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7708 /// constructing the route.
7709 #[no_mangle]
7710 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
7711         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
7712         *inner_val
7713 }
7714 /// The number of blocks such that if:
7715 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7716 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7717 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7718 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7719 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7720 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7721 /// constructing the route.
7722 #[no_mangle]
7723 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
7724         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
7725 }
7726 /// The minimum HTLC size incoming to sender, in milli-satoshi
7727 #[no_mangle]
7728 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7729         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
7730         *inner_val
7731 }
7732 /// The minimum HTLC size incoming to sender, in milli-satoshi
7733 #[no_mangle]
7734 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7735         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
7736 }
7737 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7738 ///
7739 /// This used to be optional.
7740 #[no_mangle]
7741 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7742         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
7743         *inner_val
7744 }
7745 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7746 ///
7747 /// This used to be optional.
7748 #[no_mangle]
7749 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7750         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
7751 }
7752 /// The base HTLC fee charged by sender, in milli-satoshi
7753 #[no_mangle]
7754 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
7755         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
7756         *inner_val
7757 }
7758 /// The base HTLC fee charged by sender, in milli-satoshi
7759 #[no_mangle]
7760 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7761         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
7762 }
7763 /// The amount to fee multiplier, in micro-satoshi
7764 #[no_mangle]
7765 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
7766         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
7767         *inner_val
7768 }
7769 /// The amount to fee multiplier, in micro-satoshi
7770 #[no_mangle]
7771 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7772         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
7773 }
7774 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7775 /// to decode.
7776 ///
7777 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7778 ///
7779 /// Returns a copy of the field.
7780 #[no_mangle]
7781 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
7782         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7783         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7784         local_inner_val.into()
7785 }
7786 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7787 /// to decode.
7788 ///
7789 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7790 #[no_mangle]
7791 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
7792         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7793         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7794 }
7795 /// Constructs a new UnsignedChannelUpdate given each field
7796 #[must_use]
7797 #[no_mangle]
7798 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 {
7799         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7800         UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
7801                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7802                 short_channel_id: short_channel_id_arg,
7803                 timestamp: timestamp_arg,
7804                 flags: flags_arg,
7805                 cltv_expiry_delta: cltv_expiry_delta_arg,
7806                 htlc_minimum_msat: htlc_minimum_msat_arg,
7807                 htlc_maximum_msat: htlc_maximum_msat_arg,
7808                 fee_base_msat: fee_base_msat_arg,
7809                 fee_proportional_millionths: fee_proportional_millionths_arg,
7810                 excess_data: local_excess_data_arg,
7811         }), is_owned: true }
7812 }
7813 impl Clone for UnsignedChannelUpdate {
7814         fn clone(&self) -> Self {
7815                 Self {
7816                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7817                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7818                         is_owned: true,
7819                 }
7820         }
7821 }
7822 #[allow(unused)]
7823 /// Used only if an object of this type is returned as a trait impl by a method
7824 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7825         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
7826 }
7827 #[no_mangle]
7828 /// Creates a copy of the UnsignedChannelUpdate
7829 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
7830         orig.clone()
7831 }
7832 /// Get a string which allows debug introspection of a UnsignedChannelUpdate object
7833 pub extern "C" fn UnsignedChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7834         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelUpdate }).into()}
7835 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate.
7836 #[no_mangle]
7837 pub extern "C" fn UnsignedChannelUpdate_hash(o: &UnsignedChannelUpdate) -> u64 {
7838         if o.inner.is_null() { return 0; }
7839         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7840         #[allow(deprecated)]
7841         let mut hasher = core::hash::SipHasher::new();
7842         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7843         core::hash::Hasher::finish(&hasher)
7844 }
7845 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
7846 /// This ignores pointers and is_owned flags and looks at the values in fields.
7847 /// Two objects with NULL inner values will be considered "equal" here.
7848 #[no_mangle]
7849 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
7850         if a.inner == b.inner { return true; }
7851         if a.inner.is_null() || b.inner.is_null() { return false; }
7852         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7853 }
7854
7855 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
7856 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
7857
7858 /// A [`channel_update`] message to be sent to or received from a peer.
7859 ///
7860 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7861 #[must_use]
7862 #[repr(C)]
7863 pub struct ChannelUpdate {
7864         /// A pointer to the opaque Rust object.
7865
7866         /// Nearly everywhere, inner must be non-null, however in places where
7867         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7868         pub inner: *mut nativeChannelUpdate,
7869         /// Indicates that this is the only struct which contains the same pointer.
7870
7871         /// Rust functions which take ownership of an object provided via an argument require
7872         /// this to be true and invalidate the object pointed to by inner.
7873         pub is_owned: bool,
7874 }
7875
7876 impl Drop for ChannelUpdate {
7877         fn drop(&mut self) {
7878                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
7879                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7880                 }
7881         }
7882 }
7883 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
7884 #[no_mangle]
7885 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
7886 #[allow(unused)]
7887 /// Used only if an object of this type is returned as a trait impl by a method
7888 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
7889         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
7890 }
7891 #[allow(unused)]
7892 impl ChannelUpdate {
7893         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
7894                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7895         }
7896         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
7897                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7898         }
7899         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7900         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
7901                 assert!(self.is_owned);
7902                 let ret = ObjOps::untweak_ptr(self.inner);
7903                 self.inner = core::ptr::null_mut();
7904                 ret
7905         }
7906 }
7907 /// A signature of the channel update
7908 #[no_mangle]
7909 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
7910         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7911         crate::c_types::ECDSASignature::from_rust(&inner_val)
7912 }
7913 /// A signature of the channel update
7914 #[no_mangle]
7915 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
7916         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7917 }
7918 /// The actual channel update
7919 #[no_mangle]
7920 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
7921         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7922         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 }
7923 }
7924 /// The actual channel update
7925 #[no_mangle]
7926 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
7927         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7928 }
7929 /// Constructs a new ChannelUpdate given each field
7930 #[must_use]
7931 #[no_mangle]
7932 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
7933         ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
7934                 signature: signature_arg.into_rust(),
7935                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7936         }), is_owned: true }
7937 }
7938 impl Clone for ChannelUpdate {
7939         fn clone(&self) -> Self {
7940                 Self {
7941                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7942                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7943                         is_owned: true,
7944                 }
7945         }
7946 }
7947 #[allow(unused)]
7948 /// Used only if an object of this type is returned as a trait impl by a method
7949 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7950         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelUpdate)).clone() })) as *mut c_void
7951 }
7952 #[no_mangle]
7953 /// Creates a copy of the ChannelUpdate
7954 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
7955         orig.clone()
7956 }
7957 /// Get a string which allows debug introspection of a ChannelUpdate object
7958 pub extern "C" fn ChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7959         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelUpdate }).into()}
7960 /// Generates a non-cryptographic 64-bit hash of the ChannelUpdate.
7961 #[no_mangle]
7962 pub extern "C" fn ChannelUpdate_hash(o: &ChannelUpdate) -> u64 {
7963         if o.inner.is_null() { return 0; }
7964         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7965         #[allow(deprecated)]
7966         let mut hasher = core::hash::SipHasher::new();
7967         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7968         core::hash::Hasher::finish(&hasher)
7969 }
7970 /// Checks if two ChannelUpdates contain equal inner contents.
7971 /// This ignores pointers and is_owned flags and looks at the values in fields.
7972 /// Two objects with NULL inner values will be considered "equal" here.
7973 #[no_mangle]
7974 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
7975         if a.inner == b.inner { return true; }
7976         if a.inner.is_null() || b.inner.is_null() { return false; }
7977         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7978 }
7979
7980 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
7981 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
7982
7983 /// A [`query_channel_range`] message is used to query a peer for channel
7984 /// UTXOs in a range of blocks. The recipient of a query makes a best
7985 /// effort to reply to the query using one or more [`ReplyChannelRange`]
7986 /// messages.
7987 ///
7988 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
7989 #[must_use]
7990 #[repr(C)]
7991 pub struct QueryChannelRange {
7992         /// A pointer to the opaque Rust object.
7993
7994         /// Nearly everywhere, inner must be non-null, however in places where
7995         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7996         pub inner: *mut nativeQueryChannelRange,
7997         /// Indicates that this is the only struct which contains the same pointer.
7998
7999         /// Rust functions which take ownership of an object provided via an argument require
8000         /// this to be true and invalidate the object pointed to by inner.
8001         pub is_owned: bool,
8002 }
8003
8004 impl Drop for QueryChannelRange {
8005         fn drop(&mut self) {
8006                 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
8007                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8008                 }
8009         }
8010 }
8011 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
8012 #[no_mangle]
8013 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
8014 #[allow(unused)]
8015 /// Used only if an object of this type is returned as a trait impl by a method
8016 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
8017         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
8018 }
8019 #[allow(unused)]
8020 impl QueryChannelRange {
8021         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
8022                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8023         }
8024         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
8025                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8026         }
8027         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8028         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
8029                 assert!(self.is_owned);
8030                 let ret = ObjOps::untweak_ptr(self.inner);
8031                 self.inner = core::ptr::null_mut();
8032                 ret
8033         }
8034 }
8035 /// The genesis hash of the blockchain being queried
8036 #[no_mangle]
8037 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
8038         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8039         inner_val.as_ref()
8040 }
8041 /// The genesis hash of the blockchain being queried
8042 #[no_mangle]
8043 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
8044         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8045 }
8046 /// The height of the first block for the channel UTXOs being queried
8047 #[no_mangle]
8048 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
8049         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
8050         *inner_val
8051 }
8052 /// The height of the first block for the channel UTXOs being queried
8053 #[no_mangle]
8054 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
8055         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
8056 }
8057 /// The number of blocks to include in the query results
8058 #[no_mangle]
8059 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
8060         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
8061         *inner_val
8062 }
8063 /// The number of blocks to include in the query results
8064 #[no_mangle]
8065 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
8066         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
8067 }
8068 /// Constructs a new QueryChannelRange given each field
8069 #[must_use]
8070 #[no_mangle]
8071 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 {
8072         QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
8073                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8074                 first_blocknum: first_blocknum_arg,
8075                 number_of_blocks: number_of_blocks_arg,
8076         }), is_owned: true }
8077 }
8078 impl Clone for QueryChannelRange {
8079         fn clone(&self) -> Self {
8080                 Self {
8081                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
8082                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8083                         is_owned: true,
8084                 }
8085         }
8086 }
8087 #[allow(unused)]
8088 /// Used only if an object of this type is returned as a trait impl by a method
8089 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8090         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryChannelRange)).clone() })) as *mut c_void
8091 }
8092 #[no_mangle]
8093 /// Creates a copy of the QueryChannelRange
8094 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
8095         orig.clone()
8096 }
8097 /// Get a string which allows debug introspection of a QueryChannelRange object
8098 pub extern "C" fn QueryChannelRange_debug_str_void(o: *const c_void) -> Str {
8099         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryChannelRange }).into()}
8100 /// Generates a non-cryptographic 64-bit hash of the QueryChannelRange.
8101 #[no_mangle]
8102 pub extern "C" fn QueryChannelRange_hash(o: &QueryChannelRange) -> u64 {
8103         if o.inner.is_null() { return 0; }
8104         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8105         #[allow(deprecated)]
8106         let mut hasher = core::hash::SipHasher::new();
8107         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8108         core::hash::Hasher::finish(&hasher)
8109 }
8110 /// Checks if two QueryChannelRanges contain equal inner contents.
8111 /// This ignores pointers and is_owned flags and looks at the values in fields.
8112 /// Two objects with NULL inner values will be considered "equal" here.
8113 #[no_mangle]
8114 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
8115         if a.inner == b.inner { return true; }
8116         if a.inner.is_null() || b.inner.is_null() { return false; }
8117         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8118 }
8119
8120 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
8121 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
8122
8123 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
8124 /// message.
8125 ///
8126 /// Multiple `reply_channel_range` messages can be sent in reply
8127 /// to a single [`QueryChannelRange`] message. The query recipient makes a
8128 /// best effort to respond based on their local network view which may
8129 /// not be a perfect view of the network. The `short_channel_id`s in the
8130 /// reply are encoded. We only support `encoding_type=0` uncompressed
8131 /// serialization and do not support `encoding_type=1` zlib serialization.
8132 ///
8133 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
8134 #[must_use]
8135 #[repr(C)]
8136 pub struct ReplyChannelRange {
8137         /// A pointer to the opaque Rust object.
8138
8139         /// Nearly everywhere, inner must be non-null, however in places where
8140         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8141         pub inner: *mut nativeReplyChannelRange,
8142         /// Indicates that this is the only struct which contains the same pointer.
8143
8144         /// Rust functions which take ownership of an object provided via an argument require
8145         /// this to be true and invalidate the object pointed to by inner.
8146         pub is_owned: bool,
8147 }
8148
8149 impl Drop for ReplyChannelRange {
8150         fn drop(&mut self) {
8151                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
8152                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8153                 }
8154         }
8155 }
8156 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
8157 #[no_mangle]
8158 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
8159 #[allow(unused)]
8160 /// Used only if an object of this type is returned as a trait impl by a method
8161 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
8162         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
8163 }
8164 #[allow(unused)]
8165 impl ReplyChannelRange {
8166         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
8167                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8168         }
8169         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
8170                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8171         }
8172         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8173         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
8174                 assert!(self.is_owned);
8175                 let ret = ObjOps::untweak_ptr(self.inner);
8176                 self.inner = core::ptr::null_mut();
8177                 ret
8178         }
8179 }
8180 /// The genesis hash of the blockchain being queried
8181 #[no_mangle]
8182 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
8183         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8184         inner_val.as_ref()
8185 }
8186 /// The genesis hash of the blockchain being queried
8187 #[no_mangle]
8188 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
8189         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8190 }
8191 /// The height of the first block in the range of the reply
8192 #[no_mangle]
8193 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
8194         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
8195         *inner_val
8196 }
8197 /// The height of the first block in the range of the reply
8198 #[no_mangle]
8199 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8200         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
8201 }
8202 /// The number of blocks included in the range of the reply
8203 #[no_mangle]
8204 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
8205         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
8206         *inner_val
8207 }
8208 /// The number of blocks included in the range of the reply
8209 #[no_mangle]
8210 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8211         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
8212 }
8213 /// True when this is the final reply for a query
8214 #[no_mangle]
8215 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
8216         let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
8217         *inner_val
8218 }
8219 /// True when this is the final reply for a query
8220 #[no_mangle]
8221 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
8222         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
8223 }
8224 /// The `short_channel_id`s in the channel range
8225 ///
8226 /// Returns a copy of the field.
8227 #[no_mangle]
8228 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
8229         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8230         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8231         local_inner_val.into()
8232 }
8233 /// The `short_channel_id`s in the channel range
8234 #[no_mangle]
8235 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
8236         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8237         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8238 }
8239 /// Constructs a new ReplyChannelRange given each field
8240 #[must_use]
8241 #[no_mangle]
8242 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 {
8243         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 }); };
8244         ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
8245                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8246                 first_blocknum: first_blocknum_arg,
8247                 number_of_blocks: number_of_blocks_arg,
8248                 sync_complete: sync_complete_arg,
8249                 short_channel_ids: local_short_channel_ids_arg,
8250         }), is_owned: true }
8251 }
8252 impl Clone for ReplyChannelRange {
8253         fn clone(&self) -> Self {
8254                 Self {
8255                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
8256                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8257                         is_owned: true,
8258                 }
8259         }
8260 }
8261 #[allow(unused)]
8262 /// Used only if an object of this type is returned as a trait impl by a method
8263 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8264         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyChannelRange)).clone() })) as *mut c_void
8265 }
8266 #[no_mangle]
8267 /// Creates a copy of the ReplyChannelRange
8268 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
8269         orig.clone()
8270 }
8271 /// Get a string which allows debug introspection of a ReplyChannelRange object
8272 pub extern "C" fn ReplyChannelRange_debug_str_void(o: *const c_void) -> Str {
8273         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyChannelRange }).into()}
8274 /// Generates a non-cryptographic 64-bit hash of the ReplyChannelRange.
8275 #[no_mangle]
8276 pub extern "C" fn ReplyChannelRange_hash(o: &ReplyChannelRange) -> u64 {
8277         if o.inner.is_null() { return 0; }
8278         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8279         #[allow(deprecated)]
8280         let mut hasher = core::hash::SipHasher::new();
8281         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8282         core::hash::Hasher::finish(&hasher)
8283 }
8284 /// Checks if two ReplyChannelRanges contain equal inner contents.
8285 /// This ignores pointers and is_owned flags and looks at the values in fields.
8286 /// Two objects with NULL inner values will be considered "equal" here.
8287 #[no_mangle]
8288 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
8289         if a.inner == b.inner { return true; }
8290         if a.inner.is_null() || b.inner.is_null() { return false; }
8291         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8292 }
8293
8294 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
8295 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
8296
8297 /// A [`query_short_channel_ids`] message is used to query a peer for
8298 /// routing gossip messages related to one or more `short_channel_id`s.
8299 ///
8300 /// The query recipient will reply with the latest, if available,
8301 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
8302 /// it maintains for the requested `short_channel_id`s followed by a
8303 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
8304 /// this query are encoded. We only support `encoding_type=0` uncompressed
8305 /// serialization and do not support `encoding_type=1` zlib serialization.
8306 ///
8307 /// [`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
8308 #[must_use]
8309 #[repr(C)]
8310 pub struct QueryShortChannelIds {
8311         /// A pointer to the opaque Rust object.
8312
8313         /// Nearly everywhere, inner must be non-null, however in places where
8314         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8315         pub inner: *mut nativeQueryShortChannelIds,
8316         /// Indicates that this is the only struct which contains the same pointer.
8317
8318         /// Rust functions which take ownership of an object provided via an argument require
8319         /// this to be true and invalidate the object pointed to by inner.
8320         pub is_owned: bool,
8321 }
8322
8323 impl Drop for QueryShortChannelIds {
8324         fn drop(&mut self) {
8325                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
8326                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8327                 }
8328         }
8329 }
8330 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
8331 #[no_mangle]
8332 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
8333 #[allow(unused)]
8334 /// Used only if an object of this type is returned as a trait impl by a method
8335 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
8336         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
8337 }
8338 #[allow(unused)]
8339 impl QueryShortChannelIds {
8340         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
8341                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8342         }
8343         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
8344                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8345         }
8346         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8347         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
8348                 assert!(self.is_owned);
8349                 let ret = ObjOps::untweak_ptr(self.inner);
8350                 self.inner = core::ptr::null_mut();
8351                 ret
8352         }
8353 }
8354 /// The genesis hash of the blockchain being queried
8355 #[no_mangle]
8356 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
8357         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8358         inner_val.as_ref()
8359 }
8360 /// The genesis hash of the blockchain being queried
8361 #[no_mangle]
8362 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
8363         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8364 }
8365 /// The short_channel_ids that are being queried
8366 ///
8367 /// Returns a copy of the field.
8368 #[no_mangle]
8369 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
8370         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8371         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8372         local_inner_val.into()
8373 }
8374 /// The short_channel_ids that are being queried
8375 #[no_mangle]
8376 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
8377         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8378         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8379 }
8380 /// Constructs a new QueryShortChannelIds given each field
8381 #[must_use]
8382 #[no_mangle]
8383 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 {
8384         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 }); };
8385         QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
8386                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8387                 short_channel_ids: local_short_channel_ids_arg,
8388         }), is_owned: true }
8389 }
8390 impl Clone for QueryShortChannelIds {
8391         fn clone(&self) -> Self {
8392                 Self {
8393                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
8394                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8395                         is_owned: true,
8396                 }
8397         }
8398 }
8399 #[allow(unused)]
8400 /// Used only if an object of this type is returned as a trait impl by a method
8401 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
8402         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryShortChannelIds)).clone() })) as *mut c_void
8403 }
8404 #[no_mangle]
8405 /// Creates a copy of the QueryShortChannelIds
8406 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
8407         orig.clone()
8408 }
8409 /// Get a string which allows debug introspection of a QueryShortChannelIds object
8410 pub extern "C" fn QueryShortChannelIds_debug_str_void(o: *const c_void) -> Str {
8411         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryShortChannelIds }).into()}
8412 /// Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds.
8413 #[no_mangle]
8414 pub extern "C" fn QueryShortChannelIds_hash(o: &QueryShortChannelIds) -> u64 {
8415         if o.inner.is_null() { return 0; }
8416         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8417         #[allow(deprecated)]
8418         let mut hasher = core::hash::SipHasher::new();
8419         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8420         core::hash::Hasher::finish(&hasher)
8421 }
8422 /// Checks if two QueryShortChannelIdss contain equal inner contents.
8423 /// This ignores pointers and is_owned flags and looks at the values in fields.
8424 /// Two objects with NULL inner values will be considered "equal" here.
8425 #[no_mangle]
8426 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
8427         if a.inner == b.inner { return true; }
8428         if a.inner.is_null() || b.inner.is_null() { return false; }
8429         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8430 }
8431
8432 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
8433 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
8434
8435 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
8436 /// message. The query recipient makes a best
8437 /// effort to respond based on their local network view which may not be
8438 /// a perfect view of the network.
8439 ///
8440 /// [`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
8441 #[must_use]
8442 #[repr(C)]
8443 pub struct ReplyShortChannelIdsEnd {
8444         /// A pointer to the opaque Rust object.
8445
8446         /// Nearly everywhere, inner must be non-null, however in places where
8447         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8448         pub inner: *mut nativeReplyShortChannelIdsEnd,
8449         /// Indicates that this is the only struct which contains the same pointer.
8450
8451         /// Rust functions which take ownership of an object provided via an argument require
8452         /// this to be true and invalidate the object pointed to by inner.
8453         pub is_owned: bool,
8454 }
8455
8456 impl Drop for ReplyShortChannelIdsEnd {
8457         fn drop(&mut self) {
8458                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
8459                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8460                 }
8461         }
8462 }
8463 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
8464 #[no_mangle]
8465 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
8466 #[allow(unused)]
8467 /// Used only if an object of this type is returned as a trait impl by a method
8468 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
8469         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
8470 }
8471 #[allow(unused)]
8472 impl ReplyShortChannelIdsEnd {
8473         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
8474                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8475         }
8476         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
8477                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8478         }
8479         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8480         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
8481                 assert!(self.is_owned);
8482                 let ret = ObjOps::untweak_ptr(self.inner);
8483                 self.inner = core::ptr::null_mut();
8484                 ret
8485         }
8486 }
8487 /// The genesis hash of the blockchain that was queried
8488 #[no_mangle]
8489 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
8490         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8491         inner_val.as_ref()
8492 }
8493 /// The genesis hash of the blockchain that was queried
8494 #[no_mangle]
8495 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
8496         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8497 }
8498 /// Indicates if the query recipient maintains up-to-date channel
8499 /// information for the `chain_hash`
8500 #[no_mangle]
8501 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
8502         let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
8503         *inner_val
8504 }
8505 /// Indicates if the query recipient maintains up-to-date channel
8506 /// information for the `chain_hash`
8507 #[no_mangle]
8508 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
8509         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
8510 }
8511 /// Constructs a new ReplyShortChannelIdsEnd given each field
8512 #[must_use]
8513 #[no_mangle]
8514 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
8515         ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
8516                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8517                 full_information: full_information_arg,
8518         }), is_owned: true }
8519 }
8520 impl Clone for ReplyShortChannelIdsEnd {
8521         fn clone(&self) -> Self {
8522                 Self {
8523                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
8524                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8525                         is_owned: true,
8526                 }
8527         }
8528 }
8529 #[allow(unused)]
8530 /// Used only if an object of this type is returned as a trait impl by a method
8531 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
8532         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
8533 }
8534 #[no_mangle]
8535 /// Creates a copy of the ReplyShortChannelIdsEnd
8536 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
8537         orig.clone()
8538 }
8539 /// Get a string which allows debug introspection of a ReplyShortChannelIdsEnd object
8540 pub extern "C" fn ReplyShortChannelIdsEnd_debug_str_void(o: *const c_void) -> Str {
8541         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyShortChannelIdsEnd }).into()}
8542 /// Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd.
8543 #[no_mangle]
8544 pub extern "C" fn ReplyShortChannelIdsEnd_hash(o: &ReplyShortChannelIdsEnd) -> u64 {
8545         if o.inner.is_null() { return 0; }
8546         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8547         #[allow(deprecated)]
8548         let mut hasher = core::hash::SipHasher::new();
8549         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8550         core::hash::Hasher::finish(&hasher)
8551 }
8552 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
8553 /// This ignores pointers and is_owned flags and looks at the values in fields.
8554 /// Two objects with NULL inner values will be considered "equal" here.
8555 #[no_mangle]
8556 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
8557         if a.inner == b.inner { return true; }
8558         if a.inner.is_null() || b.inner.is_null() { return false; }
8559         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8560 }
8561
8562 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
8563 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
8564
8565 /// A [`gossip_timestamp_filter`] message is used by a node to request
8566 /// gossip relay for messages in the requested time range when the
8567 /// `gossip_queries` feature has been negotiated.
8568 ///
8569 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
8570 #[must_use]
8571 #[repr(C)]
8572 pub struct GossipTimestampFilter {
8573         /// A pointer to the opaque Rust object.
8574
8575         /// Nearly everywhere, inner must be non-null, however in places where
8576         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8577         pub inner: *mut nativeGossipTimestampFilter,
8578         /// Indicates that this is the only struct which contains the same pointer.
8579
8580         /// Rust functions which take ownership of an object provided via an argument require
8581         /// this to be true and invalidate the object pointed to by inner.
8582         pub is_owned: bool,
8583 }
8584
8585 impl Drop for GossipTimestampFilter {
8586         fn drop(&mut self) {
8587                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
8588                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8589                 }
8590         }
8591 }
8592 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
8593 #[no_mangle]
8594 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
8595 #[allow(unused)]
8596 /// Used only if an object of this type is returned as a trait impl by a method
8597 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
8598         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
8599 }
8600 #[allow(unused)]
8601 impl GossipTimestampFilter {
8602         pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
8603                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8604         }
8605         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
8606                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8607         }
8608         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8609         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
8610                 assert!(self.is_owned);
8611                 let ret = ObjOps::untweak_ptr(self.inner);
8612                 self.inner = core::ptr::null_mut();
8613                 ret
8614         }
8615 }
8616 /// The genesis hash of the blockchain for channel and node information
8617 #[no_mangle]
8618 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
8619         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8620         inner_val.as_ref()
8621 }
8622 /// The genesis hash of the blockchain for channel and node information
8623 #[no_mangle]
8624 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
8625         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8626 }
8627 /// The starting unix timestamp
8628 #[no_mangle]
8629 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
8630         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
8631         *inner_val
8632 }
8633 /// The starting unix timestamp
8634 #[no_mangle]
8635 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8636         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
8637 }
8638 /// The range of information in seconds
8639 #[no_mangle]
8640 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
8641         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
8642         *inner_val
8643 }
8644 /// The range of information in seconds
8645 #[no_mangle]
8646 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8647         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
8648 }
8649 /// Constructs a new GossipTimestampFilter given each field
8650 #[must_use]
8651 #[no_mangle]
8652 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 {
8653         GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
8654                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8655                 first_timestamp: first_timestamp_arg,
8656                 timestamp_range: timestamp_range_arg,
8657         }), is_owned: true }
8658 }
8659 impl Clone for GossipTimestampFilter {
8660         fn clone(&self) -> Self {
8661                 Self {
8662                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
8663                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8664                         is_owned: true,
8665                 }
8666         }
8667 }
8668 #[allow(unused)]
8669 /// Used only if an object of this type is returned as a trait impl by a method
8670 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
8671         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeGossipTimestampFilter)).clone() })) as *mut c_void
8672 }
8673 #[no_mangle]
8674 /// Creates a copy of the GossipTimestampFilter
8675 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
8676         orig.clone()
8677 }
8678 /// Get a string which allows debug introspection of a GossipTimestampFilter object
8679 pub extern "C" fn GossipTimestampFilter_debug_str_void(o: *const c_void) -> Str {
8680         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::GossipTimestampFilter }).into()}
8681 /// Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter.
8682 #[no_mangle]
8683 pub extern "C" fn GossipTimestampFilter_hash(o: &GossipTimestampFilter) -> u64 {
8684         if o.inner.is_null() { return 0; }
8685         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8686         #[allow(deprecated)]
8687         let mut hasher = core::hash::SipHasher::new();
8688         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8689         core::hash::Hasher::finish(&hasher)
8690 }
8691 /// Checks if two GossipTimestampFilters contain equal inner contents.
8692 /// This ignores pointers and is_owned flags and looks at the values in fields.
8693 /// Two objects with NULL inner values will be considered "equal" here.
8694 #[no_mangle]
8695 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
8696         if a.inner == b.inner { return true; }
8697         if a.inner.is_null() || b.inner.is_null() { return false; }
8698         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8699 }
8700 /// Used to put an error message in a [`LightningError`].
8701 #[derive(Clone)]
8702 #[must_use]
8703 #[repr(C)]
8704 pub enum ErrorAction {
8705         /// The peer took some action which made us think they were useless. Disconnect them.
8706         DisconnectPeer {
8707                 /// An error message which we should make an effort to send before we disconnect.
8708                 ///
8709                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
8710                 msg: crate::lightning::ln::msgs::ErrorMessage,
8711         },
8712         /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
8713         DisconnectPeerWithWarning {
8714                 /// A warning message which we should make an effort to send before we disconnect.
8715                 msg: crate::lightning::ln::msgs::WarningMessage,
8716         },
8717         /// The peer did something harmless that we weren't able to process, just log and ignore
8718         IgnoreError,
8719         /// The peer did something harmless that we weren't able to meaningfully process.
8720         /// If the error is logged, log it at the given level.
8721         IgnoreAndLog(
8722                 crate::lightning::util::logger::Level),
8723         /// The peer provided us with a gossip message which we'd already seen. In most cases this
8724         /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
8725         /// our own channel announcements.
8726         IgnoreDuplicateGossip,
8727         /// The peer did something incorrect. Tell them.
8728         SendErrorMessage {
8729                 /// The message to send.
8730                 msg: crate::lightning::ln::msgs::ErrorMessage,
8731         },
8732         /// The peer did something incorrect. Tell them without closing any channels.
8733         SendWarningMessage {
8734                 /// The message to send.
8735                 msg: crate::lightning::ln::msgs::WarningMessage,
8736                 /// The peer may have done something harmless that we weren't able to meaningfully process,
8737                 /// though we should still tell them about it.
8738                 /// If this event is logged, log it at the given level.
8739                 log_level: crate::lightning::util::logger::Level,
8740         },
8741 }
8742 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
8743 pub(crate) type nativeErrorAction = ErrorActionImport;
8744
8745 impl ErrorAction {
8746         #[allow(unused)]
8747         pub(crate) fn to_native(&self) -> nativeErrorAction {
8748                 match self {
8749                         ErrorAction::DisconnectPeer {ref msg, } => {
8750                                 let mut msg_nonref = Clone::clone(msg);
8751                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
8752                                 nativeErrorAction::DisconnectPeer {
8753                                         msg: local_msg_nonref,
8754                                 }
8755                         },
8756                         ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8757                                 let mut msg_nonref = Clone::clone(msg);
8758                                 nativeErrorAction::DisconnectPeerWithWarning {
8759                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8760                                 }
8761                         },
8762                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8763                         ErrorAction::IgnoreAndLog (ref a, ) => {
8764                                 let mut a_nonref = Clone::clone(a);
8765                                 nativeErrorAction::IgnoreAndLog (
8766                                         a_nonref.into_native(),
8767                                 )
8768                         },
8769                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8770                         ErrorAction::SendErrorMessage {ref msg, } => {
8771                                 let mut msg_nonref = Clone::clone(msg);
8772                                 nativeErrorAction::SendErrorMessage {
8773                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8774                                 }
8775                         },
8776                         ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8777                                 let mut msg_nonref = Clone::clone(msg);
8778                                 let mut log_level_nonref = Clone::clone(log_level);
8779                                 nativeErrorAction::SendWarningMessage {
8780                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8781                                         log_level: log_level_nonref.into_native(),
8782                                 }
8783                         },
8784                 }
8785         }
8786         #[allow(unused)]
8787         pub(crate) fn into_native(self) -> nativeErrorAction {
8788                 match self {
8789                         ErrorAction::DisconnectPeer {mut msg, } => {
8790                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
8791                                 nativeErrorAction::DisconnectPeer {
8792                                         msg: local_msg,
8793                                 }
8794                         },
8795                         ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8796                                 nativeErrorAction::DisconnectPeerWithWarning {
8797                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
8798                                 }
8799                         },
8800                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8801                         ErrorAction::IgnoreAndLog (mut a, ) => {
8802                                 nativeErrorAction::IgnoreAndLog (
8803                                         a.into_native(),
8804                                 )
8805                         },
8806                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8807                         ErrorAction::SendErrorMessage {mut msg, } => {
8808                                 nativeErrorAction::SendErrorMessage {
8809                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
8810                                 }
8811                         },
8812                         ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8813                                 nativeErrorAction::SendWarningMessage {
8814                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
8815                                         log_level: log_level.into_native(),
8816                                 }
8817                         },
8818                 }
8819         }
8820         #[allow(unused)]
8821         pub(crate) fn from_native(native: &ErrorActionImport) -> Self {
8822                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeErrorAction) };
8823                 match native {
8824                         nativeErrorAction::DisconnectPeer {ref msg, } => {
8825                                 let mut msg_nonref = Clone::clone(msg);
8826                                 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 };
8827                                 ErrorAction::DisconnectPeer {
8828                                         msg: local_msg_nonref,
8829                                 }
8830                         },
8831                         nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8832                                 let mut msg_nonref = Clone::clone(msg);
8833                                 ErrorAction::DisconnectPeerWithWarning {
8834                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8835                                 }
8836                         },
8837                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8838                         nativeErrorAction::IgnoreAndLog (ref a, ) => {
8839                                 let mut a_nonref = Clone::clone(a);
8840                                 ErrorAction::IgnoreAndLog (
8841                                         crate::lightning::util::logger::Level::native_into(a_nonref),
8842                                 )
8843                         },
8844                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8845                         nativeErrorAction::SendErrorMessage {ref msg, } => {
8846                                 let mut msg_nonref = Clone::clone(msg);
8847                                 ErrorAction::SendErrorMessage {
8848                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8849                                 }
8850                         },
8851                         nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8852                                 let mut msg_nonref = Clone::clone(msg);
8853                                 let mut log_level_nonref = Clone::clone(log_level);
8854                                 ErrorAction::SendWarningMessage {
8855                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8856                                         log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
8857                                 }
8858                         },
8859                 }
8860         }
8861         #[allow(unused)]
8862         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
8863                 match native {
8864                         nativeErrorAction::DisconnectPeer {mut msg, } => {
8865                                 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 };
8866                                 ErrorAction::DisconnectPeer {
8867                                         msg: local_msg,
8868                                 }
8869                         },
8870                         nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8871                                 ErrorAction::DisconnectPeerWithWarning {
8872                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8873                                 }
8874                         },
8875                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8876                         nativeErrorAction::IgnoreAndLog (mut a, ) => {
8877                                 ErrorAction::IgnoreAndLog (
8878                                         crate::lightning::util::logger::Level::native_into(a),
8879                                 )
8880                         },
8881                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8882                         nativeErrorAction::SendErrorMessage {mut msg, } => {
8883                                 ErrorAction::SendErrorMessage {
8884                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8885                                 }
8886                         },
8887                         nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8888                                 ErrorAction::SendWarningMessage {
8889                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8890                                         log_level: crate::lightning::util::logger::Level::native_into(log_level),
8891                                 }
8892                         },
8893                 }
8894         }
8895 }
8896 /// Frees any resources used by the ErrorAction
8897 #[no_mangle]
8898 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
8899 /// Creates a copy of the ErrorAction
8900 #[no_mangle]
8901 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
8902         orig.clone()
8903 }
8904 #[allow(unused)]
8905 /// Used only if an object of this type is returned as a trait impl by a method
8906 pub(crate) extern "C" fn ErrorAction_clone_void(this_ptr: *const c_void) -> *mut c_void {
8907         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ErrorAction)).clone() })) as *mut c_void
8908 }
8909 #[allow(unused)]
8910 /// Used only if an object of this type is returned as a trait impl by a method
8911 pub(crate) extern "C" fn ErrorAction_free_void(this_ptr: *mut c_void) {
8912         let _ = unsafe { Box::from_raw(this_ptr as *mut ErrorAction) };
8913 }
8914 #[no_mangle]
8915 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
8916 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8917         ErrorAction::DisconnectPeer {
8918                 msg,
8919         }
8920 }
8921 #[no_mangle]
8922 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
8923 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
8924         ErrorAction::DisconnectPeerWithWarning {
8925                 msg,
8926         }
8927 }
8928 #[no_mangle]
8929 /// Utility method to constructs a new IgnoreError-variant ErrorAction
8930 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
8931         ErrorAction::IgnoreError}
8932 #[no_mangle]
8933 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
8934 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
8935         ErrorAction::IgnoreAndLog(a, )
8936 }
8937 #[no_mangle]
8938 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
8939 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
8940         ErrorAction::IgnoreDuplicateGossip}
8941 #[no_mangle]
8942 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
8943 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8944         ErrorAction::SendErrorMessage {
8945                 msg,
8946         }
8947 }
8948 #[no_mangle]
8949 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
8950 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
8951         ErrorAction::SendWarningMessage {
8952                 msg,
8953                 log_level,
8954         }
8955 }
8956 /// Get a string which allows debug introspection of a ErrorAction object
8957 pub extern "C" fn ErrorAction_debug_str_void(o: *const c_void) -> Str {
8958         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorAction }).into()}
8959 /// Generates a non-cryptographic 64-bit hash of the ErrorAction.
8960 #[no_mangle]
8961 pub extern "C" fn ErrorAction_hash(o: &ErrorAction) -> u64 {
8962         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8963         #[allow(deprecated)]
8964         let mut hasher = core::hash::SipHasher::new();
8965         core::hash::Hash::hash(&o.to_native(), &mut hasher);
8966         core::hash::Hasher::finish(&hasher)
8967 }
8968
8969 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
8970 pub(crate) type nativeLightningError = nativeLightningErrorImport;
8971
8972 /// An Err type for failure to process messages.
8973 #[must_use]
8974 #[repr(C)]
8975 pub struct LightningError {
8976         /// A pointer to the opaque Rust object.
8977
8978         /// Nearly everywhere, inner must be non-null, however in places where
8979         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8980         pub inner: *mut nativeLightningError,
8981         /// Indicates that this is the only struct which contains the same pointer.
8982
8983         /// Rust functions which take ownership of an object provided via an argument require
8984         /// this to be true and invalidate the object pointed to by inner.
8985         pub is_owned: bool,
8986 }
8987
8988 impl Drop for LightningError {
8989         fn drop(&mut self) {
8990                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
8991                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8992                 }
8993         }
8994 }
8995 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
8996 #[no_mangle]
8997 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
8998 #[allow(unused)]
8999 /// Used only if an object of this type is returned as a trait impl by a method
9000 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
9001         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
9002 }
9003 #[allow(unused)]
9004 impl LightningError {
9005         pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
9006                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9007         }
9008         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
9009                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9010         }
9011         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9012         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
9013                 assert!(self.is_owned);
9014                 let ret = ObjOps::untweak_ptr(self.inner);
9015                 self.inner = core::ptr::null_mut();
9016                 ret
9017         }
9018 }
9019 /// A human-readable message describing the error
9020 #[no_mangle]
9021 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
9022         let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
9023         inner_val.as_str().into()
9024 }
9025 /// A human-readable message describing the error
9026 #[no_mangle]
9027 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
9028         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
9029 }
9030 /// The action which should be taken against the offending peer.
9031 #[no_mangle]
9032 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
9033         let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
9034         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
9035 }
9036 /// The action which should be taken against the offending peer.
9037 #[no_mangle]
9038 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
9039         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
9040 }
9041 /// Constructs a new LightningError given each field
9042 #[must_use]
9043 #[no_mangle]
9044 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
9045         LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
9046                 err: err_arg.into_string(),
9047                 action: action_arg.into_native(),
9048         }), is_owned: true }
9049 }
9050 impl Clone for LightningError {
9051         fn clone(&self) -> Self {
9052                 Self {
9053                         inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
9054                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9055                         is_owned: true,
9056                 }
9057         }
9058 }
9059 #[allow(unused)]
9060 /// Used only if an object of this type is returned as a trait impl by a method
9061 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
9062         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLightningError)).clone() })) as *mut c_void
9063 }
9064 #[no_mangle]
9065 /// Creates a copy of the LightningError
9066 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
9067         orig.clone()
9068 }
9069 /// Get a string which allows debug introspection of a LightningError object
9070 pub extern "C" fn LightningError_debug_str_void(o: *const c_void) -> Str {
9071         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::LightningError }).into()}
9072
9073 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
9074 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
9075
9076 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
9077 /// transaction updates if they were pending.
9078 #[must_use]
9079 #[repr(C)]
9080 pub struct CommitmentUpdate {
9081         /// A pointer to the opaque Rust object.
9082
9083         /// Nearly everywhere, inner must be non-null, however in places where
9084         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9085         pub inner: *mut nativeCommitmentUpdate,
9086         /// Indicates that this is the only struct which contains the same pointer.
9087
9088         /// Rust functions which take ownership of an object provided via an argument require
9089         /// this to be true and invalidate the object pointed to by inner.
9090         pub is_owned: bool,
9091 }
9092
9093 impl Drop for CommitmentUpdate {
9094         fn drop(&mut self) {
9095                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
9096                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9097                 }
9098         }
9099 }
9100 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
9101 #[no_mangle]
9102 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
9103 #[allow(unused)]
9104 /// Used only if an object of this type is returned as a trait impl by a method
9105 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
9106         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
9107 }
9108 #[allow(unused)]
9109 impl CommitmentUpdate {
9110         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
9111                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9112         }
9113         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
9114                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9115         }
9116         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9117         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
9118                 assert!(self.is_owned);
9119                 let ret = ObjOps::untweak_ptr(self.inner);
9120                 self.inner = core::ptr::null_mut();
9121                 ret
9122         }
9123 }
9124 /// `update_add_htlc` messages which should be sent
9125 #[no_mangle]
9126 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
9127         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
9128         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 } }); };
9129         local_inner_val.into()
9130 }
9131 /// `update_add_htlc` messages which should be sent
9132 #[no_mangle]
9133 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
9134         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9135         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
9136 }
9137 /// `update_fulfill_htlc` messages which should be sent
9138 #[no_mangle]
9139 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
9140         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
9141         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 } }); };
9142         local_inner_val.into()
9143 }
9144 /// `update_fulfill_htlc` messages which should be sent
9145 #[no_mangle]
9146 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
9147         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9148         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
9149 }
9150 /// `update_fail_htlc` messages which should be sent
9151 #[no_mangle]
9152 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
9153         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
9154         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 } }); };
9155         local_inner_val.into()
9156 }
9157 /// `update_fail_htlc` messages which should be sent
9158 #[no_mangle]
9159 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
9160         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9161         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
9162 }
9163 /// `update_fail_malformed_htlc` messages which should be sent
9164 #[no_mangle]
9165 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
9166         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
9167         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 } }); };
9168         local_inner_val.into()
9169 }
9170 /// `update_fail_malformed_htlc` messages which should be sent
9171 #[no_mangle]
9172 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
9173         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9174         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
9175 }
9176 /// An `update_fee` message which should be sent
9177 ///
9178 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9179 #[no_mangle]
9180 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
9181         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
9182         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 };
9183         local_inner_val
9184 }
9185 /// An `update_fee` message which should be sent
9186 ///
9187 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
9188 #[no_mangle]
9189 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
9190         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
9191         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
9192 }
9193 /// A `commitment_signed` message which should be sent
9194 #[no_mangle]
9195 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
9196         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
9197         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 }
9198 }
9199 /// A `commitment_signed` message which should be sent
9200 #[no_mangle]
9201 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
9202         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
9203 }
9204 /// Constructs a new CommitmentUpdate given each field
9205 ///
9206 /// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
9207 #[must_use]
9208 #[no_mangle]
9209 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 {
9210         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()) } }); };
9211         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()) } }); };
9212         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()) } }); };
9213         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()) } }); };
9214         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()) } }) };
9215         CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
9216                 update_add_htlcs: local_update_add_htlcs_arg,
9217                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
9218                 update_fail_htlcs: local_update_fail_htlcs_arg,
9219                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
9220                 update_fee: local_update_fee_arg,
9221                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
9222         }), is_owned: true }
9223 }
9224 impl Clone for CommitmentUpdate {
9225         fn clone(&self) -> Self {
9226                 Self {
9227                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
9228                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9229                         is_owned: true,
9230                 }
9231         }
9232 }
9233 #[allow(unused)]
9234 /// Used only if an object of this type is returned as a trait impl by a method
9235 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
9236         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentUpdate)).clone() })) as *mut c_void
9237 }
9238 #[no_mangle]
9239 /// Creates a copy of the CommitmentUpdate
9240 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
9241         orig.clone()
9242 }
9243 /// Get a string which allows debug introspection of a CommitmentUpdate object
9244 pub extern "C" fn CommitmentUpdate_debug_str_void(o: *const c_void) -> Str {
9245         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentUpdate }).into()}
9246 /// Generates a non-cryptographic 64-bit hash of the CommitmentUpdate.
9247 #[no_mangle]
9248 pub extern "C" fn CommitmentUpdate_hash(o: &CommitmentUpdate) -> u64 {
9249         if o.inner.is_null() { return 0; }
9250         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
9251         #[allow(deprecated)]
9252         let mut hasher = core::hash::SipHasher::new();
9253         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
9254         core::hash::Hasher::finish(&hasher)
9255 }
9256 /// Checks if two CommitmentUpdates contain equal inner contents.
9257 /// This ignores pointers and is_owned flags and looks at the values in fields.
9258 /// Two objects with NULL inner values will be considered "equal" here.
9259 #[no_mangle]
9260 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
9261         if a.inner == b.inner { return true; }
9262         if a.inner.is_null() || b.inner.is_null() { return false; }
9263         if a.get_native_ref() == b.get_native_ref() { true } else { false }
9264 }
9265 /// A trait to describe an object which can receive channel messages.
9266 ///
9267 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
9268 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
9269 #[repr(C)]
9270 pub struct ChannelMessageHandler {
9271         /// An opaque pointer which is passed to your function implementations as an argument.
9272         /// This has no meaning in the LDK, and can be NULL or any other value.
9273         pub this_arg: *mut c_void,
9274         /// Handle an incoming `open_channel` message from the given peer.
9275         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),
9276         /// Handle an incoming `open_channel2` message from the given peer.
9277         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),
9278         /// Handle an incoming `accept_channel` message from the given peer.
9279         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),
9280         /// Handle an incoming `accept_channel2` message from the given peer.
9281         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),
9282         /// Handle an incoming `funding_created` message from the given peer.
9283         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),
9284         /// Handle an incoming `funding_signed` message from the given peer.
9285         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),
9286         /// Handle an incoming `channel_ready` message from the given peer.
9287         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),
9288         /// Handle an incoming `shutdown` message from the given peer.
9289         pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
9290         /// Handle an incoming `closing_signed` message from the given peer.
9291         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),
9292         /// Handle an incoming `stfu` message from the given peer.
9293         pub handle_stfu: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Stfu),
9294         /// Handle an incoming `splice` message from the given peer.
9295         pub handle_splice: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Splice),
9296         /// Handle an incoming `splice_ack` message from the given peer.
9297         pub handle_splice_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceAck),
9298         /// Handle an incoming `splice_locked` message from the given peer.
9299         pub handle_splice_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceLocked),
9300         /// Handle an incoming `tx_add_input message` from the given peer.
9301         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),
9302         /// Handle an incoming `tx_add_output` message from the given peer.
9303         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),
9304         /// Handle an incoming `tx_remove_input` message from the given peer.
9305         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),
9306         /// Handle an incoming `tx_remove_output` message from the given peer.
9307         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),
9308         /// Handle an incoming `tx_complete message` from the given peer.
9309         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),
9310         /// Handle an incoming `tx_signatures` message from the given peer.
9311         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),
9312         /// Handle an incoming `tx_init_rbf` message from the given peer.
9313         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),
9314         /// Handle an incoming `tx_ack_rbf` message from the given peer.
9315         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),
9316         /// Handle an incoming `tx_abort message` from the given peer.
9317         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),
9318         /// Handle an incoming `update_add_htlc` message from the given peer.
9319         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),
9320         /// Handle an incoming `update_fulfill_htlc` message from the given peer.
9321         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),
9322         /// Handle an incoming `update_fail_htlc` message from the given peer.
9323         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),
9324         /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
9325         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),
9326         /// Handle an incoming `commitment_signed` message from the given peer.
9327         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),
9328         /// Handle an incoming `revoke_and_ack` message from the given peer.
9329         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),
9330         /// Handle an incoming `update_fee` message from the given peer.
9331         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),
9332         /// Handle an incoming `announcement_signatures` message from the given peer.
9333         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),
9334         /// Indicates a connection to the peer failed/an existing connection was lost.
9335         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9336         /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
9337         ///
9338         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9339         /// with us. Implementors should be somewhat conservative about doing so, however, as other
9340         /// message handlers may still wish to communicate with this peer.
9341         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,
9342         /// Handle an incoming `channel_reestablish` message from the given peer.
9343         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),
9344         /// Handle an incoming `channel_update` message from the given peer.
9345         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),
9346         /// Handle an incoming `error` message from the given peer.
9347         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
9348         /// Gets the node feature flags which this handler itself supports. All available handlers are
9349         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9350         /// which are broadcasted in our [`NodeAnnouncement`] message.
9351         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9352         /// Gets the init feature flags which should be sent to the given peer. All available handlers
9353         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9354         /// which are sent in our [`Init`] message.
9355         ///
9356         /// Note that this method is called before [`Self::peer_connected`].
9357         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9358         /// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
9359         ///
9360         /// If it's `None`, then no particular network chain hash compatibility will be enforced when
9361         /// connecting to peers.
9362         pub get_chain_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ,
9363         /// Implementation of MessageSendEventsProvider for this object.
9364         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9365         /// Frees any resources associated with this object given its this_arg pointer.
9366         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9367         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9368 }
9369 unsafe impl Send for ChannelMessageHandler {}
9370 unsafe impl Sync for ChannelMessageHandler {}
9371 #[allow(unused)]
9372 pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
9373         ChannelMessageHandler {
9374                 this_arg: orig.this_arg,
9375                 handle_open_channel: Clone::clone(&orig.handle_open_channel),
9376                 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
9377                 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
9378                 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
9379                 handle_funding_created: Clone::clone(&orig.handle_funding_created),
9380                 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
9381                 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
9382                 handle_shutdown: Clone::clone(&orig.handle_shutdown),
9383                 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
9384                 handle_stfu: Clone::clone(&orig.handle_stfu),
9385                 handle_splice: Clone::clone(&orig.handle_splice),
9386                 handle_splice_ack: Clone::clone(&orig.handle_splice_ack),
9387                 handle_splice_locked: Clone::clone(&orig.handle_splice_locked),
9388                 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
9389                 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
9390                 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
9391                 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
9392                 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
9393                 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
9394                 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
9395                 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
9396                 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
9397                 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
9398                 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
9399                 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
9400                 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
9401                 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
9402                 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
9403                 handle_update_fee: Clone::clone(&orig.handle_update_fee),
9404                 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
9405                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9406                 peer_connected: Clone::clone(&orig.peer_connected),
9407                 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
9408                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9409                 handle_error: Clone::clone(&orig.handle_error),
9410                 provided_node_features: Clone::clone(&orig.provided_node_features),
9411                 provided_init_features: Clone::clone(&orig.provided_init_features),
9412                 get_chain_hashes: Clone::clone(&orig.get_chain_hashes),
9413                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9414                 free: Clone::clone(&orig.free),
9415         }
9416 }
9417 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
9418         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9419                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9420                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9421                 local_ret
9422         }
9423 }
9424
9425 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
9426 impl rustChannelMessageHandler for ChannelMessageHandler {
9427         fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
9428                 (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 })
9429         }
9430         fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
9431                 (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 })
9432         }
9433         fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
9434                 (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 })
9435         }
9436         fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
9437                 (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 })
9438         }
9439         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
9440                 (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 })
9441         }
9442         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
9443                 (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 })
9444         }
9445         fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
9446                 (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 })
9447         }
9448         fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
9449                 (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 })
9450         }
9451         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
9452                 (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 })
9453         }
9454         fn handle_stfu(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Stfu) {
9455                 (self.handle_stfu)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Stfu { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Stfu<>) as *mut _) }, is_owned: false })
9456         }
9457         fn handle_splice(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Splice) {
9458                 (self.handle_splice)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Splice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Splice<>) as *mut _) }, is_owned: false })
9459         }
9460         fn handle_splice_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::SpliceAck) {
9461                 (self.handle_splice_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::SpliceAck { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::SpliceAck<>) as *mut _) }, is_owned: false })
9462         }
9463         fn handle_splice_locked(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::SpliceLocked) {
9464                 (self.handle_splice_locked)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::SpliceLocked { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::SpliceLocked<>) as *mut _) }, is_owned: false })
9465         }
9466         fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
9467                 (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 })
9468         }
9469         fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
9470                 (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 })
9471         }
9472         fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
9473                 (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 })
9474         }
9475         fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
9476                 (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 })
9477         }
9478         fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
9479                 (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 })
9480         }
9481         fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
9482                 (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 })
9483         }
9484         fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
9485                 (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 })
9486         }
9487         fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
9488                 (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 })
9489         }
9490         fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
9491                 (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 })
9492         }
9493         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
9494                 (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 })
9495         }
9496         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
9497                 (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 })
9498         }
9499         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
9500                 (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 })
9501         }
9502         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
9503                 (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 })
9504         }
9505         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
9506                 (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 })
9507         }
9508         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
9509                 (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 })
9510         }
9511         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
9512                 (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 })
9513         }
9514         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
9515                 (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 })
9516         }
9517         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9518                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9519         }
9520         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9521                 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);
9522                 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)) })*/ })};
9523                 local_ret
9524         }
9525         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
9526                 (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 })
9527         }
9528         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
9529                 (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 })
9530         }
9531         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
9532                 (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 })
9533         }
9534         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9535                 let mut ret = (self.provided_node_features)(self.this_arg);
9536                 *unsafe { Box::from_raw(ret.take_inner()) }
9537         }
9538         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9539                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9540                 *unsafe { Box::from_raw(ret.take_inner()) }
9541         }
9542         fn get_chain_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
9543                 let mut ret = (self.get_chain_hashes)(self.this_arg);
9544                 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 }})} };
9545                 local_ret
9546         }
9547 }
9548
9549 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9550 // directly as a Deref trait in higher-level structs:
9551 impl core::ops::Deref for ChannelMessageHandler {
9552         type Target = Self;
9553         fn deref(&self) -> &Self {
9554                 self
9555         }
9556 }
9557 impl core::ops::DerefMut for ChannelMessageHandler {
9558         fn deref_mut(&mut self) -> &mut Self {
9559                 self
9560         }
9561 }
9562 /// Calls the free function if one is set
9563 #[no_mangle]
9564 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
9565 impl Drop for ChannelMessageHandler {
9566         fn drop(&mut self) {
9567                 if let Some(f) = self.free {
9568                         f(self.this_arg);
9569                 }
9570         }
9571 }
9572 /// A trait to describe an object which can receive routing messages.
9573 ///
9574 /// # Implementor DoS Warnings
9575 ///
9576 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
9577 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
9578 /// repeated disk I/O for queries accessing different parts of the network graph.
9579 #[repr(C)]
9580 pub struct RoutingMessageHandler {
9581         /// An opaque pointer which is passed to your function implementations as an argument.
9582         /// This has no meaning in the LDK, and can be NULL or any other value.
9583         pub this_arg: *mut c_void,
9584         /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
9585         /// `false` or returning an `Err` otherwise.
9586         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9587         /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
9588         /// or returning an `Err` otherwise.
9589         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9590         /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
9591         /// `false` or returning an `Err` otherwise.
9592         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9593         /// Gets channel announcements and updates required to dump our routing table to a remote node,
9594         /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
9595         /// for a single channel.
9596         pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
9597         /// Gets a node announcement required to dump our routing table to a remote node, starting at
9598         /// the node *after* the provided pubkey and including up to one announcement immediately
9599         /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
9600         /// If `None` is provided for `starting_point`, we start at the first node.
9601         ///
9602         /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
9603         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9604         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,
9605         /// Called when a connection is established with a peer. This can be used to
9606         /// perform routing table synchronization using a strategy defined by the
9607         /// implementor.
9608         ///
9609         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9610         /// with us. Implementors should be somewhat conservative about doing so, however, as other
9611         /// message handlers may still wish to communicate with this peer.
9612         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,
9613         /// Handles the reply of a query we initiated to learn about channels
9614         /// for a given range of blocks. We can expect to receive one or more
9615         /// replies to a single query.
9616         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,
9617         /// Handles the reply of a query we initiated asking for routing gossip
9618         /// messages for a list of channels. We should receive this message when
9619         /// a node has completed its best effort to send us the pertaining routing
9620         /// gossip messages.
9621         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,
9622         /// Handles when a peer asks us to send a list of `short_channel_id`s
9623         /// for the requested range of blocks.
9624         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,
9625         /// Handles when a peer asks us to send routing gossip messages for a
9626         /// list of `short_channel_id`s.
9627         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,
9628         /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
9629         /// pending some async action. While there is no guarantee of the rate of future messages, the
9630         /// caller should seek to reduce the rate of new gossip messages handled, especially
9631         /// [`ChannelAnnouncement`]s.
9632         pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
9633         /// Gets the node feature flags which this handler itself supports. All available handlers are
9634         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9635         /// which are broadcasted in our [`NodeAnnouncement`] message.
9636         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9637         /// Gets the init feature flags which should be sent to the given peer. All available handlers
9638         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9639         /// which are sent in our [`Init`] message.
9640         ///
9641         /// Note that this method is called before [`Self::peer_connected`].
9642         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9643         /// Implementation of MessageSendEventsProvider for this object.
9644         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9645         /// Frees any resources associated with this object given its this_arg pointer.
9646         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9647         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9648 }
9649 unsafe impl Send for RoutingMessageHandler {}
9650 unsafe impl Sync for RoutingMessageHandler {}
9651 #[allow(unused)]
9652 pub(crate) fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
9653         RoutingMessageHandler {
9654                 this_arg: orig.this_arg,
9655                 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
9656                 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
9657                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9658                 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
9659                 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
9660                 peer_connected: Clone::clone(&orig.peer_connected),
9661                 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
9662                 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
9663                 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
9664                 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
9665                 processing_queue_high: Clone::clone(&orig.processing_queue_high),
9666                 provided_node_features: Clone::clone(&orig.provided_node_features),
9667                 provided_init_features: Clone::clone(&orig.provided_init_features),
9668                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9669                 free: Clone::clone(&orig.free),
9670         }
9671 }
9672 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
9673         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9674                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9675                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9676                 local_ret
9677         }
9678 }
9679
9680 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
9681 impl rustRoutingMessageHandler for RoutingMessageHandler {
9682         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9683                 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 });
9684                 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()) } })};
9685                 local_ret
9686         }
9687         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9688                 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 });
9689                 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()) } })};
9690                 local_ret
9691         }
9692         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
9693                 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 });
9694                 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()) } })};
9695                 local_ret
9696         }
9697         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>)> {
9698                 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
9699                 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 };
9700                 local_ret
9701         }
9702         fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
9703                 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 };
9704                 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
9705                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9706                 local_ret
9707         }
9708         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9709                 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);
9710                 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)) })*/ })};
9711                 local_ret
9712         }
9713         fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9714                 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 });
9715                 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()) } })};
9716                 local_ret
9717         }
9718         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> {
9719                 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 });
9720                 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()) } })};
9721                 local_ret
9722         }
9723         fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9724                 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 });
9725                 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()) } })};
9726                 local_ret
9727         }
9728         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> {
9729                 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 });
9730                 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()) } })};
9731                 local_ret
9732         }
9733         fn processing_queue_high(&self) -> bool {
9734                 let mut ret = (self.processing_queue_high)(self.this_arg);
9735                 ret
9736         }
9737         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9738                 let mut ret = (self.provided_node_features)(self.this_arg);
9739                 *unsafe { Box::from_raw(ret.take_inner()) }
9740         }
9741         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9742                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9743                 *unsafe { Box::from_raw(ret.take_inner()) }
9744         }
9745 }
9746
9747 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9748 // directly as a Deref trait in higher-level structs:
9749 impl core::ops::Deref for RoutingMessageHandler {
9750         type Target = Self;
9751         fn deref(&self) -> &Self {
9752                 self
9753         }
9754 }
9755 impl core::ops::DerefMut for RoutingMessageHandler {
9756         fn deref_mut(&mut self) -> &mut Self {
9757                 self
9758         }
9759 }
9760 /// Calls the free function if one is set
9761 #[no_mangle]
9762 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
9763 impl Drop for RoutingMessageHandler {
9764         fn drop(&mut self) {
9765                 if let Some(f) = self.free {
9766                         f(self.this_arg);
9767                 }
9768         }
9769 }
9770 /// A handler for received [`OnionMessage`]s and for providing generated ones to send.
9771 #[repr(C)]
9772 pub struct OnionMessageHandler {
9773         /// An opaque pointer which is passed to your function implementations as an argument.
9774         /// This has no meaning in the LDK, and can be NULL or any other value.
9775         pub this_arg: *mut c_void,
9776         /// Because much of the lightning network does not yet support forwarding onion messages, we
9777         /// may need to directly connect to a node which will forward a message for us. In such a case,
9778         /// this method will return the set of nodes which need connection by node_id and the
9779         /// corresponding socket addresses where they may accept incoming connections.
9780         ///
9781         /// Thus, this method should be polled regularly to detect messages await such a direct
9782         /// connection.
9783         pub get_and_clear_connections_needed: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ,
9784         /// Handle an incoming `onion_message` message from the given peer.
9785         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),
9786         /// Returns the next pending onion message for the peer with the given node id.
9787         ///
9788         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9789         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,
9790         /// Called when a connection is established with a peer. Can be used to track which peers
9791         /// advertise onion message support and are online.
9792         ///
9793         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9794         /// with us. Implementors should be somewhat conservative about doing so, however, as other
9795         /// message handlers may still wish to communicate with this peer.
9796         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,
9797         /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
9798         /// drop and refuse to forward onion messages to this peer.
9799         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9800         /// Performs actions that should happen roughly every ten seconds after startup. Allows handlers
9801         /// to drop any buffered onion messages intended for prospective peers.
9802         pub timer_tick_occurred: extern "C" fn (this_arg: *const c_void),
9803         /// Gets the node feature flags which this handler itself supports. All available handlers are
9804         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9805         /// which are broadcasted in our [`NodeAnnouncement`] message.
9806         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9807         /// Gets the init feature flags which should be sent to the given peer. All available handlers
9808         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9809         /// which are sent in our [`Init`] message.
9810         ///
9811         /// Note that this method is called before [`Self::peer_connected`].
9812         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9813         /// Frees any resources associated with this object given its this_arg pointer.
9814         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9815         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9816 }
9817 unsafe impl Send for OnionMessageHandler {}
9818 unsafe impl Sync for OnionMessageHandler {}
9819 #[allow(unused)]
9820 pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
9821         OnionMessageHandler {
9822                 this_arg: orig.this_arg,
9823                 get_and_clear_connections_needed: Clone::clone(&orig.get_and_clear_connections_needed),
9824                 handle_onion_message: Clone::clone(&orig.handle_onion_message),
9825                 next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
9826                 peer_connected: Clone::clone(&orig.peer_connected),
9827                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9828                 timer_tick_occurred: Clone::clone(&orig.timer_tick_occurred),
9829                 provided_node_features: Clone::clone(&orig.provided_node_features),
9830                 provided_init_features: Clone::clone(&orig.provided_init_features),
9831                 free: Clone::clone(&orig.free),
9832         }
9833 }
9834
9835 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
9836 impl rustOnionMessageHandler for OnionMessageHandler {
9837         fn get_and_clear_connections_needed(&self) -> Vec<(bitcoin::secp256k1::PublicKey, Vec<lightning::ln::msgs::SocketAddress>)> {
9838                 let mut ret = (self.get_and_clear_connections_needed)(self.this_arg);
9839                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_native() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }); };
9840                 local_ret
9841         }
9842         fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
9843                 (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 })
9844         }
9845         fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
9846                 let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
9847                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9848                 local_ret
9849         }
9850         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9851                 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);
9852                 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)) })*/ })};
9853                 local_ret
9854         }
9855         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9856                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9857         }
9858         fn timer_tick_occurred(&self) {
9859                 (self.timer_tick_occurred)(self.this_arg)
9860         }
9861         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9862                 let mut ret = (self.provided_node_features)(self.this_arg);
9863                 *unsafe { Box::from_raw(ret.take_inner()) }
9864         }
9865         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9866                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9867                 *unsafe { Box::from_raw(ret.take_inner()) }
9868         }
9869 }
9870
9871 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9872 // directly as a Deref trait in higher-level structs:
9873 impl core::ops::Deref for OnionMessageHandler {
9874         type Target = Self;
9875         fn deref(&self) -> &Self {
9876                 self
9877         }
9878 }
9879 impl core::ops::DerefMut for OnionMessageHandler {
9880         fn deref_mut(&mut self) -> &mut Self {
9881                 self
9882         }
9883 }
9884 /// Calls the free function if one is set
9885 #[no_mangle]
9886 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
9887 impl Drop for OnionMessageHandler {
9888         fn drop(&mut self) {
9889                 if let Some(f) = self.free {
9890                         f(self.this_arg);
9891                 }
9892         }
9893 }
9894
9895 use lightning::ln::msgs::FinalOnionHopData as nativeFinalOnionHopDataImport;
9896 pub(crate) type nativeFinalOnionHopData = nativeFinalOnionHopDataImport;
9897
9898 /// Information communicated in the onion to the recipient for multi-part tracking and proof that
9899 /// the payment is associated with an invoice.
9900 #[must_use]
9901 #[repr(C)]
9902 pub struct FinalOnionHopData {
9903         /// A pointer to the opaque Rust object.
9904
9905         /// Nearly everywhere, inner must be non-null, however in places where
9906         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9907         pub inner: *mut nativeFinalOnionHopData,
9908         /// Indicates that this is the only struct which contains the same pointer.
9909
9910         /// Rust functions which take ownership of an object provided via an argument require
9911         /// this to be true and invalidate the object pointed to by inner.
9912         pub is_owned: bool,
9913 }
9914
9915 impl Drop for FinalOnionHopData {
9916         fn drop(&mut self) {
9917                 if self.is_owned && !<*mut nativeFinalOnionHopData>::is_null(self.inner) {
9918                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9919                 }
9920         }
9921 }
9922 /// Frees any resources used by the FinalOnionHopData, if is_owned is set and inner is non-NULL.
9923 #[no_mangle]
9924 pub extern "C" fn FinalOnionHopData_free(this_obj: FinalOnionHopData) { }
9925 #[allow(unused)]
9926 /// Used only if an object of this type is returned as a trait impl by a method
9927 pub(crate) extern "C" fn FinalOnionHopData_free_void(this_ptr: *mut c_void) {
9928         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFinalOnionHopData) };
9929 }
9930 #[allow(unused)]
9931 impl FinalOnionHopData {
9932         pub(crate) fn get_native_ref(&self) -> &'static nativeFinalOnionHopData {
9933                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9934         }
9935         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFinalOnionHopData {
9936                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9937         }
9938         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9939         pub(crate) fn take_inner(mut self) -> *mut nativeFinalOnionHopData {
9940                 assert!(self.is_owned);
9941                 let ret = ObjOps::untweak_ptr(self.inner);
9942                 self.inner = core::ptr::null_mut();
9943                 ret
9944         }
9945 }
9946 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9947 /// Because it is generated by the recipient and included in the invoice, it also provides
9948 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9949 #[no_mangle]
9950 pub extern "C" fn FinalOnionHopData_get_payment_secret(this_ptr: &FinalOnionHopData) -> *const [u8; 32] {
9951         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret;
9952         &inner_val.0
9953 }
9954 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9955 /// Because it is generated by the recipient and included in the invoice, it also provides
9956 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9957 #[no_mangle]
9958 pub extern "C" fn FinalOnionHopData_set_payment_secret(this_ptr: &mut FinalOnionHopData, mut val: crate::c_types::ThirtyTwoBytes) {
9959         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::PaymentSecret(val.data);
9960 }
9961 /// The intended total amount that this payment is for.
9962 ///
9963 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9964 #[no_mangle]
9965 pub extern "C" fn FinalOnionHopData_get_total_msat(this_ptr: &FinalOnionHopData) -> u64 {
9966         let mut inner_val = &mut this_ptr.get_native_mut_ref().total_msat;
9967         *inner_val
9968 }
9969 /// The intended total amount that this payment is for.
9970 ///
9971 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9972 #[no_mangle]
9973 pub extern "C" fn FinalOnionHopData_set_total_msat(this_ptr: &mut FinalOnionHopData, mut val: u64) {
9974         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.total_msat = val;
9975 }
9976 /// Constructs a new FinalOnionHopData given each field
9977 #[must_use]
9978 #[no_mangle]
9979 pub extern "C" fn FinalOnionHopData_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut total_msat_arg: u64) -> FinalOnionHopData {
9980         FinalOnionHopData { inner: ObjOps::heap_alloc(nativeFinalOnionHopData {
9981                 payment_secret: ::lightning::ln::PaymentSecret(payment_secret_arg.data),
9982                 total_msat: total_msat_arg,
9983         }), is_owned: true }
9984 }
9985 impl Clone for FinalOnionHopData {
9986         fn clone(&self) -> Self {
9987                 Self {
9988                         inner: if <*mut nativeFinalOnionHopData>::is_null(self.inner) { core::ptr::null_mut() } else {
9989                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9990                         is_owned: true,
9991                 }
9992         }
9993 }
9994 #[allow(unused)]
9995 /// Used only if an object of this type is returned as a trait impl by a method
9996 pub(crate) extern "C" fn FinalOnionHopData_clone_void(this_ptr: *const c_void) -> *mut c_void {
9997         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFinalOnionHopData)).clone() })) as *mut c_void
9998 }
9999 #[no_mangle]
10000 /// Creates a copy of the FinalOnionHopData
10001 pub extern "C" fn FinalOnionHopData_clone(orig: &FinalOnionHopData) -> FinalOnionHopData {
10002         orig.clone()
10003 }
10004 mod fuzzy_internal_msgs {
10005
10006 use alloc::str::FromStr;
10007 use alloc::string::String;
10008 use core::ffi::c_void;
10009 use core::convert::Infallible;
10010 use bitcoin::hashes::Hash;
10011 use crate::c_types::*;
10012 #[cfg(feature="no-std")]
10013 use alloc::{vec::Vec, boxed::Box};
10014
10015 }
10016
10017 use lightning::ln::msgs::OnionPacket as nativeOnionPacketImport;
10018 pub(crate) type nativeOnionPacket = nativeOnionPacketImport;
10019
10020 /// BOLT 4 onion packet including hop data for the next peer.
10021 #[must_use]
10022 #[repr(C)]
10023 pub struct OnionPacket {
10024         /// A pointer to the opaque Rust object.
10025
10026         /// Nearly everywhere, inner must be non-null, however in places where
10027         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
10028         pub inner: *mut nativeOnionPacket,
10029         /// Indicates that this is the only struct which contains the same pointer.
10030
10031         /// Rust functions which take ownership of an object provided via an argument require
10032         /// this to be true and invalidate the object pointed to by inner.
10033         pub is_owned: bool,
10034 }
10035
10036 impl Drop for OnionPacket {
10037         fn drop(&mut self) {
10038                 if self.is_owned && !<*mut nativeOnionPacket>::is_null(self.inner) {
10039                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
10040                 }
10041         }
10042 }
10043 /// Frees any resources used by the OnionPacket, if is_owned is set and inner is non-NULL.
10044 #[no_mangle]
10045 pub extern "C" fn OnionPacket_free(this_obj: OnionPacket) { }
10046 #[allow(unused)]
10047 /// Used only if an object of this type is returned as a trait impl by a method
10048 pub(crate) extern "C" fn OnionPacket_free_void(this_ptr: *mut c_void) {
10049         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionPacket) };
10050 }
10051 #[allow(unused)]
10052 impl OnionPacket {
10053         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionPacket {
10054                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
10055         }
10056         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionPacket {
10057                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
10058         }
10059         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
10060         pub(crate) fn take_inner(mut self) -> *mut nativeOnionPacket {
10061                 assert!(self.is_owned);
10062                 let ret = ObjOps::untweak_ptr(self.inner);
10063                 self.inner = core::ptr::null_mut();
10064                 ret
10065         }
10066 }
10067 /// BOLT 4 version number.
10068 #[no_mangle]
10069 pub extern "C" fn OnionPacket_get_version(this_ptr: &OnionPacket) -> u8 {
10070         let mut inner_val = &mut this_ptr.get_native_mut_ref().version;
10071         *inner_val
10072 }
10073 /// BOLT 4 version number.
10074 #[no_mangle]
10075 pub extern "C" fn OnionPacket_set_version(this_ptr: &mut OnionPacket, mut val: u8) {
10076         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val;
10077 }
10078 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
10079 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
10080 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
10081 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
10082 /// like.
10083 ///
10084 /// Returns a copy of the field.
10085 #[no_mangle]
10086 pub extern "C" fn OnionPacket_get_public_key(this_ptr: &OnionPacket) -> crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ {
10087         let mut inner_val = this_ptr.get_native_mut_ref().public_key.clone();
10088         let mut local_inner_val = match inner_val { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
10089         local_inner_val
10090 }
10091 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
10092 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
10093 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
10094 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
10095 /// like.
10096 #[no_mangle]
10097 pub extern "C" fn OnionPacket_set_public_key(this_ptr: &mut OnionPacket, mut val: crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ) {
10098         let mut local_val = match val.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut val.contents.result)) }).into_rust() }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut val.contents.err)) }).into_rust() })};
10099         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = local_val;
10100 }
10101 /// HMAC to verify the integrity of hop_data.
10102 #[no_mangle]
10103 pub extern "C" fn OnionPacket_get_hmac(this_ptr: &OnionPacket) -> *const [u8; 32] {
10104         let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac;
10105         inner_val
10106 }
10107 /// HMAC to verify the integrity of hop_data.
10108 #[no_mangle]
10109 pub extern "C" fn OnionPacket_set_hmac(this_ptr: &mut OnionPacket, mut val: crate::c_types::ThirtyTwoBytes) {
10110         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data;
10111 }
10112 impl Clone for OnionPacket {
10113         fn clone(&self) -> Self {
10114                 Self {
10115                         inner: if <*mut nativeOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else {
10116                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
10117                         is_owned: true,
10118                 }
10119         }
10120 }
10121 #[allow(unused)]
10122 /// Used only if an object of this type is returned as a trait impl by a method
10123 pub(crate) extern "C" fn OnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void {
10124         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionPacket)).clone() })) as *mut c_void
10125 }
10126 #[no_mangle]
10127 /// Creates a copy of the OnionPacket
10128 pub extern "C" fn OnionPacket_clone(orig: &OnionPacket) -> OnionPacket {
10129         orig.clone()
10130 }
10131 /// Generates a non-cryptographic 64-bit hash of the OnionPacket.
10132 #[no_mangle]
10133 pub extern "C" fn OnionPacket_hash(o: &OnionPacket) -> u64 {
10134         if o.inner.is_null() { return 0; }
10135         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
10136         #[allow(deprecated)]
10137         let mut hasher = core::hash::SipHasher::new();
10138         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
10139         core::hash::Hasher::finish(&hasher)
10140 }
10141 /// Checks if two OnionPackets contain equal inner contents.
10142 /// This ignores pointers and is_owned flags and looks at the values in fields.
10143 /// Two objects with NULL inner values will be considered "equal" here.
10144 #[no_mangle]
10145 pub extern "C" fn OnionPacket_eq(a: &OnionPacket, b: &OnionPacket) -> bool {
10146         if a.inner == b.inner { return true; }
10147         if a.inner.is_null() || b.inner.is_null() { return false; }
10148         if a.get_native_ref() == b.get_native_ref() { true } else { false }
10149 }
10150 /// Get a string which allows debug introspection of a OnionPacket object
10151 pub extern "C" fn OnionPacket_debug_str_void(o: *const c_void) -> Str {
10152         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionPacket }).into()}
10153 #[no_mangle]
10154 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
10155 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
10156         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10157 }
10158 #[allow(unused)]
10159 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10160         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
10161 }
10162 #[no_mangle]
10163 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
10164 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
10165         let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10166         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() };
10167         local_res
10168 }
10169 #[no_mangle]
10170 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
10171 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
10172         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10173 }
10174 #[allow(unused)]
10175 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10176         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
10177 }
10178 #[no_mangle]
10179 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
10180 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
10181         let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10182         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() };
10183         local_res
10184 }
10185 #[no_mangle]
10186 /// Serialize the Stfu object into a byte array which can be read by Stfu_read
10187 pub extern "C" fn Stfu_write(obj: &crate::lightning::ln::msgs::Stfu) -> crate::c_types::derived::CVec_u8Z {
10188         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10189 }
10190 #[allow(unused)]
10191 pub(crate) extern "C" fn Stfu_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10192         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStfu) })
10193 }
10194 #[no_mangle]
10195 /// Read a Stfu from a byte array, created by Stfu_write
10196 pub extern "C" fn Stfu_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_StfuDecodeErrorZ {
10197         let res: Result<lightning::ln::msgs::Stfu, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10198         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Stfu { 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() };
10199         local_res
10200 }
10201 #[no_mangle]
10202 /// Serialize the Splice object into a byte array which can be read by Splice_read
10203 pub extern "C" fn Splice_write(obj: &crate::lightning::ln::msgs::Splice) -> crate::c_types::derived::CVec_u8Z {
10204         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10205 }
10206 #[allow(unused)]
10207 pub(crate) extern "C" fn Splice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10208         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSplice) })
10209 }
10210 #[no_mangle]
10211 /// Read a Splice from a byte array, created by Splice_write
10212 pub extern "C" fn Splice_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceDecodeErrorZ {
10213         let res: Result<lightning::ln::msgs::Splice, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10214         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Splice { 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() };
10215         local_res
10216 }
10217 #[no_mangle]
10218 /// Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read
10219 pub extern "C" fn SpliceAck_write(obj: &crate::lightning::ln::msgs::SpliceAck) -> crate::c_types::derived::CVec_u8Z {
10220         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10221 }
10222 #[allow(unused)]
10223 pub(crate) extern "C" fn SpliceAck_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10224         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceAck) })
10225 }
10226 #[no_mangle]
10227 /// Read a SpliceAck from a byte array, created by SpliceAck_write
10228 pub extern "C" fn SpliceAck_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceAckDecodeErrorZ {
10229         let res: Result<lightning::ln::msgs::SpliceAck, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10230         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SpliceAck { 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() };
10231         local_res
10232 }
10233 #[no_mangle]
10234 /// Serialize the SpliceLocked object into a byte array which can be read by SpliceLocked_read
10235 pub extern "C" fn SpliceLocked_write(obj: &crate::lightning::ln::msgs::SpliceLocked) -> crate::c_types::derived::CVec_u8Z {
10236         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10237 }
10238 #[allow(unused)]
10239 pub(crate) extern "C" fn SpliceLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10240         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceLocked) })
10241 }
10242 #[no_mangle]
10243 /// Read a SpliceLocked from a byte array, created by SpliceLocked_write
10244 pub extern "C" fn SpliceLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceLockedDecodeErrorZ {
10245         let res: Result<lightning::ln::msgs::SpliceLocked, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10246         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SpliceLocked { 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() };
10247         local_res
10248 }
10249 #[no_mangle]
10250 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
10251 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
10252         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10253 }
10254 #[allow(unused)]
10255 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10256         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
10257 }
10258 #[no_mangle]
10259 /// Read a TxAddInput from a byte array, created by TxAddInput_write
10260 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
10261         let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10262         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() };
10263         local_res
10264 }
10265 #[no_mangle]
10266 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
10267 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
10268         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10269 }
10270 #[allow(unused)]
10271 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10272         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
10273 }
10274 #[no_mangle]
10275 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
10276 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
10277         let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10278         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() };
10279         local_res
10280 }
10281 #[no_mangle]
10282 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
10283 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
10284         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10285 }
10286 #[allow(unused)]
10287 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10288         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
10289 }
10290 #[no_mangle]
10291 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
10292 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
10293         let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10294         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() };
10295         local_res
10296 }
10297 #[no_mangle]
10298 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
10299 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
10300         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10301 }
10302 #[allow(unused)]
10303 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10304         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
10305 }
10306 #[no_mangle]
10307 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
10308 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
10309         let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10310         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() };
10311         local_res
10312 }
10313 #[no_mangle]
10314 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
10315 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
10316         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10317 }
10318 #[allow(unused)]
10319 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10320         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
10321 }
10322 #[no_mangle]
10323 /// Read a TxComplete from a byte array, created by TxComplete_write
10324 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
10325         let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10326         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() };
10327         local_res
10328 }
10329 #[no_mangle]
10330 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
10331 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
10332         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10333 }
10334 #[allow(unused)]
10335 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10336         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
10337 }
10338 #[no_mangle]
10339 /// Read a TxSignatures from a byte array, created by TxSignatures_write
10340 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
10341         let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10342         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() };
10343         local_res
10344 }
10345 #[no_mangle]
10346 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
10347 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
10348         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10349 }
10350 #[allow(unused)]
10351 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10352         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
10353 }
10354 #[no_mangle]
10355 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
10356 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
10357         let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10358         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() };
10359         local_res
10360 }
10361 #[no_mangle]
10362 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
10363 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
10364         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10365 }
10366 #[allow(unused)]
10367 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10368         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
10369 }
10370 #[no_mangle]
10371 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
10372 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
10373         let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10374         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() };
10375         local_res
10376 }
10377 #[no_mangle]
10378 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
10379 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
10380         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10381 }
10382 #[allow(unused)]
10383 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10384         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
10385 }
10386 #[no_mangle]
10387 /// Read a TxAbort from a byte array, created by TxAbort_write
10388 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
10389         let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10390         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() };
10391         local_res
10392 }
10393 #[no_mangle]
10394 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
10395 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
10396         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10397 }
10398 #[allow(unused)]
10399 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10400         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
10401 }
10402 #[no_mangle]
10403 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
10404 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
10405         let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10406         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() };
10407         local_res
10408 }
10409 #[no_mangle]
10410 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
10411 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
10412         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10413 }
10414 #[allow(unused)]
10415 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10416         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
10417 }
10418 #[no_mangle]
10419 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
10420 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
10421         let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10422         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() };
10423         local_res
10424 }
10425 #[no_mangle]
10426 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
10427 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
10428         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10429 }
10430 #[allow(unused)]
10431 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10432         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
10433 }
10434 #[no_mangle]
10435 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
10436 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
10437         let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10438         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() };
10439         local_res
10440 }
10441 #[no_mangle]
10442 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
10443 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
10444         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10445 }
10446 #[allow(unused)]
10447 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10448         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
10449 }
10450 #[no_mangle]
10451 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
10452 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
10453         let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10454         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() };
10455         local_res
10456 }
10457 #[no_mangle]
10458 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
10459 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
10460         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10461 }
10462 #[allow(unused)]
10463 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10464         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
10465 }
10466 #[no_mangle]
10467 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
10468 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
10469         let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10470         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() };
10471         local_res
10472 }
10473 #[no_mangle]
10474 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
10475 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
10476         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10477 }
10478 #[allow(unused)]
10479 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10480         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
10481 }
10482 #[no_mangle]
10483 /// Read a FundingCreated from a byte array, created by FundingCreated_write
10484 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
10485         let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10486         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() };
10487         local_res
10488 }
10489 #[no_mangle]
10490 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
10491 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
10492         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10493 }
10494 #[allow(unused)]
10495 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10496         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
10497 }
10498 #[no_mangle]
10499 /// Read a FundingSigned from a byte array, created by FundingSigned_write
10500 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
10501         let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10502         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() };
10503         local_res
10504 }
10505 #[no_mangle]
10506 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
10507 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
10508         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10509 }
10510 #[allow(unused)]
10511 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10512         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
10513 }
10514 #[no_mangle]
10515 /// Read a ChannelReady from a byte array, created by ChannelReady_write
10516 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
10517         let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10518         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() };
10519         local_res
10520 }
10521 #[no_mangle]
10522 /// Serialize the Init object into a byte array which can be read by Init_read
10523 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
10524         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10525 }
10526 #[allow(unused)]
10527 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10528         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
10529 }
10530 #[no_mangle]
10531 /// Read a Init from a byte array, created by Init_write
10532 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
10533         let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10534         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() };
10535         local_res
10536 }
10537 #[no_mangle]
10538 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
10539 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
10540         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10541 }
10542 #[allow(unused)]
10543 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10544         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
10545 }
10546 #[no_mangle]
10547 /// Read a OpenChannel from a byte array, created by OpenChannel_write
10548 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
10549         let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10550         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() };
10551         local_res
10552 }
10553 #[no_mangle]
10554 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
10555 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
10556         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10557 }
10558 #[allow(unused)]
10559 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10560         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
10561 }
10562 #[no_mangle]
10563 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
10564 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
10565         let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10566         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() };
10567         local_res
10568 }
10569 #[no_mangle]
10570 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
10571 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
10572         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10573 }
10574 #[allow(unused)]
10575 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10576         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
10577 }
10578 #[no_mangle]
10579 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
10580 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
10581         let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10582         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() };
10583         local_res
10584 }
10585 #[no_mangle]
10586 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
10587 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
10588         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10589 }
10590 #[allow(unused)]
10591 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10592         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
10593 }
10594 #[no_mangle]
10595 /// Read a Shutdown from a byte array, created by Shutdown_write
10596 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
10597         let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10598         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() };
10599         local_res
10600 }
10601 #[no_mangle]
10602 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
10603 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
10604         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10605 }
10606 #[allow(unused)]
10607 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10608         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
10609 }
10610 #[no_mangle]
10611 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
10612 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
10613         let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10614         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() };
10615         local_res
10616 }
10617 #[no_mangle]
10618 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
10619 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
10620         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10621 }
10622 #[allow(unused)]
10623 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10624         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
10625 }
10626 #[no_mangle]
10627 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
10628 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
10629         let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10630         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() };
10631         local_res
10632 }
10633 #[no_mangle]
10634 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
10635 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
10636         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10637 }
10638 #[allow(unused)]
10639 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10640         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
10641 }
10642 #[no_mangle]
10643 /// Read a UpdateFee from a byte array, created by UpdateFee_write
10644 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
10645         let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10646         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() };
10647         local_res
10648 }
10649 #[no_mangle]
10650 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
10651 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
10652         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10653 }
10654 #[allow(unused)]
10655 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10656         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
10657 }
10658 #[no_mangle]
10659 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
10660 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
10661         let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10662         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() };
10663         local_res
10664 }
10665 #[no_mangle]
10666 /// Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read
10667 pub extern "C" fn OnionPacket_write(obj: &crate::lightning::ln::msgs::OnionPacket) -> crate::c_types::derived::CVec_u8Z {
10668         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10669 }
10670 #[allow(unused)]
10671 pub(crate) extern "C" fn OnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10672         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionPacket) })
10673 }
10674 #[no_mangle]
10675 /// Read a OnionPacket from a byte array, created by OnionPacket_write
10676 pub extern "C" fn OnionPacket_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionPacketDecodeErrorZ {
10677         let res: Result<lightning::ln::msgs::OnionPacket, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10678         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OnionPacket { 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() };
10679         local_res
10680 }
10681 #[no_mangle]
10682 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
10683 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
10684         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10685 }
10686 #[allow(unused)]
10687 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10688         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
10689 }
10690 #[no_mangle]
10691 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
10692 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
10693         let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10694         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() };
10695         local_res
10696 }
10697 #[no_mangle]
10698 /// Read a OnionMessage from a byte array, created by OnionMessage_write
10699 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
10700         let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10701         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() };
10702         local_res
10703 }
10704 #[no_mangle]
10705 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
10706 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
10707         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10708 }
10709 #[allow(unused)]
10710 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10711         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
10712 }
10713 #[no_mangle]
10714 /// Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read
10715 pub extern "C" fn FinalOnionHopData_write(obj: &crate::lightning::ln::msgs::FinalOnionHopData) -> crate::c_types::derived::CVec_u8Z {
10716         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10717 }
10718 #[allow(unused)]
10719 pub(crate) extern "C" fn FinalOnionHopData_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10720         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFinalOnionHopData) })
10721 }
10722 #[no_mangle]
10723 /// Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write
10724 pub extern "C" fn FinalOnionHopData_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FinalOnionHopDataDecodeErrorZ {
10725         let res: Result<lightning::ln::msgs::FinalOnionHopData, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10726         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FinalOnionHopData { 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() };
10727         local_res
10728 }
10729 #[no_mangle]
10730 /// Serialize the Ping object into a byte array which can be read by Ping_read
10731 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
10732         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10733 }
10734 #[allow(unused)]
10735 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10736         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
10737 }
10738 #[no_mangle]
10739 /// Read a Ping from a byte array, created by Ping_write
10740 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
10741         let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10742         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() };
10743         local_res
10744 }
10745 #[no_mangle]
10746 /// Serialize the Pong object into a byte array which can be read by Pong_read
10747 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
10748         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10749 }
10750 #[allow(unused)]
10751 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10752         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
10753 }
10754 #[no_mangle]
10755 /// Read a Pong from a byte array, created by Pong_write
10756 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
10757         let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10758         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() };
10759         local_res
10760 }
10761 #[no_mangle]
10762 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
10763 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10764         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10765 }
10766 #[allow(unused)]
10767 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10768         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
10769 }
10770 #[no_mangle]
10771 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
10772 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
10773         let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10774         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() };
10775         local_res
10776 }
10777 #[no_mangle]
10778 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
10779 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10780         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10781 }
10782 #[allow(unused)]
10783 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10784         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
10785 }
10786 #[no_mangle]
10787 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
10788 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
10789         let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10790         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() };
10791         local_res
10792 }
10793 #[no_mangle]
10794 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
10795 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10796         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10797 }
10798 #[allow(unused)]
10799 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10800         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
10801 }
10802 #[no_mangle]
10803 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
10804 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
10805         let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10806         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() };
10807         local_res
10808 }
10809 #[no_mangle]
10810 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
10811 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10812         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10813 }
10814 #[allow(unused)]
10815 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10816         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
10817 }
10818 #[no_mangle]
10819 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
10820 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
10821         let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10822         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() };
10823         local_res
10824 }
10825 #[no_mangle]
10826 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
10827 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
10828         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10829 }
10830 #[allow(unused)]
10831 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10832         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
10833 }
10834 #[no_mangle]
10835 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
10836 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
10837         let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10838         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() };
10839         local_res
10840 }
10841 #[no_mangle]
10842 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
10843 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
10844         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10845 }
10846 #[allow(unused)]
10847 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10848         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
10849 }
10850 #[no_mangle]
10851 /// Read a WarningMessage from a byte array, created by WarningMessage_write
10852 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
10853         let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10854         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() };
10855         local_res
10856 }
10857 #[no_mangle]
10858 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
10859 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10860         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10861 }
10862 #[allow(unused)]
10863 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10864         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
10865 }
10866 #[no_mangle]
10867 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
10868 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
10869         let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10870         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() };
10871         local_res
10872 }
10873 #[no_mangle]
10874 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
10875 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10876         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10877 }
10878 #[allow(unused)]
10879 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10880         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
10881 }
10882 #[no_mangle]
10883 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
10884 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
10885         let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10886         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() };
10887         local_res
10888 }
10889 #[no_mangle]
10890 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
10891 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
10892         let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10893         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() };
10894         local_res
10895 }
10896 #[no_mangle]
10897 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
10898 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
10899         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10900 }
10901 #[allow(unused)]
10902 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10903         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
10904 }
10905 #[no_mangle]
10906 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
10907 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
10908         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10909 }
10910 #[allow(unused)]
10911 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10912         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
10913 }
10914 #[no_mangle]
10915 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
10916 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
10917         let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10918         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() };
10919         local_res
10920 }
10921 /// Calculates the overflow safe ending block height for the query.
10922 ///
10923 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
10924 #[must_use]
10925 #[no_mangle]
10926 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
10927         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
10928         ret
10929 }
10930
10931 #[no_mangle]
10932 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
10933 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
10934         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10935 }
10936 #[allow(unused)]
10937 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10938         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
10939 }
10940 #[no_mangle]
10941 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
10942 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
10943         let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10944         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() };
10945         local_res
10946 }
10947 #[no_mangle]
10948 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
10949 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
10950         let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10951         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() };
10952         local_res
10953 }
10954 #[no_mangle]
10955 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
10956 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
10957         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10958 }
10959 #[allow(unused)]
10960 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10961         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
10962 }
10963 #[no_mangle]
10964 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
10965 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
10966         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10967 }
10968 #[allow(unused)]
10969 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10970         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
10971 }
10972 #[no_mangle]
10973 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
10974 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
10975         let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10976         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() };
10977         local_res
10978 }