Update auto-generated bindings to include ln-transaction-sync
[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         /// Value is validly encoded but is dangerous to use.
62         ///
63         /// This is used for things like [`ChannelManager`] deserialization where we want to ensure
64         /// that we don't use a [`ChannelManager`] which is in out of sync with the [`ChannelMonitor`].
65         /// This indicates that there is a critical implementation flaw in the storage implementation
66         /// and it's unsafe to continue.
67         ///
68         /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
69         /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
70         DangerousValue,
71 }
72 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
73 pub(crate) type nativeDecodeError = DecodeErrorImport;
74
75 impl DecodeError {
76         #[allow(unused)]
77         pub(crate) fn to_native(&self) -> nativeDecodeError {
78                 match self {
79                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
80                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
81                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
82                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
83                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
84                         DecodeError::Io (ref a, ) => {
85                                 let mut a_nonref = Clone::clone(a);
86                                 nativeDecodeError::Io (
87                                         a_nonref.to_rust_kind(),
88                                 )
89                         },
90                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
91                         DecodeError::DangerousValue => nativeDecodeError::DangerousValue,
92                 }
93         }
94         #[allow(unused)]
95         pub(crate) fn into_native(self) -> nativeDecodeError {
96                 match self {
97                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
98                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
99                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
100                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
101                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
102                         DecodeError::Io (mut a, ) => {
103                                 nativeDecodeError::Io (
104                                         a.to_rust_kind(),
105                                 )
106                         },
107                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
108                         DecodeError::DangerousValue => nativeDecodeError::DangerousValue,
109                 }
110         }
111         #[allow(unused)]
112         pub(crate) fn from_native(native: &DecodeErrorImport) -> Self {
113                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeDecodeError) };
114                 match native {
115                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
116                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
117                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
118                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
119                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
120                         nativeDecodeError::Io (ref a, ) => {
121                                 let mut a_nonref = Clone::clone(a);
122                                 DecodeError::Io (
123                                         crate::c_types::IOError::from_rust_kind(a_nonref),
124                                 )
125                         },
126                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
127                         nativeDecodeError::DangerousValue => DecodeError::DangerousValue,
128                 }
129         }
130         #[allow(unused)]
131         pub(crate) fn native_into(native: nativeDecodeError) -> Self {
132                 match native {
133                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
134                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
135                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
136                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
137                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
138                         nativeDecodeError::Io (mut a, ) => {
139                                 DecodeError::Io (
140                                         crate::c_types::IOError::from_rust_kind(a),
141                                 )
142                         },
143                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
144                         nativeDecodeError::DangerousValue => DecodeError::DangerousValue,
145                 }
146         }
147 }
148 /// Frees any resources used by the DecodeError
149 #[no_mangle]
150 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
151 /// Creates a copy of the DecodeError
152 #[no_mangle]
153 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
154         orig.clone()
155 }
156 #[allow(unused)]
157 /// Used only if an object of this type is returned as a trait impl by a method
158 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
159         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const DecodeError)).clone() })) as *mut c_void
160 }
161 #[allow(unused)]
162 /// Used only if an object of this type is returned as a trait impl by a method
163 pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
164         let _ = unsafe { Box::from_raw(this_ptr as *mut DecodeError) };
165 }
166 #[no_mangle]
167 /// Utility method to constructs a new UnknownVersion-variant DecodeError
168 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
169         DecodeError::UnknownVersion}
170 #[no_mangle]
171 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
172 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
173         DecodeError::UnknownRequiredFeature}
174 #[no_mangle]
175 /// Utility method to constructs a new InvalidValue-variant DecodeError
176 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
177         DecodeError::InvalidValue}
178 #[no_mangle]
179 /// Utility method to constructs a new ShortRead-variant DecodeError
180 pub extern "C" fn DecodeError_short_read() -> DecodeError {
181         DecodeError::ShortRead}
182 #[no_mangle]
183 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
184 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
185         DecodeError::BadLengthDescriptor}
186 #[no_mangle]
187 /// Utility method to constructs a new Io-variant DecodeError
188 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
189         DecodeError::Io(a, )
190 }
191 #[no_mangle]
192 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
193 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
194         DecodeError::UnsupportedCompression}
195 #[no_mangle]
196 /// Utility method to constructs a new DangerousValue-variant DecodeError
197 pub extern "C" fn DecodeError_dangerous_value() -> DecodeError {
198         DecodeError::DangerousValue}
199 /// Get a string which allows debug introspection of a DecodeError object
200 pub extern "C" fn DecodeError_debug_str_void(o: *const c_void) -> Str {
201         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::DecodeError }).into()}
202 /// Generates a non-cryptographic 64-bit hash of the DecodeError.
203 #[no_mangle]
204 pub extern "C" fn DecodeError_hash(o: &DecodeError) -> u64 {
205         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
206         #[allow(deprecated)]
207         let mut hasher = core::hash::SipHasher::new();
208         core::hash::Hash::hash(&o.to_native(), &mut hasher);
209         core::hash::Hasher::finish(&hasher)
210 }
211 /// Checks if two DecodeErrors contain equal inner contents.
212 /// This ignores pointers and is_owned flags and looks at the values in fields.
213 #[no_mangle]
214 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
215         if &a.to_native() == &b.to_native() { true } else { false }
216 }
217
218 use lightning::ln::msgs::Init as nativeInitImport;
219 pub(crate) type nativeInit = nativeInitImport;
220
221 /// An [`init`] message to be sent to or received from a peer.
222 ///
223 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
224 #[must_use]
225 #[repr(C)]
226 pub struct Init {
227         /// A pointer to the opaque Rust object.
228
229         /// Nearly everywhere, inner must be non-null, however in places where
230         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
231         pub inner: *mut nativeInit,
232         /// Indicates that this is the only struct which contains the same pointer.
233
234         /// Rust functions which take ownership of an object provided via an argument require
235         /// this to be true and invalidate the object pointed to by inner.
236         pub is_owned: bool,
237 }
238
239 impl Drop for Init {
240         fn drop(&mut self) {
241                 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
242                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
243                 }
244         }
245 }
246 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
247 #[no_mangle]
248 pub extern "C" fn Init_free(this_obj: Init) { }
249 #[allow(unused)]
250 /// Used only if an object of this type is returned as a trait impl by a method
251 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
252         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
253 }
254 #[allow(unused)]
255 impl Init {
256         pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
257                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
258         }
259         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
260                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
261         }
262         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
263         pub(crate) fn take_inner(mut self) -> *mut nativeInit {
264                 assert!(self.is_owned);
265                 let ret = ObjOps::untweak_ptr(self.inner);
266                 self.inner = core::ptr::null_mut();
267                 ret
268         }
269 }
270 /// The relevant features which the sender supports.
271 #[no_mangle]
272 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
273         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
274         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 }
275 }
276 /// The relevant features which the sender supports.
277 #[no_mangle]
278 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
279         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
280 }
281 /// Indicates chains the sender is interested in.
282 ///
283 /// If there are no common chains, the connection will be closed.
284 ///
285 /// Returns a copy of the field.
286 #[no_mangle]
287 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
288         let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
289         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() }) };
290         local_inner_val
291 }
292 /// Indicates chains the sender is interested in.
293 ///
294 /// If there are no common chains, the connection will be closed.
295 #[no_mangle]
296 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ) {
297         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 }})} };
298         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
299 }
300 /// The receipient's network address.
301 ///
302 /// This adds the option to report a remote IP address back to a connecting peer using the init
303 /// message. A node can decide to use that information to discover a potential update to its
304 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
305 /// the new address.
306 #[no_mangle]
307 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_SocketAddressZ {
308         let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
309         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()) }) };
310         local_inner_val
311 }
312 /// The receipient's network address.
313 ///
314 /// This adds the option to report a remote IP address back to a connecting peer using the init
315 /// message. A node can decide to use that information to discover a potential update to its
316 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
317 /// the new address.
318 #[no_mangle]
319 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_SocketAddressZ) {
320         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
321         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
322 }
323 /// Constructs a new Init given each field
324 #[must_use]
325 #[no_mangle]
326 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 {
327         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 }})} };
328         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() }})} };
329         Init { inner: ObjOps::heap_alloc(nativeInit {
330                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
331                 networks: local_networks_arg,
332                 remote_network_address: local_remote_network_address_arg,
333         }), is_owned: true }
334 }
335 impl Clone for Init {
336         fn clone(&self) -> Self {
337                 Self {
338                         inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
339                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
340                         is_owned: true,
341                 }
342         }
343 }
344 #[allow(unused)]
345 /// Used only if an object of this type is returned as a trait impl by a method
346 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
347         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInit)).clone() })) as *mut c_void
348 }
349 #[no_mangle]
350 /// Creates a copy of the Init
351 pub extern "C" fn Init_clone(orig: &Init) -> Init {
352         orig.clone()
353 }
354 /// Get a string which allows debug introspection of a Init object
355 pub extern "C" fn Init_debug_str_void(o: *const c_void) -> Str {
356         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Init }).into()}
357 /// Generates a non-cryptographic 64-bit hash of the Init.
358 #[no_mangle]
359 pub extern "C" fn Init_hash(o: &Init) -> u64 {
360         if o.inner.is_null() { return 0; }
361         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
362         #[allow(deprecated)]
363         let mut hasher = core::hash::SipHasher::new();
364         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
365         core::hash::Hasher::finish(&hasher)
366 }
367 /// Checks if two Inits contain equal inner contents.
368 /// This ignores pointers and is_owned flags and looks at the values in fields.
369 /// Two objects with NULL inner values will be considered "equal" here.
370 #[no_mangle]
371 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
372         if a.inner == b.inner { return true; }
373         if a.inner.is_null() || b.inner.is_null() { return false; }
374         if a.get_native_ref() == b.get_native_ref() { true } else { false }
375 }
376
377 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
378 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
379
380 /// An [`error`] message to be sent to or received from a peer.
381 ///
382 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
383 #[must_use]
384 #[repr(C)]
385 pub struct ErrorMessage {
386         /// A pointer to the opaque Rust object.
387
388         /// Nearly everywhere, inner must be non-null, however in places where
389         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
390         pub inner: *mut nativeErrorMessage,
391         /// Indicates that this is the only struct which contains the same pointer.
392
393         /// Rust functions which take ownership of an object provided via an argument require
394         /// this to be true and invalidate the object pointed to by inner.
395         pub is_owned: bool,
396 }
397
398 impl Drop for ErrorMessage {
399         fn drop(&mut self) {
400                 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
401                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
402                 }
403         }
404 }
405 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
406 #[no_mangle]
407 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
408 #[allow(unused)]
409 /// Used only if an object of this type is returned as a trait impl by a method
410 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
411         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
412 }
413 #[allow(unused)]
414 impl ErrorMessage {
415         pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
416                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
417         }
418         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
419                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
420         }
421         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
422         pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
423                 assert!(self.is_owned);
424                 let ret = ObjOps::untweak_ptr(self.inner);
425                 self.inner = core::ptr::null_mut();
426                 ret
427         }
428 }
429 /// The channel ID involved in the error.
430 ///
431 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
432 /// with the sending peer should be closed.
433 #[no_mangle]
434 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> crate::lightning::ln::types::ChannelId {
435         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
436         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
437 }
438 /// The channel ID involved in the error.
439 ///
440 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
441 /// with the sending peer should be closed.
442 #[no_mangle]
443 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::lightning::ln::types::ChannelId) {
444         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
445 }
446 /// A possibly human-readable error description.
447 ///
448 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
449 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
450 /// the terminal emulator or the logging subsystem.
451 #[no_mangle]
452 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
453         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
454         inner_val.as_str().into()
455 }
456 /// A possibly human-readable error description.
457 ///
458 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
459 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
460 /// the terminal emulator or the logging subsystem.
461 #[no_mangle]
462 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
463         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
464 }
465 /// Constructs a new ErrorMessage given each field
466 #[must_use]
467 #[no_mangle]
468 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::Str) -> ErrorMessage {
469         ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
470                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
471                 data: data_arg.into_string(),
472         }), is_owned: true }
473 }
474 impl Clone for ErrorMessage {
475         fn clone(&self) -> Self {
476                 Self {
477                         inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
478                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
479                         is_owned: true,
480                 }
481         }
482 }
483 #[allow(unused)]
484 /// Used only if an object of this type is returned as a trait impl by a method
485 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
486         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeErrorMessage)).clone() })) as *mut c_void
487 }
488 #[no_mangle]
489 /// Creates a copy of the ErrorMessage
490 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
491         orig.clone()
492 }
493 /// Get a string which allows debug introspection of a ErrorMessage object
494 pub extern "C" fn ErrorMessage_debug_str_void(o: *const c_void) -> Str {
495         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorMessage }).into()}
496 /// Generates a non-cryptographic 64-bit hash of the ErrorMessage.
497 #[no_mangle]
498 pub extern "C" fn ErrorMessage_hash(o: &ErrorMessage) -> u64 {
499         if o.inner.is_null() { return 0; }
500         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
501         #[allow(deprecated)]
502         let mut hasher = core::hash::SipHasher::new();
503         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
504         core::hash::Hasher::finish(&hasher)
505 }
506 /// Checks if two ErrorMessages contain equal inner contents.
507 /// This ignores pointers and is_owned flags and looks at the values in fields.
508 /// Two objects with NULL inner values will be considered "equal" here.
509 #[no_mangle]
510 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
511         if a.inner == b.inner { return true; }
512         if a.inner.is_null() || b.inner.is_null() { return false; }
513         if a.get_native_ref() == b.get_native_ref() { true } else { false }
514 }
515
516 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
517 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
518
519 /// A [`warning`] message to be sent to or received from a peer.
520 ///
521 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
522 #[must_use]
523 #[repr(C)]
524 pub struct WarningMessage {
525         /// A pointer to the opaque Rust object.
526
527         /// Nearly everywhere, inner must be non-null, however in places where
528         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
529         pub inner: *mut nativeWarningMessage,
530         /// Indicates that this is the only struct which contains the same pointer.
531
532         /// Rust functions which take ownership of an object provided via an argument require
533         /// this to be true and invalidate the object pointed to by inner.
534         pub is_owned: bool,
535 }
536
537 impl Drop for WarningMessage {
538         fn drop(&mut self) {
539                 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
540                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
541                 }
542         }
543 }
544 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
545 #[no_mangle]
546 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
547 #[allow(unused)]
548 /// Used only if an object of this type is returned as a trait impl by a method
549 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
550         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
551 }
552 #[allow(unused)]
553 impl WarningMessage {
554         pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
555                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
556         }
557         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
558                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
559         }
560         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
561         pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
562                 assert!(self.is_owned);
563                 let ret = ObjOps::untweak_ptr(self.inner);
564                 self.inner = core::ptr::null_mut();
565                 ret
566         }
567 }
568 /// The channel ID involved in the warning.
569 ///
570 /// All-0s indicates a warning unrelated to a specific channel.
571 #[no_mangle]
572 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> crate::lightning::ln::types::ChannelId {
573         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
574         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
575 }
576 /// The channel ID involved in the warning.
577 ///
578 /// All-0s indicates a warning unrelated to a specific channel.
579 #[no_mangle]
580 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::lightning::ln::types::ChannelId) {
581         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
582 }
583 /// A possibly human-readable warning description.
584 ///
585 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
586 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
587 /// the terminal emulator or the logging subsystem.
588 #[no_mangle]
589 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
590         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
591         inner_val.as_str().into()
592 }
593 /// A possibly human-readable warning description.
594 ///
595 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
596 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
597 /// the terminal emulator or the logging subsystem.
598 #[no_mangle]
599 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
600         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
601 }
602 /// Constructs a new WarningMessage given each field
603 #[must_use]
604 #[no_mangle]
605 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::Str) -> WarningMessage {
606         WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
607                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
608                 data: data_arg.into_string(),
609         }), is_owned: true }
610 }
611 impl Clone for WarningMessage {
612         fn clone(&self) -> Self {
613                 Self {
614                         inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
615                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
616                         is_owned: true,
617                 }
618         }
619 }
620 #[allow(unused)]
621 /// Used only if an object of this type is returned as a trait impl by a method
622 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
623         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeWarningMessage)).clone() })) as *mut c_void
624 }
625 #[no_mangle]
626 /// Creates a copy of the WarningMessage
627 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
628         orig.clone()
629 }
630 /// Get a string which allows debug introspection of a WarningMessage object
631 pub extern "C" fn WarningMessage_debug_str_void(o: *const c_void) -> Str {
632         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::WarningMessage }).into()}
633 /// Generates a non-cryptographic 64-bit hash of the WarningMessage.
634 #[no_mangle]
635 pub extern "C" fn WarningMessage_hash(o: &WarningMessage) -> u64 {
636         if o.inner.is_null() { return 0; }
637         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
638         #[allow(deprecated)]
639         let mut hasher = core::hash::SipHasher::new();
640         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
641         core::hash::Hasher::finish(&hasher)
642 }
643 /// Checks if two WarningMessages contain equal inner contents.
644 /// This ignores pointers and is_owned flags and looks at the values in fields.
645 /// Two objects with NULL inner values will be considered "equal" here.
646 #[no_mangle]
647 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
648         if a.inner == b.inner { return true; }
649         if a.inner.is_null() || b.inner.is_null() { return false; }
650         if a.get_native_ref() == b.get_native_ref() { true } else { false }
651 }
652
653 use lightning::ln::msgs::Ping as nativePingImport;
654 pub(crate) type nativePing = nativePingImport;
655
656 /// A [`ping`] message to be sent to or received from a peer.
657 ///
658 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
659 #[must_use]
660 #[repr(C)]
661 pub struct Ping {
662         /// A pointer to the opaque Rust object.
663
664         /// Nearly everywhere, inner must be non-null, however in places where
665         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
666         pub inner: *mut nativePing,
667         /// Indicates that this is the only struct which contains the same pointer.
668
669         /// Rust functions which take ownership of an object provided via an argument require
670         /// this to be true and invalidate the object pointed to by inner.
671         pub is_owned: bool,
672 }
673
674 impl Drop for Ping {
675         fn drop(&mut self) {
676                 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
677                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
678                 }
679         }
680 }
681 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
682 #[no_mangle]
683 pub extern "C" fn Ping_free(this_obj: Ping) { }
684 #[allow(unused)]
685 /// Used only if an object of this type is returned as a trait impl by a method
686 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
687         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
688 }
689 #[allow(unused)]
690 impl Ping {
691         pub(crate) fn get_native_ref(&self) -> &'static nativePing {
692                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
693         }
694         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
695                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
696         }
697         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
698         pub(crate) fn take_inner(mut self) -> *mut nativePing {
699                 assert!(self.is_owned);
700                 let ret = ObjOps::untweak_ptr(self.inner);
701                 self.inner = core::ptr::null_mut();
702                 ret
703         }
704 }
705 /// The desired response length.
706 #[no_mangle]
707 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
708         let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
709         *inner_val
710 }
711 /// The desired response length.
712 #[no_mangle]
713 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
714         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
715 }
716 /// The ping packet size.
717 ///
718 /// This field is not sent on the wire. byteslen zeros are sent.
719 #[no_mangle]
720 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
721         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
722         *inner_val
723 }
724 /// The ping packet size.
725 ///
726 /// This field is not sent on the wire. byteslen zeros are sent.
727 #[no_mangle]
728 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
729         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
730 }
731 /// Constructs a new Ping given each field
732 #[must_use]
733 #[no_mangle]
734 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
735         Ping { inner: ObjOps::heap_alloc(nativePing {
736                 ponglen: ponglen_arg,
737                 byteslen: byteslen_arg,
738         }), is_owned: true }
739 }
740 impl Clone for Ping {
741         fn clone(&self) -> Self {
742                 Self {
743                         inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
744                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
745                         is_owned: true,
746                 }
747         }
748 }
749 #[allow(unused)]
750 /// Used only if an object of this type is returned as a trait impl by a method
751 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
752         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePing)).clone() })) as *mut c_void
753 }
754 #[no_mangle]
755 /// Creates a copy of the Ping
756 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
757         orig.clone()
758 }
759 /// Get a string which allows debug introspection of a Ping object
760 pub extern "C" fn Ping_debug_str_void(o: *const c_void) -> Str {
761         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Ping }).into()}
762 /// Generates a non-cryptographic 64-bit hash of the Ping.
763 #[no_mangle]
764 pub extern "C" fn Ping_hash(o: &Ping) -> u64 {
765         if o.inner.is_null() { return 0; }
766         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
767         #[allow(deprecated)]
768         let mut hasher = core::hash::SipHasher::new();
769         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
770         core::hash::Hasher::finish(&hasher)
771 }
772 /// Checks if two Pings contain equal inner contents.
773 /// This ignores pointers and is_owned flags and looks at the values in fields.
774 /// Two objects with NULL inner values will be considered "equal" here.
775 #[no_mangle]
776 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
777         if a.inner == b.inner { return true; }
778         if a.inner.is_null() || b.inner.is_null() { return false; }
779         if a.get_native_ref() == b.get_native_ref() { true } else { false }
780 }
781
782 use lightning::ln::msgs::Pong as nativePongImport;
783 pub(crate) type nativePong = nativePongImport;
784
785 /// A [`pong`] message to be sent to or received from a peer.
786 ///
787 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
788 #[must_use]
789 #[repr(C)]
790 pub struct Pong {
791         /// A pointer to the opaque Rust object.
792
793         /// Nearly everywhere, inner must be non-null, however in places where
794         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
795         pub inner: *mut nativePong,
796         /// Indicates that this is the only struct which contains the same pointer.
797
798         /// Rust functions which take ownership of an object provided via an argument require
799         /// this to be true and invalidate the object pointed to by inner.
800         pub is_owned: bool,
801 }
802
803 impl Drop for Pong {
804         fn drop(&mut self) {
805                 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
806                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
807                 }
808         }
809 }
810 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
811 #[no_mangle]
812 pub extern "C" fn Pong_free(this_obj: Pong) { }
813 #[allow(unused)]
814 /// Used only if an object of this type is returned as a trait impl by a method
815 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
816         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
817 }
818 #[allow(unused)]
819 impl Pong {
820         pub(crate) fn get_native_ref(&self) -> &'static nativePong {
821                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
822         }
823         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
824                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
825         }
826         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
827         pub(crate) fn take_inner(mut self) -> *mut nativePong {
828                 assert!(self.is_owned);
829                 let ret = ObjOps::untweak_ptr(self.inner);
830                 self.inner = core::ptr::null_mut();
831                 ret
832         }
833 }
834 /// The pong packet size.
835 ///
836 /// This field is not sent on the wire. byteslen zeros are sent.
837 #[no_mangle]
838 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
839         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
840         *inner_val
841 }
842 /// The pong packet size.
843 ///
844 /// This field is not sent on the wire. byteslen zeros are sent.
845 #[no_mangle]
846 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
847         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
848 }
849 /// Constructs a new Pong given each field
850 #[must_use]
851 #[no_mangle]
852 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
853         Pong { inner: ObjOps::heap_alloc(nativePong {
854                 byteslen: byteslen_arg,
855         }), is_owned: true }
856 }
857 impl Clone for Pong {
858         fn clone(&self) -> Self {
859                 Self {
860                         inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
861                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
862                         is_owned: true,
863                 }
864         }
865 }
866 #[allow(unused)]
867 /// Used only if an object of this type is returned as a trait impl by a method
868 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
869         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePong)).clone() })) as *mut c_void
870 }
871 #[no_mangle]
872 /// Creates a copy of the Pong
873 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
874         orig.clone()
875 }
876 /// Get a string which allows debug introspection of a Pong object
877 pub extern "C" fn Pong_debug_str_void(o: *const c_void) -> Str {
878         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Pong }).into()}
879 /// Generates a non-cryptographic 64-bit hash of the Pong.
880 #[no_mangle]
881 pub extern "C" fn Pong_hash(o: &Pong) -> u64 {
882         if o.inner.is_null() { return 0; }
883         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
884         #[allow(deprecated)]
885         let mut hasher = core::hash::SipHasher::new();
886         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
887         core::hash::Hasher::finish(&hasher)
888 }
889 /// Checks if two Pongs contain equal inner contents.
890 /// This ignores pointers and is_owned flags and looks at the values in fields.
891 /// Two objects with NULL inner values will be considered "equal" here.
892 #[no_mangle]
893 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
894         if a.inner == b.inner { return true; }
895         if a.inner.is_null() || b.inner.is_null() { return false; }
896         if a.get_native_ref() == b.get_native_ref() { true } else { false }
897 }
898
899 use lightning::ln::msgs::CommonOpenChannelFields as nativeCommonOpenChannelFieldsImport;
900 pub(crate) type nativeCommonOpenChannelFields = nativeCommonOpenChannelFieldsImport;
901
902 /// Contains fields that are both common to [`open_channel`] and `open_channel2` messages.
903 ///
904 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
905 #[must_use]
906 #[repr(C)]
907 pub struct CommonOpenChannelFields {
908         /// A pointer to the opaque Rust object.
909
910         /// Nearly everywhere, inner must be non-null, however in places where
911         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
912         pub inner: *mut nativeCommonOpenChannelFields,
913         /// Indicates that this is the only struct which contains the same pointer.
914
915         /// Rust functions which take ownership of an object provided via an argument require
916         /// this to be true and invalidate the object pointed to by inner.
917         pub is_owned: bool,
918 }
919
920 impl Drop for CommonOpenChannelFields {
921         fn drop(&mut self) {
922                 if self.is_owned && !<*mut nativeCommonOpenChannelFields>::is_null(self.inner) {
923                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
924                 }
925         }
926 }
927 /// Frees any resources used by the CommonOpenChannelFields, if is_owned is set and inner is non-NULL.
928 #[no_mangle]
929 pub extern "C" fn CommonOpenChannelFields_free(this_obj: CommonOpenChannelFields) { }
930 #[allow(unused)]
931 /// Used only if an object of this type is returned as a trait impl by a method
932 pub(crate) extern "C" fn CommonOpenChannelFields_free_void(this_ptr: *mut c_void) {
933         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommonOpenChannelFields) };
934 }
935 #[allow(unused)]
936 impl CommonOpenChannelFields {
937         pub(crate) fn get_native_ref(&self) -> &'static nativeCommonOpenChannelFields {
938                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
939         }
940         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommonOpenChannelFields {
941                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
942         }
943         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
944         pub(crate) fn take_inner(mut self) -> *mut nativeCommonOpenChannelFields {
945                 assert!(self.is_owned);
946                 let ret = ObjOps::untweak_ptr(self.inner);
947                 self.inner = core::ptr::null_mut();
948                 ret
949         }
950 }
951 /// The genesis hash of the blockchain where the channel is to be opened
952 #[no_mangle]
953 pub extern "C" fn CommonOpenChannelFields_get_chain_hash(this_ptr: &CommonOpenChannelFields) -> *const [u8; 32] {
954         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
955         inner_val.as_ref()
956 }
957 /// The genesis hash of the blockchain where the channel is to be opened
958 #[no_mangle]
959 pub extern "C" fn CommonOpenChannelFields_set_chain_hash(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::ThirtyTwoBytes) {
960         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
961 }
962 /// A temporary channel ID
963 /// For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
964 /// For V1 channels: a temporary channel ID, until the funding outpoint is announced
965 #[no_mangle]
966 pub extern "C" fn CommonOpenChannelFields_get_temporary_channel_id(this_ptr: &CommonOpenChannelFields) -> crate::lightning::ln::types::ChannelId {
967         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
968         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
969 }
970 /// A temporary channel ID
971 /// For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
972 /// For V1 channels: a temporary channel ID, until the funding outpoint is announced
973 #[no_mangle]
974 pub extern "C" fn CommonOpenChannelFields_set_temporary_channel_id(this_ptr: &mut CommonOpenChannelFields, mut val: crate::lightning::ln::types::ChannelId) {
975         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) };
976 }
977 /// For V1 channels: The channel value
978 /// For V2 channels: Part of the channel value contributed by the channel initiator
979 #[no_mangle]
980 pub extern "C" fn CommonOpenChannelFields_get_funding_satoshis(this_ptr: &CommonOpenChannelFields) -> u64 {
981         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
982         *inner_val
983 }
984 /// For V1 channels: The channel value
985 /// For V2 channels: Part of the channel value contributed by the channel initiator
986 #[no_mangle]
987 pub extern "C" fn CommonOpenChannelFields_set_funding_satoshis(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
988         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
989 }
990 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
991 /// omitted
992 #[no_mangle]
993 pub extern "C" fn CommonOpenChannelFields_get_dust_limit_satoshis(this_ptr: &CommonOpenChannelFields) -> u64 {
994         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
995         *inner_val
996 }
997 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
998 /// omitted
999 #[no_mangle]
1000 pub extern "C" fn CommonOpenChannelFields_set_dust_limit_satoshis(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
1001         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1002 }
1003 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1004 #[no_mangle]
1005 pub extern "C" fn CommonOpenChannelFields_get_max_htlc_value_in_flight_msat(this_ptr: &CommonOpenChannelFields) -> u64 {
1006         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1007         *inner_val
1008 }
1009 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1010 #[no_mangle]
1011 pub extern "C" fn CommonOpenChannelFields_set_max_htlc_value_in_flight_msat(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
1012         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1013 }
1014 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1015 #[no_mangle]
1016 pub extern "C" fn CommonOpenChannelFields_get_htlc_minimum_msat(this_ptr: &CommonOpenChannelFields) -> u64 {
1017         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1018         *inner_val
1019 }
1020 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1021 #[no_mangle]
1022 pub extern "C" fn CommonOpenChannelFields_set_htlc_minimum_msat(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
1023         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1024 }
1025 /// The feerate for the commitment transaction set by the channel initiator until updated by
1026 /// [`UpdateFee`]
1027 #[no_mangle]
1028 pub extern "C" fn CommonOpenChannelFields_get_commitment_feerate_sat_per_1000_weight(this_ptr: &CommonOpenChannelFields) -> u32 {
1029         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1030         *inner_val
1031 }
1032 /// The feerate for the commitment transaction set by the channel initiator until updated by
1033 /// [`UpdateFee`]
1034 #[no_mangle]
1035 pub extern "C" fn CommonOpenChannelFields_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut CommonOpenChannelFields, mut val: u32) {
1036         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1037 }
1038 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1039 /// broadcast a commitment transaction
1040 #[no_mangle]
1041 pub extern "C" fn CommonOpenChannelFields_get_to_self_delay(this_ptr: &CommonOpenChannelFields) -> u16 {
1042         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1043         *inner_val
1044 }
1045 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1046 /// broadcast a commitment transaction
1047 #[no_mangle]
1048 pub extern "C" fn CommonOpenChannelFields_set_to_self_delay(this_ptr: &mut CommonOpenChannelFields, mut val: u16) {
1049         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1050 }
1051 /// The maximum number of inbound HTLCs towards channel initiator
1052 #[no_mangle]
1053 pub extern "C" fn CommonOpenChannelFields_get_max_accepted_htlcs(this_ptr: &CommonOpenChannelFields) -> u16 {
1054         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1055         *inner_val
1056 }
1057 /// The maximum number of inbound HTLCs towards channel initiator
1058 #[no_mangle]
1059 pub extern "C" fn CommonOpenChannelFields_set_max_accepted_htlcs(this_ptr: &mut CommonOpenChannelFields, mut val: u16) {
1060         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1061 }
1062 /// The channel initiator's key controlling the funding transaction
1063 #[no_mangle]
1064 pub extern "C" fn CommonOpenChannelFields_get_funding_pubkey(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1065         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1066         crate::c_types::PublicKey::from_rust(&inner_val)
1067 }
1068 /// The channel initiator's key controlling the funding transaction
1069 #[no_mangle]
1070 pub extern "C" fn CommonOpenChannelFields_set_funding_pubkey(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1071         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1072 }
1073 /// Used to derive a revocation key for transactions broadcast by counterparty
1074 #[no_mangle]
1075 pub extern "C" fn CommonOpenChannelFields_get_revocation_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1076         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1077         crate::c_types::PublicKey::from_rust(&inner_val)
1078 }
1079 /// Used to derive a revocation key for transactions broadcast by counterparty
1080 #[no_mangle]
1081 pub extern "C" fn CommonOpenChannelFields_set_revocation_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1082         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1083 }
1084 /// A payment key to channel initiator for transactions broadcast by counterparty
1085 #[no_mangle]
1086 pub extern "C" fn CommonOpenChannelFields_get_payment_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1087         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1088         crate::c_types::PublicKey::from_rust(&inner_val)
1089 }
1090 /// A payment key to channel initiator for transactions broadcast by counterparty
1091 #[no_mangle]
1092 pub extern "C" fn CommonOpenChannelFields_set_payment_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1093         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1094 }
1095 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1096 /// initiator
1097 #[no_mangle]
1098 pub extern "C" fn CommonOpenChannelFields_get_delayed_payment_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1099         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1100         crate::c_types::PublicKey::from_rust(&inner_val)
1101 }
1102 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1103 /// initiator
1104 #[no_mangle]
1105 pub extern "C" fn CommonOpenChannelFields_set_delayed_payment_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1106         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1107 }
1108 /// Used to derive an HTLC payment key to channel initiator
1109 #[no_mangle]
1110 pub extern "C" fn CommonOpenChannelFields_get_htlc_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1111         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1112         crate::c_types::PublicKey::from_rust(&inner_val)
1113 }
1114 /// Used to derive an HTLC payment key to channel initiator
1115 #[no_mangle]
1116 pub extern "C" fn CommonOpenChannelFields_set_htlc_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1117         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1118 }
1119 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1120 #[no_mangle]
1121 pub extern "C" fn CommonOpenChannelFields_get_first_per_commitment_point(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1122         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1123         crate::c_types::PublicKey::from_rust(&inner_val)
1124 }
1125 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1126 #[no_mangle]
1127 pub extern "C" fn CommonOpenChannelFields_set_first_per_commitment_point(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1128         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1129 }
1130 /// The channel flags to be used
1131 #[no_mangle]
1132 pub extern "C" fn CommonOpenChannelFields_get_channel_flags(this_ptr: &CommonOpenChannelFields) -> u8 {
1133         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1134         *inner_val
1135 }
1136 /// The channel flags to be used
1137 #[no_mangle]
1138 pub extern "C" fn CommonOpenChannelFields_set_channel_flags(this_ptr: &mut CommonOpenChannelFields, mut val: u8) {
1139         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1140 }
1141 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1142 /// collaboratively close
1143 #[no_mangle]
1144 pub extern "C" fn CommonOpenChannelFields_get_shutdown_scriptpubkey(this_ptr: &CommonOpenChannelFields) -> crate::c_types::derived::COption_CVec_u8ZZ {
1145         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1146         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() }) };
1147         local_inner_val
1148 }
1149 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1150 /// collaboratively close
1151 #[no_mangle]
1152 pub extern "C" fn CommonOpenChannelFields_set_shutdown_scriptpubkey(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1153         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()) }})} };
1154         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1155 }
1156 /// The channel type that this channel will represent
1157 ///
1158 /// If this is `None`, we derive the channel type from the intersection of our
1159 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1160 ///
1161 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1162 #[no_mangle]
1163 pub extern "C" fn CommonOpenChannelFields_get_channel_type(this_ptr: &CommonOpenChannelFields) -> crate::lightning::ln::features::ChannelTypeFeatures {
1164         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1165         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 };
1166         local_inner_val
1167 }
1168 /// The channel type that this channel will represent
1169 ///
1170 /// If this is `None`, we derive the channel type from the intersection of our
1171 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1172 ///
1173 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1174 #[no_mangle]
1175 pub extern "C" fn CommonOpenChannelFields_set_channel_type(this_ptr: &mut CommonOpenChannelFields, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1176         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1177         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1178 }
1179 /// Constructs a new CommonOpenChannelFields given each field
1180 ///
1181 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1182 #[must_use]
1183 #[no_mangle]
1184 pub extern "C" fn CommonOpenChannelFields_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, 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 commitment_feerate_sat_per_1000_weight_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 channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> CommonOpenChannelFields {
1185         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()) }})} };
1186         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()) } }) };
1187         CommonOpenChannelFields { inner: ObjOps::heap_alloc(nativeCommonOpenChannelFields {
1188                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
1189                 temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) },
1190                 funding_satoshis: funding_satoshis_arg,
1191                 dust_limit_satoshis: dust_limit_satoshis_arg,
1192                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1193                 htlc_minimum_msat: htlc_minimum_msat_arg,
1194                 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1195                 to_self_delay: to_self_delay_arg,
1196                 max_accepted_htlcs: max_accepted_htlcs_arg,
1197                 funding_pubkey: funding_pubkey_arg.into_rust(),
1198                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1199                 payment_basepoint: payment_basepoint_arg.into_rust(),
1200                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1201                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1202                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1203                 channel_flags: channel_flags_arg,
1204                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1205                 channel_type: local_channel_type_arg,
1206         }), is_owned: true }
1207 }
1208 impl Clone for CommonOpenChannelFields {
1209         fn clone(&self) -> Self {
1210                 Self {
1211                         inner: if <*mut nativeCommonOpenChannelFields>::is_null(self.inner) { core::ptr::null_mut() } else {
1212                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1213                         is_owned: true,
1214                 }
1215         }
1216 }
1217 #[allow(unused)]
1218 /// Used only if an object of this type is returned as a trait impl by a method
1219 pub(crate) extern "C" fn CommonOpenChannelFields_clone_void(this_ptr: *const c_void) -> *mut c_void {
1220         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommonOpenChannelFields)).clone() })) as *mut c_void
1221 }
1222 #[no_mangle]
1223 /// Creates a copy of the CommonOpenChannelFields
1224 pub extern "C" fn CommonOpenChannelFields_clone(orig: &CommonOpenChannelFields) -> CommonOpenChannelFields {
1225         orig.clone()
1226 }
1227 /// Get a string which allows debug introspection of a CommonOpenChannelFields object
1228 pub extern "C" fn CommonOpenChannelFields_debug_str_void(o: *const c_void) -> Str {
1229         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommonOpenChannelFields }).into()}
1230 /// Generates a non-cryptographic 64-bit hash of the CommonOpenChannelFields.
1231 #[no_mangle]
1232 pub extern "C" fn CommonOpenChannelFields_hash(o: &CommonOpenChannelFields) -> u64 {
1233         if o.inner.is_null() { return 0; }
1234         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1235         #[allow(deprecated)]
1236         let mut hasher = core::hash::SipHasher::new();
1237         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1238         core::hash::Hasher::finish(&hasher)
1239 }
1240 /// Checks if two CommonOpenChannelFieldss contain equal inner contents.
1241 /// This ignores pointers and is_owned flags and looks at the values in fields.
1242 /// Two objects with NULL inner values will be considered "equal" here.
1243 #[no_mangle]
1244 pub extern "C" fn CommonOpenChannelFields_eq(a: &CommonOpenChannelFields, b: &CommonOpenChannelFields) -> bool {
1245         if a.inner == b.inner { return true; }
1246         if a.inner.is_null() || b.inner.is_null() { return false; }
1247         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1248 }
1249
1250 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
1251 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
1252
1253 /// An [`open_channel`] message to be sent to or received from a peer.
1254 ///
1255 /// Used in V1 channel establishment
1256 ///
1257 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
1258 #[must_use]
1259 #[repr(C)]
1260 pub struct OpenChannel {
1261         /// A pointer to the opaque Rust object.
1262
1263         /// Nearly everywhere, inner must be non-null, however in places where
1264         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1265         pub inner: *mut nativeOpenChannel,
1266         /// Indicates that this is the only struct which contains the same pointer.
1267
1268         /// Rust functions which take ownership of an object provided via an argument require
1269         /// this to be true and invalidate the object pointed to by inner.
1270         pub is_owned: bool,
1271 }
1272
1273 impl Drop for OpenChannel {
1274         fn drop(&mut self) {
1275                 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
1276                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1277                 }
1278         }
1279 }
1280 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
1281 #[no_mangle]
1282 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
1283 #[allow(unused)]
1284 /// Used only if an object of this type is returned as a trait impl by a method
1285 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
1286         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
1287 }
1288 #[allow(unused)]
1289 impl OpenChannel {
1290         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
1291                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1292         }
1293         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
1294                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1295         }
1296         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1297         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
1298                 assert!(self.is_owned);
1299                 let ret = ObjOps::untweak_ptr(self.inner);
1300                 self.inner = core::ptr::null_mut();
1301                 ret
1302         }
1303 }
1304 /// Common fields of `open_channel(2)`-like messages
1305 #[no_mangle]
1306 pub extern "C" fn OpenChannel_get_common_fields(this_ptr: &OpenChannel) -> crate::lightning::ln::msgs::CommonOpenChannelFields {
1307         let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
1308         crate::lightning::ln::msgs::CommonOpenChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonOpenChannelFields<>) as *mut _) }, is_owned: false }
1309 }
1310 /// Common fields of `open_channel(2)`-like messages
1311 #[no_mangle]
1312 pub extern "C" fn OpenChannel_set_common_fields(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::msgs::CommonOpenChannelFields) {
1313         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
1314 }
1315 /// The amount to push to the counterparty as part of the open, in milli-satoshi
1316 #[no_mangle]
1317 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
1318         let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
1319         *inner_val
1320 }
1321 /// The amount to push to the counterparty as part of the open, in milli-satoshi
1322 #[no_mangle]
1323 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
1324         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
1325 }
1326 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1327 #[no_mangle]
1328 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
1329         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1330         *inner_val
1331 }
1332 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1333 #[no_mangle]
1334 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
1335         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1336 }
1337 /// Constructs a new OpenChannel given each field
1338 #[must_use]
1339 #[no_mangle]
1340 pub extern "C" fn OpenChannel_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonOpenChannelFields, mut push_msat_arg: u64, mut channel_reserve_satoshis_arg: u64) -> OpenChannel {
1341         OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1342                 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
1343                 push_msat: push_msat_arg,
1344                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1345         }), is_owned: true }
1346 }
1347 impl Clone for OpenChannel {
1348         fn clone(&self) -> Self {
1349                 Self {
1350                         inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1351                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1352                         is_owned: true,
1353                 }
1354         }
1355 }
1356 #[allow(unused)]
1357 /// Used only if an object of this type is returned as a trait impl by a method
1358 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1359         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannel)).clone() })) as *mut c_void
1360 }
1361 #[no_mangle]
1362 /// Creates a copy of the OpenChannel
1363 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1364         orig.clone()
1365 }
1366 /// Get a string which allows debug introspection of a OpenChannel object
1367 pub extern "C" fn OpenChannel_debug_str_void(o: *const c_void) -> Str {
1368         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannel }).into()}
1369 /// Generates a non-cryptographic 64-bit hash of the OpenChannel.
1370 #[no_mangle]
1371 pub extern "C" fn OpenChannel_hash(o: &OpenChannel) -> u64 {
1372         if o.inner.is_null() { return 0; }
1373         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1374         #[allow(deprecated)]
1375         let mut hasher = core::hash::SipHasher::new();
1376         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1377         core::hash::Hasher::finish(&hasher)
1378 }
1379 /// Checks if two OpenChannels contain equal inner contents.
1380 /// This ignores pointers and is_owned flags and looks at the values in fields.
1381 /// Two objects with NULL inner values will be considered "equal" here.
1382 #[no_mangle]
1383 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1384         if a.inner == b.inner { return true; }
1385         if a.inner.is_null() || b.inner.is_null() { return false; }
1386         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1387 }
1388
1389 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1390 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1391
1392 /// An open_channel2 message to be sent by or received from the channel initiator.
1393 ///
1394 /// Used in V2 channel establishment
1395 ///
1396 #[must_use]
1397 #[repr(C)]
1398 pub struct OpenChannelV2 {
1399         /// A pointer to the opaque Rust object.
1400
1401         /// Nearly everywhere, inner must be non-null, however in places where
1402         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1403         pub inner: *mut nativeOpenChannelV2,
1404         /// Indicates that this is the only struct which contains the same pointer.
1405
1406         /// Rust functions which take ownership of an object provided via an argument require
1407         /// this to be true and invalidate the object pointed to by inner.
1408         pub is_owned: bool,
1409 }
1410
1411 impl Drop for OpenChannelV2 {
1412         fn drop(&mut self) {
1413                 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1414                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1415                 }
1416         }
1417 }
1418 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1419 #[no_mangle]
1420 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1421 #[allow(unused)]
1422 /// Used only if an object of this type is returned as a trait impl by a method
1423 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1424         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1425 }
1426 #[allow(unused)]
1427 impl OpenChannelV2 {
1428         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1429                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1430         }
1431         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1432                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1433         }
1434         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1435         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1436                 assert!(self.is_owned);
1437                 let ret = ObjOps::untweak_ptr(self.inner);
1438                 self.inner = core::ptr::null_mut();
1439                 ret
1440         }
1441 }
1442 /// Common fields of `open_channel(2)`-like messages
1443 #[no_mangle]
1444 pub extern "C" fn OpenChannelV2_get_common_fields(this_ptr: &OpenChannelV2) -> crate::lightning::ln::msgs::CommonOpenChannelFields {
1445         let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
1446         crate::lightning::ln::msgs::CommonOpenChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonOpenChannelFields<>) as *mut _) }, is_owned: false }
1447 }
1448 /// Common fields of `open_channel(2)`-like messages
1449 #[no_mangle]
1450 pub extern "C" fn OpenChannelV2_set_common_fields(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::msgs::CommonOpenChannelFields) {
1451         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
1452 }
1453 /// The feerate for the funding transaction set by the channel initiator
1454 #[no_mangle]
1455 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1456         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1457         *inner_val
1458 }
1459 /// The feerate for the funding transaction set by the channel initiator
1460 #[no_mangle]
1461 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1462         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1463 }
1464 /// The locktime for the funding transaction
1465 #[no_mangle]
1466 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1467         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1468         *inner_val
1469 }
1470 /// The locktime for the funding transaction
1471 #[no_mangle]
1472 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1473         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1474 }
1475 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1476 #[no_mangle]
1477 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1478         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1479         crate::c_types::PublicKey::from_rust(&inner_val)
1480 }
1481 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1482 #[no_mangle]
1483 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1484         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1485 }
1486 /// Optionally, a requirement that only confirmed inputs can be added
1487 #[no_mangle]
1488 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1489         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1490         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 /*  { () /**/ } */ };
1491         local_inner_val
1492 }
1493 /// Optionally, a requirement that only confirmed inputs can be added
1494 #[no_mangle]
1495 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1496         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1497         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1498 }
1499 /// Constructs a new OpenChannelV2 given each field
1500 #[must_use]
1501 #[no_mangle]
1502 pub extern "C" fn OpenChannelV2_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonOpenChannelFields, mut funding_feerate_sat_per_1000_weight_arg: u32, mut locktime_arg: u32, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 {
1503         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1504         OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1505                 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
1506                 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1507                 locktime: locktime_arg,
1508                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1509                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1510         }), is_owned: true }
1511 }
1512 impl Clone for OpenChannelV2 {
1513         fn clone(&self) -> Self {
1514                 Self {
1515                         inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1516                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1517                         is_owned: true,
1518                 }
1519         }
1520 }
1521 #[allow(unused)]
1522 /// Used only if an object of this type is returned as a trait impl by a method
1523 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1524         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannelV2)).clone() })) as *mut c_void
1525 }
1526 #[no_mangle]
1527 /// Creates a copy of the OpenChannelV2
1528 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1529         orig.clone()
1530 }
1531 /// Get a string which allows debug introspection of a OpenChannelV2 object
1532 pub extern "C" fn OpenChannelV2_debug_str_void(o: *const c_void) -> Str {
1533         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannelV2 }).into()}
1534 /// Generates a non-cryptographic 64-bit hash of the OpenChannelV2.
1535 #[no_mangle]
1536 pub extern "C" fn OpenChannelV2_hash(o: &OpenChannelV2) -> u64 {
1537         if o.inner.is_null() { return 0; }
1538         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1539         #[allow(deprecated)]
1540         let mut hasher = core::hash::SipHasher::new();
1541         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1542         core::hash::Hasher::finish(&hasher)
1543 }
1544 /// Checks if two OpenChannelV2s contain equal inner contents.
1545 /// This ignores pointers and is_owned flags and looks at the values in fields.
1546 /// Two objects with NULL inner values will be considered "equal" here.
1547 #[no_mangle]
1548 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1549         if a.inner == b.inner { return true; }
1550         if a.inner.is_null() || b.inner.is_null() { return false; }
1551         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1552 }
1553
1554 use lightning::ln::msgs::CommonAcceptChannelFields as nativeCommonAcceptChannelFieldsImport;
1555 pub(crate) type nativeCommonAcceptChannelFields = nativeCommonAcceptChannelFieldsImport;
1556
1557 /// Contains fields that are both common to [`accept_channel`] and `accept_channel2` messages.
1558 ///
1559 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1560 #[must_use]
1561 #[repr(C)]
1562 pub struct CommonAcceptChannelFields {
1563         /// A pointer to the opaque Rust object.
1564
1565         /// Nearly everywhere, inner must be non-null, however in places where
1566         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1567         pub inner: *mut nativeCommonAcceptChannelFields,
1568         /// Indicates that this is the only struct which contains the same pointer.
1569
1570         /// Rust functions which take ownership of an object provided via an argument require
1571         /// this to be true and invalidate the object pointed to by inner.
1572         pub is_owned: bool,
1573 }
1574
1575 impl Drop for CommonAcceptChannelFields {
1576         fn drop(&mut self) {
1577                 if self.is_owned && !<*mut nativeCommonAcceptChannelFields>::is_null(self.inner) {
1578                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1579                 }
1580         }
1581 }
1582 /// Frees any resources used by the CommonAcceptChannelFields, if is_owned is set and inner is non-NULL.
1583 #[no_mangle]
1584 pub extern "C" fn CommonAcceptChannelFields_free(this_obj: CommonAcceptChannelFields) { }
1585 #[allow(unused)]
1586 /// Used only if an object of this type is returned as a trait impl by a method
1587 pub(crate) extern "C" fn CommonAcceptChannelFields_free_void(this_ptr: *mut c_void) {
1588         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommonAcceptChannelFields) };
1589 }
1590 #[allow(unused)]
1591 impl CommonAcceptChannelFields {
1592         pub(crate) fn get_native_ref(&self) -> &'static nativeCommonAcceptChannelFields {
1593                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1594         }
1595         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommonAcceptChannelFields {
1596                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1597         }
1598         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1599         pub(crate) fn take_inner(mut self) -> *mut nativeCommonAcceptChannelFields {
1600                 assert!(self.is_owned);
1601                 let ret = ObjOps::untweak_ptr(self.inner);
1602                 self.inner = core::ptr::null_mut();
1603                 ret
1604         }
1605 }
1606 /// The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message.
1607 #[no_mangle]
1608 pub extern "C" fn CommonAcceptChannelFields_get_temporary_channel_id(this_ptr: &CommonAcceptChannelFields) -> crate::lightning::ln::types::ChannelId {
1609         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1610         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
1611 }
1612 /// The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message.
1613 #[no_mangle]
1614 pub extern "C" fn CommonAcceptChannelFields_set_temporary_channel_id(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::lightning::ln::types::ChannelId) {
1615         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) };
1616 }
1617 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1618 /// omitted
1619 #[no_mangle]
1620 pub extern "C" fn CommonAcceptChannelFields_get_dust_limit_satoshis(this_ptr: &CommonAcceptChannelFields) -> u64 {
1621         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1622         *inner_val
1623 }
1624 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1625 /// omitted
1626 #[no_mangle]
1627 pub extern "C" fn CommonAcceptChannelFields_set_dust_limit_satoshis(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) {
1628         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1629 }
1630 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1631 #[no_mangle]
1632 pub extern "C" fn CommonAcceptChannelFields_get_max_htlc_value_in_flight_msat(this_ptr: &CommonAcceptChannelFields) -> u64 {
1633         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1634         *inner_val
1635 }
1636 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1637 #[no_mangle]
1638 pub extern "C" fn CommonAcceptChannelFields_set_max_htlc_value_in_flight_msat(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) {
1639         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1640 }
1641 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1642 #[no_mangle]
1643 pub extern "C" fn CommonAcceptChannelFields_get_htlc_minimum_msat(this_ptr: &CommonAcceptChannelFields) -> u64 {
1644         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1645         *inner_val
1646 }
1647 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1648 #[no_mangle]
1649 pub extern "C" fn CommonAcceptChannelFields_set_htlc_minimum_msat(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) {
1650         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1651 }
1652 /// Minimum depth of the funding transaction before the channel is considered open
1653 #[no_mangle]
1654 pub extern "C" fn CommonAcceptChannelFields_get_minimum_depth(this_ptr: &CommonAcceptChannelFields) -> u32 {
1655         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1656         *inner_val
1657 }
1658 /// Minimum depth of the funding transaction before the channel is considered open
1659 #[no_mangle]
1660 pub extern "C" fn CommonAcceptChannelFields_set_minimum_depth(this_ptr: &mut CommonAcceptChannelFields, mut val: u32) {
1661         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1662 }
1663 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1664 /// broadcast a commitment transaction
1665 #[no_mangle]
1666 pub extern "C" fn CommonAcceptChannelFields_get_to_self_delay(this_ptr: &CommonAcceptChannelFields) -> u16 {
1667         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1668         *inner_val
1669 }
1670 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1671 /// broadcast a commitment transaction
1672 #[no_mangle]
1673 pub extern "C" fn CommonAcceptChannelFields_set_to_self_delay(this_ptr: &mut CommonAcceptChannelFields, mut val: u16) {
1674         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1675 }
1676 /// The maximum number of inbound HTLCs towards channel acceptor
1677 #[no_mangle]
1678 pub extern "C" fn CommonAcceptChannelFields_get_max_accepted_htlcs(this_ptr: &CommonAcceptChannelFields) -> u16 {
1679         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1680         *inner_val
1681 }
1682 /// The maximum number of inbound HTLCs towards channel acceptor
1683 #[no_mangle]
1684 pub extern "C" fn CommonAcceptChannelFields_set_max_accepted_htlcs(this_ptr: &mut CommonAcceptChannelFields, mut val: u16) {
1685         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1686 }
1687 /// The channel acceptor's key controlling the funding transaction
1688 #[no_mangle]
1689 pub extern "C" fn CommonAcceptChannelFields_get_funding_pubkey(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1690         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1691         crate::c_types::PublicKey::from_rust(&inner_val)
1692 }
1693 /// The channel acceptor's key controlling the funding transaction
1694 #[no_mangle]
1695 pub extern "C" fn CommonAcceptChannelFields_set_funding_pubkey(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1696         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1697 }
1698 /// Used to derive a revocation key for transactions broadcast by counterparty
1699 #[no_mangle]
1700 pub extern "C" fn CommonAcceptChannelFields_get_revocation_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1701         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1702         crate::c_types::PublicKey::from_rust(&inner_val)
1703 }
1704 /// Used to derive a revocation key for transactions broadcast by counterparty
1705 #[no_mangle]
1706 pub extern "C" fn CommonAcceptChannelFields_set_revocation_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1707         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1708 }
1709 /// A payment key to channel acceptor for transactions broadcast by counterparty
1710 #[no_mangle]
1711 pub extern "C" fn CommonAcceptChannelFields_get_payment_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1712         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1713         crate::c_types::PublicKey::from_rust(&inner_val)
1714 }
1715 /// A payment key to channel acceptor for transactions broadcast by counterparty
1716 #[no_mangle]
1717 pub extern "C" fn CommonAcceptChannelFields_set_payment_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1718         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1719 }
1720 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
1721 /// acceptor
1722 #[no_mangle]
1723 pub extern "C" fn CommonAcceptChannelFields_get_delayed_payment_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1724         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1725         crate::c_types::PublicKey::from_rust(&inner_val)
1726 }
1727 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
1728 /// acceptor
1729 #[no_mangle]
1730 pub extern "C" fn CommonAcceptChannelFields_set_delayed_payment_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1731         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1732 }
1733 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
1734 #[no_mangle]
1735 pub extern "C" fn CommonAcceptChannelFields_get_htlc_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1736         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1737         crate::c_types::PublicKey::from_rust(&inner_val)
1738 }
1739 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
1740 #[no_mangle]
1741 pub extern "C" fn CommonAcceptChannelFields_set_htlc_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1742         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1743 }
1744 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
1745 #[no_mangle]
1746 pub extern "C" fn CommonAcceptChannelFields_get_first_per_commitment_point(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1747         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1748         crate::c_types::PublicKey::from_rust(&inner_val)
1749 }
1750 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
1751 #[no_mangle]
1752 pub extern "C" fn CommonAcceptChannelFields_set_first_per_commitment_point(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1753         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1754 }
1755 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
1756 /// collaboratively close
1757 #[no_mangle]
1758 pub extern "C" fn CommonAcceptChannelFields_get_shutdown_scriptpubkey(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::derived::COption_CVec_u8ZZ {
1759         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1760         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() }) };
1761         local_inner_val
1762 }
1763 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
1764 /// collaboratively close
1765 #[no_mangle]
1766 pub extern "C" fn CommonAcceptChannelFields_set_shutdown_scriptpubkey(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1767         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()) }})} };
1768         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1769 }
1770 /// The channel type that this channel will represent. If none is set, we derive the channel
1771 /// type from the intersection of our feature bits with our counterparty's feature bits from
1772 /// the Init message.
1773 ///
1774 /// This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s
1775 /// [`CommonOpenChannelFields::channel_type`].
1776 ///
1777 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1778 #[no_mangle]
1779 pub extern "C" fn CommonAcceptChannelFields_get_channel_type(this_ptr: &CommonAcceptChannelFields) -> crate::lightning::ln::features::ChannelTypeFeatures {
1780         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1781         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 };
1782         local_inner_val
1783 }
1784 /// The channel type that this channel will represent. If none is set, we derive the channel
1785 /// type from the intersection of our feature bits with our counterparty's feature bits from
1786 /// the Init message.
1787 ///
1788 /// This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s
1789 /// [`CommonOpenChannelFields::channel_type`].
1790 ///
1791 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1792 #[no_mangle]
1793 pub extern "C" fn CommonAcceptChannelFields_set_channel_type(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1794         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1795         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1796 }
1797 /// Constructs a new CommonAcceptChannelFields given each field
1798 ///
1799 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1800 #[must_use]
1801 #[no_mangle]
1802 pub extern "C" fn CommonAcceptChannelFields_new(mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, 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 shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> CommonAcceptChannelFields {
1803         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()) }})} };
1804         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()) } }) };
1805         CommonAcceptChannelFields { inner: ObjOps::heap_alloc(nativeCommonAcceptChannelFields {
1806                 temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) },
1807                 dust_limit_satoshis: dust_limit_satoshis_arg,
1808                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1809                 htlc_minimum_msat: htlc_minimum_msat_arg,
1810                 minimum_depth: minimum_depth_arg,
1811                 to_self_delay: to_self_delay_arg,
1812                 max_accepted_htlcs: max_accepted_htlcs_arg,
1813                 funding_pubkey: funding_pubkey_arg.into_rust(),
1814                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1815                 payment_basepoint: payment_basepoint_arg.into_rust(),
1816                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1817                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1818                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1819                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1820                 channel_type: local_channel_type_arg,
1821         }), is_owned: true }
1822 }
1823 impl Clone for CommonAcceptChannelFields {
1824         fn clone(&self) -> Self {
1825                 Self {
1826                         inner: if <*mut nativeCommonAcceptChannelFields>::is_null(self.inner) { core::ptr::null_mut() } else {
1827                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1828                         is_owned: true,
1829                 }
1830         }
1831 }
1832 #[allow(unused)]
1833 /// Used only if an object of this type is returned as a trait impl by a method
1834 pub(crate) extern "C" fn CommonAcceptChannelFields_clone_void(this_ptr: *const c_void) -> *mut c_void {
1835         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommonAcceptChannelFields)).clone() })) as *mut c_void
1836 }
1837 #[no_mangle]
1838 /// Creates a copy of the CommonAcceptChannelFields
1839 pub extern "C" fn CommonAcceptChannelFields_clone(orig: &CommonAcceptChannelFields) -> CommonAcceptChannelFields {
1840         orig.clone()
1841 }
1842 /// Get a string which allows debug introspection of a CommonAcceptChannelFields object
1843 pub extern "C" fn CommonAcceptChannelFields_debug_str_void(o: *const c_void) -> Str {
1844         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommonAcceptChannelFields }).into()}
1845 /// Generates a non-cryptographic 64-bit hash of the CommonAcceptChannelFields.
1846 #[no_mangle]
1847 pub extern "C" fn CommonAcceptChannelFields_hash(o: &CommonAcceptChannelFields) -> u64 {
1848         if o.inner.is_null() { return 0; }
1849         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1850         #[allow(deprecated)]
1851         let mut hasher = core::hash::SipHasher::new();
1852         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1853         core::hash::Hasher::finish(&hasher)
1854 }
1855 /// Checks if two CommonAcceptChannelFieldss contain equal inner contents.
1856 /// This ignores pointers and is_owned flags and looks at the values in fields.
1857 /// Two objects with NULL inner values will be considered "equal" here.
1858 #[no_mangle]
1859 pub extern "C" fn CommonAcceptChannelFields_eq(a: &CommonAcceptChannelFields, b: &CommonAcceptChannelFields) -> bool {
1860         if a.inner == b.inner { return true; }
1861         if a.inner.is_null() || b.inner.is_null() { return false; }
1862         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1863 }
1864
1865 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1866 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1867
1868 /// An [`accept_channel`] message to be sent to or received from a peer.
1869 ///
1870 /// Used in V1 channel establishment
1871 ///
1872 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1873 #[must_use]
1874 #[repr(C)]
1875 pub struct AcceptChannel {
1876         /// A pointer to the opaque Rust object.
1877
1878         /// Nearly everywhere, inner must be non-null, however in places where
1879         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1880         pub inner: *mut nativeAcceptChannel,
1881         /// Indicates that this is the only struct which contains the same pointer.
1882
1883         /// Rust functions which take ownership of an object provided via an argument require
1884         /// this to be true and invalidate the object pointed to by inner.
1885         pub is_owned: bool,
1886 }
1887
1888 impl Drop for AcceptChannel {
1889         fn drop(&mut self) {
1890                 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1891                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1892                 }
1893         }
1894 }
1895 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1896 #[no_mangle]
1897 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1898 #[allow(unused)]
1899 /// Used only if an object of this type is returned as a trait impl by a method
1900 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1901         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1902 }
1903 #[allow(unused)]
1904 impl AcceptChannel {
1905         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1906                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1907         }
1908         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1909                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1910         }
1911         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1912         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1913                 assert!(self.is_owned);
1914                 let ret = ObjOps::untweak_ptr(self.inner);
1915                 self.inner = core::ptr::null_mut();
1916                 ret
1917         }
1918 }
1919 /// Common fields of `accept_channel(2)`-like messages
1920 #[no_mangle]
1921 pub extern "C" fn AcceptChannel_get_common_fields(this_ptr: &AcceptChannel) -> crate::lightning::ln::msgs::CommonAcceptChannelFields {
1922         let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
1923         crate::lightning::ln::msgs::CommonAcceptChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonAcceptChannelFields<>) as *mut _) }, is_owned: false }
1924 }
1925 /// Common fields of `accept_channel(2)`-like messages
1926 #[no_mangle]
1927 pub extern "C" fn AcceptChannel_set_common_fields(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::msgs::CommonAcceptChannelFields) {
1928         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
1929 }
1930 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1931 #[no_mangle]
1932 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1933         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1934         *inner_val
1935 }
1936 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1937 #[no_mangle]
1938 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1939         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1940 }
1941 /// Constructs a new AcceptChannel given each field
1942 #[must_use]
1943 #[no_mangle]
1944 pub extern "C" fn AcceptChannel_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonAcceptChannelFields, mut channel_reserve_satoshis_arg: u64) -> AcceptChannel {
1945         AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1946                 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
1947                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1948         }), is_owned: true }
1949 }
1950 impl Clone for AcceptChannel {
1951         fn clone(&self) -> Self {
1952                 Self {
1953                         inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1954                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1955                         is_owned: true,
1956                 }
1957         }
1958 }
1959 #[allow(unused)]
1960 /// Used only if an object of this type is returned as a trait impl by a method
1961 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1962         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannel)).clone() })) as *mut c_void
1963 }
1964 #[no_mangle]
1965 /// Creates a copy of the AcceptChannel
1966 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1967         orig.clone()
1968 }
1969 /// Get a string which allows debug introspection of a AcceptChannel object
1970 pub extern "C" fn AcceptChannel_debug_str_void(o: *const c_void) -> Str {
1971         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AcceptChannel }).into()}
1972 /// Generates a non-cryptographic 64-bit hash of the AcceptChannel.
1973 #[no_mangle]
1974 pub extern "C" fn AcceptChannel_hash(o: &AcceptChannel) -> u64 {
1975         if o.inner.is_null() { return 0; }
1976         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1977         #[allow(deprecated)]
1978         let mut hasher = core::hash::SipHasher::new();
1979         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1980         core::hash::Hasher::finish(&hasher)
1981 }
1982 /// Checks if two AcceptChannels contain equal inner contents.
1983 /// This ignores pointers and is_owned flags and looks at the values in fields.
1984 /// Two objects with NULL inner values will be considered "equal" here.
1985 #[no_mangle]
1986 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1987         if a.inner == b.inner { return true; }
1988         if a.inner.is_null() || b.inner.is_null() { return false; }
1989         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1990 }
1991
1992 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1993 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1994
1995 /// An accept_channel2 message to be sent by or received from the channel accepter.
1996 ///
1997 /// Used in V2 channel establishment
1998 ///
1999 #[must_use]
2000 #[repr(C)]
2001 pub struct AcceptChannelV2 {
2002         /// A pointer to the opaque Rust object.
2003
2004         /// Nearly everywhere, inner must be non-null, however in places where
2005         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2006         pub inner: *mut nativeAcceptChannelV2,
2007         /// Indicates that this is the only struct which contains the same pointer.
2008
2009         /// Rust functions which take ownership of an object provided via an argument require
2010         /// this to be true and invalidate the object pointed to by inner.
2011         pub is_owned: bool,
2012 }
2013
2014 impl Drop for AcceptChannelV2 {
2015         fn drop(&mut self) {
2016                 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
2017                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2018                 }
2019         }
2020 }
2021 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
2022 #[no_mangle]
2023 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
2024 #[allow(unused)]
2025 /// Used only if an object of this type is returned as a trait impl by a method
2026 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
2027         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
2028 }
2029 #[allow(unused)]
2030 impl AcceptChannelV2 {
2031         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
2032                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2033         }
2034         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
2035                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2036         }
2037         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2038         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
2039                 assert!(self.is_owned);
2040                 let ret = ObjOps::untweak_ptr(self.inner);
2041                 self.inner = core::ptr::null_mut();
2042                 ret
2043         }
2044 }
2045 /// Common fields of `accept_channel(2)`-like messages
2046 #[no_mangle]
2047 pub extern "C" fn AcceptChannelV2_get_common_fields(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::msgs::CommonAcceptChannelFields {
2048         let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
2049         crate::lightning::ln::msgs::CommonAcceptChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonAcceptChannelFields<>) as *mut _) }, is_owned: false }
2050 }
2051 /// Common fields of `accept_channel(2)`-like messages
2052 #[no_mangle]
2053 pub extern "C" fn AcceptChannelV2_set_common_fields(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::msgs::CommonAcceptChannelFields) {
2054         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
2055 }
2056 /// Part of the channel value contributed by the channel acceptor
2057 #[no_mangle]
2058 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
2059         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
2060         *inner_val
2061 }
2062 /// Part of the channel value contributed by the channel acceptor
2063 #[no_mangle]
2064 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2065         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
2066 }
2067 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2068 #[no_mangle]
2069 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2070         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2071         crate::c_types::PublicKey::from_rust(&inner_val)
2072 }
2073 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2074 #[no_mangle]
2075 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2076         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2077 }
2078 /// Optionally, a requirement that only confirmed inputs can be added
2079 #[no_mangle]
2080 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2081         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2082         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 /*  { () /**/ } */ };
2083         local_inner_val
2084 }
2085 /// Optionally, a requirement that only confirmed inputs can be added
2086 #[no_mangle]
2087 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2088         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2089         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2090 }
2091 /// Constructs a new AcceptChannelV2 given each field
2092 #[must_use]
2093 #[no_mangle]
2094 pub extern "C" fn AcceptChannelV2_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonAcceptChannelFields, mut funding_satoshis_arg: u64, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 {
2095         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2096         AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2097                 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
2098                 funding_satoshis: funding_satoshis_arg,
2099                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2100                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2101         }), is_owned: true }
2102 }
2103 impl Clone for AcceptChannelV2 {
2104         fn clone(&self) -> Self {
2105                 Self {
2106                         inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2107                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2108                         is_owned: true,
2109                 }
2110         }
2111 }
2112 #[allow(unused)]
2113 /// Used only if an object of this type is returned as a trait impl by a method
2114 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2115         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannelV2)).clone() })) as *mut c_void
2116 }
2117 #[no_mangle]
2118 /// Creates a copy of the AcceptChannelV2
2119 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2120         orig.clone()
2121 }
2122 /// Get a string which allows debug introspection of a AcceptChannelV2 object
2123 pub extern "C" fn AcceptChannelV2_debug_str_void(o: *const c_void) -> Str {
2124         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AcceptChannelV2 }).into()}
2125 /// Generates a non-cryptographic 64-bit hash of the AcceptChannelV2.
2126 #[no_mangle]
2127 pub extern "C" fn AcceptChannelV2_hash(o: &AcceptChannelV2) -> u64 {
2128         if o.inner.is_null() { return 0; }
2129         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2130         #[allow(deprecated)]
2131         let mut hasher = core::hash::SipHasher::new();
2132         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2133         core::hash::Hasher::finish(&hasher)
2134 }
2135 /// Checks if two AcceptChannelV2s contain equal inner contents.
2136 /// This ignores pointers and is_owned flags and looks at the values in fields.
2137 /// Two objects with NULL inner values will be considered "equal" here.
2138 #[no_mangle]
2139 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2140         if a.inner == b.inner { return true; }
2141         if a.inner.is_null() || b.inner.is_null() { return false; }
2142         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2143 }
2144
2145 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2146 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2147
2148 /// A [`funding_created`] message to be sent to or received from a peer.
2149 ///
2150 /// Used in V1 channel establishment
2151 ///
2152 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2153 #[must_use]
2154 #[repr(C)]
2155 pub struct FundingCreated {
2156         /// A pointer to the opaque Rust object.
2157
2158         /// Nearly everywhere, inner must be non-null, however in places where
2159         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2160         pub inner: *mut nativeFundingCreated,
2161         /// Indicates that this is the only struct which contains the same pointer.
2162
2163         /// Rust functions which take ownership of an object provided via an argument require
2164         /// this to be true and invalidate the object pointed to by inner.
2165         pub is_owned: bool,
2166 }
2167
2168 impl Drop for FundingCreated {
2169         fn drop(&mut self) {
2170                 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2171                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2172                 }
2173         }
2174 }
2175 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2176 #[no_mangle]
2177 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2178 #[allow(unused)]
2179 /// Used only if an object of this type is returned as a trait impl by a method
2180 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2181         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2182 }
2183 #[allow(unused)]
2184 impl FundingCreated {
2185         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2186                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2187         }
2188         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2189                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2190         }
2191         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2192         pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2193                 assert!(self.is_owned);
2194                 let ret = ObjOps::untweak_ptr(self.inner);
2195                 self.inner = core::ptr::null_mut();
2196                 ret
2197         }
2198 }
2199 /// A temporary channel ID, until the funding is established
2200 #[no_mangle]
2201 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> crate::lightning::ln::types::ChannelId {
2202         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2203         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2204 }
2205 /// A temporary channel ID, until the funding is established
2206 #[no_mangle]
2207 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::lightning::ln::types::ChannelId) {
2208         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2209 }
2210 /// The funding transaction ID
2211 #[no_mangle]
2212 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2213         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2214         inner_val.as_ref()
2215 }
2216 /// The funding transaction ID
2217 #[no_mangle]
2218 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2219         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2220 }
2221 /// The specific output index funding this channel
2222 #[no_mangle]
2223 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2224         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2225         *inner_val
2226 }
2227 /// The specific output index funding this channel
2228 #[no_mangle]
2229 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2230         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2231 }
2232 /// The signature of the channel initiator (funder) on the initial commitment transaction
2233 #[no_mangle]
2234 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::ECDSASignature {
2235         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2236         crate::c_types::ECDSASignature::from_rust(&inner_val)
2237 }
2238 /// The signature of the channel initiator (funder) on the initial commitment transaction
2239 #[no_mangle]
2240 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::ECDSASignature) {
2241         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2242 }
2243 /// Constructs a new FundingCreated given each field
2244 #[must_use]
2245 #[no_mangle]
2246 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::ECDSASignature) -> FundingCreated {
2247         FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2248                 temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) },
2249                 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2250                 funding_output_index: funding_output_index_arg,
2251                 signature: signature_arg.into_rust(),
2252         }), is_owned: true }
2253 }
2254 impl Clone for FundingCreated {
2255         fn clone(&self) -> Self {
2256                 Self {
2257                         inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2258                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2259                         is_owned: true,
2260                 }
2261         }
2262 }
2263 #[allow(unused)]
2264 /// Used only if an object of this type is returned as a trait impl by a method
2265 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2266         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingCreated)).clone() })) as *mut c_void
2267 }
2268 #[no_mangle]
2269 /// Creates a copy of the FundingCreated
2270 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2271         orig.clone()
2272 }
2273 /// Get a string which allows debug introspection of a FundingCreated object
2274 pub extern "C" fn FundingCreated_debug_str_void(o: *const c_void) -> Str {
2275         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::FundingCreated }).into()}
2276 /// Generates a non-cryptographic 64-bit hash of the FundingCreated.
2277 #[no_mangle]
2278 pub extern "C" fn FundingCreated_hash(o: &FundingCreated) -> u64 {
2279         if o.inner.is_null() { return 0; }
2280         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2281         #[allow(deprecated)]
2282         let mut hasher = core::hash::SipHasher::new();
2283         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2284         core::hash::Hasher::finish(&hasher)
2285 }
2286 /// Checks if two FundingCreateds contain equal inner contents.
2287 /// This ignores pointers and is_owned flags and looks at the values in fields.
2288 /// Two objects with NULL inner values will be considered "equal" here.
2289 #[no_mangle]
2290 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2291         if a.inner == b.inner { return true; }
2292         if a.inner.is_null() || b.inner.is_null() { return false; }
2293         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2294 }
2295
2296 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2297 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2298
2299 /// A [`funding_signed`] message to be sent to or received from a peer.
2300 ///
2301 /// Used in V1 channel establishment
2302 ///
2303 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2304 #[must_use]
2305 #[repr(C)]
2306 pub struct FundingSigned {
2307         /// A pointer to the opaque Rust object.
2308
2309         /// Nearly everywhere, inner must be non-null, however in places where
2310         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2311         pub inner: *mut nativeFundingSigned,
2312         /// Indicates that this is the only struct which contains the same pointer.
2313
2314         /// Rust functions which take ownership of an object provided via an argument require
2315         /// this to be true and invalidate the object pointed to by inner.
2316         pub is_owned: bool,
2317 }
2318
2319 impl Drop for FundingSigned {
2320         fn drop(&mut self) {
2321                 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2322                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2323                 }
2324         }
2325 }
2326 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2327 #[no_mangle]
2328 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2329 #[allow(unused)]
2330 /// Used only if an object of this type is returned as a trait impl by a method
2331 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2332         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2333 }
2334 #[allow(unused)]
2335 impl FundingSigned {
2336         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2337                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2338         }
2339         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2340                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2341         }
2342         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2343         pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2344                 assert!(self.is_owned);
2345                 let ret = ObjOps::untweak_ptr(self.inner);
2346                 self.inner = core::ptr::null_mut();
2347                 ret
2348         }
2349 }
2350 /// The channel ID
2351 #[no_mangle]
2352 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> crate::lightning::ln::types::ChannelId {
2353         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2354         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2355 }
2356 /// The channel ID
2357 #[no_mangle]
2358 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::lightning::ln::types::ChannelId) {
2359         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2360 }
2361 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2362 #[no_mangle]
2363 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::ECDSASignature {
2364         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2365         crate::c_types::ECDSASignature::from_rust(&inner_val)
2366 }
2367 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2368 #[no_mangle]
2369 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::ECDSASignature) {
2370         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2371 }
2372 /// Constructs a new FundingSigned given each field
2373 #[must_use]
2374 #[no_mangle]
2375 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned {
2376         FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2377                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2378                 signature: signature_arg.into_rust(),
2379         }), is_owned: true }
2380 }
2381 impl Clone for FundingSigned {
2382         fn clone(&self) -> Self {
2383                 Self {
2384                         inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2385                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2386                         is_owned: true,
2387                 }
2388         }
2389 }
2390 #[allow(unused)]
2391 /// Used only if an object of this type is returned as a trait impl by a method
2392 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2393         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingSigned)).clone() })) as *mut c_void
2394 }
2395 #[no_mangle]
2396 /// Creates a copy of the FundingSigned
2397 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2398         orig.clone()
2399 }
2400 /// Get a string which allows debug introspection of a FundingSigned object
2401 pub extern "C" fn FundingSigned_debug_str_void(o: *const c_void) -> Str {
2402         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::FundingSigned }).into()}
2403 /// Generates a non-cryptographic 64-bit hash of the FundingSigned.
2404 #[no_mangle]
2405 pub extern "C" fn FundingSigned_hash(o: &FundingSigned) -> u64 {
2406         if o.inner.is_null() { return 0; }
2407         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2408         #[allow(deprecated)]
2409         let mut hasher = core::hash::SipHasher::new();
2410         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2411         core::hash::Hasher::finish(&hasher)
2412 }
2413 /// Checks if two FundingSigneds contain equal inner contents.
2414 /// This ignores pointers and is_owned flags and looks at the values in fields.
2415 /// Two objects with NULL inner values will be considered "equal" here.
2416 #[no_mangle]
2417 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2418         if a.inner == b.inner { return true; }
2419         if a.inner.is_null() || b.inner.is_null() { return false; }
2420         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2421 }
2422
2423 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2424 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2425
2426 /// A [`channel_ready`] message to be sent to or received from a peer.
2427 ///
2428 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2429 #[must_use]
2430 #[repr(C)]
2431 pub struct ChannelReady {
2432         /// A pointer to the opaque Rust object.
2433
2434         /// Nearly everywhere, inner must be non-null, however in places where
2435         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2436         pub inner: *mut nativeChannelReady,
2437         /// Indicates that this is the only struct which contains the same pointer.
2438
2439         /// Rust functions which take ownership of an object provided via an argument require
2440         /// this to be true and invalidate the object pointed to by inner.
2441         pub is_owned: bool,
2442 }
2443
2444 impl Drop for ChannelReady {
2445         fn drop(&mut self) {
2446                 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2447                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2448                 }
2449         }
2450 }
2451 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2452 #[no_mangle]
2453 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2454 #[allow(unused)]
2455 /// Used only if an object of this type is returned as a trait impl by a method
2456 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2457         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2458 }
2459 #[allow(unused)]
2460 impl ChannelReady {
2461         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2462                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2463         }
2464         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2465                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2466         }
2467         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2468         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2469                 assert!(self.is_owned);
2470                 let ret = ObjOps::untweak_ptr(self.inner);
2471                 self.inner = core::ptr::null_mut();
2472                 ret
2473         }
2474 }
2475 /// The channel ID
2476 #[no_mangle]
2477 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> crate::lightning::ln::types::ChannelId {
2478         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2479         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2480 }
2481 /// The channel ID
2482 #[no_mangle]
2483 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::lightning::ln::types::ChannelId) {
2484         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2485 }
2486 /// The per-commitment point of the second commitment transaction
2487 #[no_mangle]
2488 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2489         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2490         crate::c_types::PublicKey::from_rust(&inner_val)
2491 }
2492 /// The per-commitment point of the second commitment transaction
2493 #[no_mangle]
2494 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2495         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2496 }
2497 /// If set, provides a `short_channel_id` alias for this channel.
2498 ///
2499 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2500 /// messages' recipient.
2501 #[no_mangle]
2502 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2503         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2504         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() }) };
2505         local_inner_val
2506 }
2507 /// If set, provides a `short_channel_id` alias for this channel.
2508 ///
2509 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2510 /// messages' recipient.
2511 #[no_mangle]
2512 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2513         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2514         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2515 }
2516 /// Constructs a new ChannelReady given each field
2517 #[must_use]
2518 #[no_mangle]
2519 pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady {
2520         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 };
2521         ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2522                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2523                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2524                 short_channel_id_alias: local_short_channel_id_alias_arg,
2525         }), is_owned: true }
2526 }
2527 impl Clone for ChannelReady {
2528         fn clone(&self) -> Self {
2529                 Self {
2530                         inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2531                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2532                         is_owned: true,
2533                 }
2534         }
2535 }
2536 #[allow(unused)]
2537 /// Used only if an object of this type is returned as a trait impl by a method
2538 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2539         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReady)).clone() })) as *mut c_void
2540 }
2541 #[no_mangle]
2542 /// Creates a copy of the ChannelReady
2543 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2544         orig.clone()
2545 }
2546 /// Get a string which allows debug introspection of a ChannelReady object
2547 pub extern "C" fn ChannelReady_debug_str_void(o: *const c_void) -> Str {
2548         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelReady }).into()}
2549 /// Generates a non-cryptographic 64-bit hash of the ChannelReady.
2550 #[no_mangle]
2551 pub extern "C" fn ChannelReady_hash(o: &ChannelReady) -> u64 {
2552         if o.inner.is_null() { return 0; }
2553         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2554         #[allow(deprecated)]
2555         let mut hasher = core::hash::SipHasher::new();
2556         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2557         core::hash::Hasher::finish(&hasher)
2558 }
2559 /// Checks if two ChannelReadys contain equal inner contents.
2560 /// This ignores pointers and is_owned flags and looks at the values in fields.
2561 /// Two objects with NULL inner values will be considered "equal" here.
2562 #[no_mangle]
2563 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2564         if a.inner == b.inner { return true; }
2565         if a.inner.is_null() || b.inner.is_null() { return false; }
2566         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2567 }
2568
2569 use lightning::ln::msgs::Stfu as nativeStfuImport;
2570 pub(crate) type nativeStfu = nativeStfuImport;
2571
2572 /// An stfu (quiescence) message to be sent by or received from the stfu initiator.
2573 #[must_use]
2574 #[repr(C)]
2575 pub struct Stfu {
2576         /// A pointer to the opaque Rust object.
2577
2578         /// Nearly everywhere, inner must be non-null, however in places where
2579         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2580         pub inner: *mut nativeStfu,
2581         /// Indicates that this is the only struct which contains the same pointer.
2582
2583         /// Rust functions which take ownership of an object provided via an argument require
2584         /// this to be true and invalidate the object pointed to by inner.
2585         pub is_owned: bool,
2586 }
2587
2588 impl Drop for Stfu {
2589         fn drop(&mut self) {
2590                 if self.is_owned && !<*mut nativeStfu>::is_null(self.inner) {
2591                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2592                 }
2593         }
2594 }
2595 /// Frees any resources used by the Stfu, if is_owned is set and inner is non-NULL.
2596 #[no_mangle]
2597 pub extern "C" fn Stfu_free(this_obj: Stfu) { }
2598 #[allow(unused)]
2599 /// Used only if an object of this type is returned as a trait impl by a method
2600 pub(crate) extern "C" fn Stfu_free_void(this_ptr: *mut c_void) {
2601         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeStfu) };
2602 }
2603 #[allow(unused)]
2604 impl Stfu {
2605         pub(crate) fn get_native_ref(&self) -> &'static nativeStfu {
2606                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2607         }
2608         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeStfu {
2609                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2610         }
2611         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2612         pub(crate) fn take_inner(mut self) -> *mut nativeStfu {
2613                 assert!(self.is_owned);
2614                 let ret = ObjOps::untweak_ptr(self.inner);
2615                 self.inner = core::ptr::null_mut();
2616                 ret
2617         }
2618 }
2619 /// The channel ID where quiescence is intended
2620 #[no_mangle]
2621 pub extern "C" fn Stfu_get_channel_id(this_ptr: &Stfu) -> crate::lightning::ln::types::ChannelId {
2622         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2623         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2624 }
2625 /// The channel ID where quiescence is intended
2626 #[no_mangle]
2627 pub extern "C" fn Stfu_set_channel_id(this_ptr: &mut Stfu, mut val: crate::lightning::ln::types::ChannelId) {
2628         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2629 }
2630 /// Initiator flag, 1 if initiating, 0 if replying to an stfu.
2631 #[no_mangle]
2632 pub extern "C" fn Stfu_get_initiator(this_ptr: &Stfu) -> u8 {
2633         let mut inner_val = &mut this_ptr.get_native_mut_ref().initiator;
2634         *inner_val
2635 }
2636 /// Initiator flag, 1 if initiating, 0 if replying to an stfu.
2637 #[no_mangle]
2638 pub extern "C" fn Stfu_set_initiator(this_ptr: &mut Stfu, mut val: u8) {
2639         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.initiator = val;
2640 }
2641 /// Constructs a new Stfu given each field
2642 #[must_use]
2643 #[no_mangle]
2644 pub extern "C" fn Stfu_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut initiator_arg: u8) -> Stfu {
2645         Stfu { inner: ObjOps::heap_alloc(nativeStfu {
2646                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2647                 initiator: initiator_arg,
2648         }), is_owned: true }
2649 }
2650 impl Clone for Stfu {
2651         fn clone(&self) -> Self {
2652                 Self {
2653                         inner: if <*mut nativeStfu>::is_null(self.inner) { core::ptr::null_mut() } else {
2654                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2655                         is_owned: true,
2656                 }
2657         }
2658 }
2659 #[allow(unused)]
2660 /// Used only if an object of this type is returned as a trait impl by a method
2661 pub(crate) extern "C" fn Stfu_clone_void(this_ptr: *const c_void) -> *mut c_void {
2662         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeStfu)).clone() })) as *mut c_void
2663 }
2664 #[no_mangle]
2665 /// Creates a copy of the Stfu
2666 pub extern "C" fn Stfu_clone(orig: &Stfu) -> Stfu {
2667         orig.clone()
2668 }
2669 /// Get a string which allows debug introspection of a Stfu object
2670 pub extern "C" fn Stfu_debug_str_void(o: *const c_void) -> Str {
2671         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Stfu }).into()}
2672 /// Checks if two Stfus contain equal inner contents.
2673 /// This ignores pointers and is_owned flags and looks at the values in fields.
2674 /// Two objects with NULL inner values will be considered "equal" here.
2675 #[no_mangle]
2676 pub extern "C" fn Stfu_eq(a: &Stfu, b: &Stfu) -> bool {
2677         if a.inner == b.inner { return true; }
2678         if a.inner.is_null() || b.inner.is_null() { return false; }
2679         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2680 }
2681
2682 use lightning::ln::msgs::Splice as nativeSpliceImport;
2683 pub(crate) type nativeSplice = nativeSpliceImport;
2684
2685 /// A splice message to be sent by or received from the stfu initiator (splice initiator).
2686 #[must_use]
2687 #[repr(C)]
2688 pub struct Splice {
2689         /// A pointer to the opaque Rust object.
2690
2691         /// Nearly everywhere, inner must be non-null, however in places where
2692         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2693         pub inner: *mut nativeSplice,
2694         /// Indicates that this is the only struct which contains the same pointer.
2695
2696         /// Rust functions which take ownership of an object provided via an argument require
2697         /// this to be true and invalidate the object pointed to by inner.
2698         pub is_owned: bool,
2699 }
2700
2701 impl Drop for Splice {
2702         fn drop(&mut self) {
2703                 if self.is_owned && !<*mut nativeSplice>::is_null(self.inner) {
2704                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2705                 }
2706         }
2707 }
2708 /// Frees any resources used by the Splice, if is_owned is set and inner is non-NULL.
2709 #[no_mangle]
2710 pub extern "C" fn Splice_free(this_obj: Splice) { }
2711 #[allow(unused)]
2712 /// Used only if an object of this type is returned as a trait impl by a method
2713 pub(crate) extern "C" fn Splice_free_void(this_ptr: *mut c_void) {
2714         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSplice) };
2715 }
2716 #[allow(unused)]
2717 impl Splice {
2718         pub(crate) fn get_native_ref(&self) -> &'static nativeSplice {
2719                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2720         }
2721         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSplice {
2722                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2723         }
2724         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2725         pub(crate) fn take_inner(mut self) -> *mut nativeSplice {
2726                 assert!(self.is_owned);
2727                 let ret = ObjOps::untweak_ptr(self.inner);
2728                 self.inner = core::ptr::null_mut();
2729                 ret
2730         }
2731 }
2732 /// The channel ID where splicing is intended
2733 #[no_mangle]
2734 pub extern "C" fn Splice_get_channel_id(this_ptr: &Splice) -> crate::lightning::ln::types::ChannelId {
2735         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2736         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2737 }
2738 /// The channel ID where splicing is intended
2739 #[no_mangle]
2740 pub extern "C" fn Splice_set_channel_id(this_ptr: &mut Splice, mut val: crate::lightning::ln::types::ChannelId) {
2741         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2742 }
2743 /// The genesis hash of the blockchain where the channel is intended to be spliced
2744 #[no_mangle]
2745 pub extern "C" fn Splice_get_chain_hash(this_ptr: &Splice) -> *const [u8; 32] {
2746         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
2747         inner_val.as_ref()
2748 }
2749 /// The genesis hash of the blockchain where the channel is intended to be spliced
2750 #[no_mangle]
2751 pub extern "C" fn Splice_set_chain_hash(this_ptr: &mut Splice, mut val: crate::c_types::ThirtyTwoBytes) {
2752         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
2753 }
2754 /// The intended change in channel capacity: the amount to be added (positive value)
2755 /// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
2756 #[no_mangle]
2757 pub extern "C" fn Splice_get_relative_satoshis(this_ptr: &Splice) -> i64 {
2758         let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis;
2759         *inner_val
2760 }
2761 /// The intended change in channel capacity: the amount to be added (positive value)
2762 /// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
2763 #[no_mangle]
2764 pub extern "C" fn Splice_set_relative_satoshis(this_ptr: &mut Splice, mut val: i64) {
2765         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val;
2766 }
2767 /// The feerate for the new funding transaction, set by the splice initiator
2768 #[no_mangle]
2769 pub extern "C" fn Splice_get_funding_feerate_perkw(this_ptr: &Splice) -> u32 {
2770         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_perkw;
2771         *inner_val
2772 }
2773 /// The feerate for the new funding transaction, set by the splice initiator
2774 #[no_mangle]
2775 pub extern "C" fn Splice_set_funding_feerate_perkw(this_ptr: &mut Splice, mut val: u32) {
2776         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_perkw = val;
2777 }
2778 /// The locktime for the new funding transaction
2779 #[no_mangle]
2780 pub extern "C" fn Splice_get_locktime(this_ptr: &Splice) -> u32 {
2781         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
2782         *inner_val
2783 }
2784 /// The locktime for the new funding transaction
2785 #[no_mangle]
2786 pub extern "C" fn Splice_set_locktime(this_ptr: &mut Splice, mut val: u32) {
2787         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
2788 }
2789 /// The key of the sender (splice initiator) controlling the new funding transaction
2790 #[no_mangle]
2791 pub extern "C" fn Splice_get_funding_pubkey(this_ptr: &Splice) -> crate::c_types::PublicKey {
2792         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
2793         crate::c_types::PublicKey::from_rust(&inner_val)
2794 }
2795 /// The key of the sender (splice initiator) controlling the new funding transaction
2796 #[no_mangle]
2797 pub extern "C" fn Splice_set_funding_pubkey(this_ptr: &mut Splice, mut val: crate::c_types::PublicKey) {
2798         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
2799 }
2800 /// Constructs a new Splice given each field
2801 #[must_use]
2802 #[no_mangle]
2803 pub extern "C" fn Splice_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, 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 {
2804         Splice { inner: ObjOps::heap_alloc(nativeSplice {
2805                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2806                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
2807                 relative_satoshis: relative_satoshis_arg,
2808                 funding_feerate_perkw: funding_feerate_perkw_arg,
2809                 locktime: locktime_arg,
2810                 funding_pubkey: funding_pubkey_arg.into_rust(),
2811         }), is_owned: true }
2812 }
2813 impl Clone for Splice {
2814         fn clone(&self) -> Self {
2815                 Self {
2816                         inner: if <*mut nativeSplice>::is_null(self.inner) { core::ptr::null_mut() } else {
2817                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2818                         is_owned: true,
2819                 }
2820         }
2821 }
2822 #[allow(unused)]
2823 /// Used only if an object of this type is returned as a trait impl by a method
2824 pub(crate) extern "C" fn Splice_clone_void(this_ptr: *const c_void) -> *mut c_void {
2825         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSplice)).clone() })) as *mut c_void
2826 }
2827 #[no_mangle]
2828 /// Creates a copy of the Splice
2829 pub extern "C" fn Splice_clone(orig: &Splice) -> Splice {
2830         orig.clone()
2831 }
2832 /// Get a string which allows debug introspection of a Splice object
2833 pub extern "C" fn Splice_debug_str_void(o: *const c_void) -> Str {
2834         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Splice }).into()}
2835 /// Checks if two Splices contain equal inner contents.
2836 /// This ignores pointers and is_owned flags and looks at the values in fields.
2837 /// Two objects with NULL inner values will be considered "equal" here.
2838 #[no_mangle]
2839 pub extern "C" fn Splice_eq(a: &Splice, b: &Splice) -> bool {
2840         if a.inner == b.inner { return true; }
2841         if a.inner.is_null() || b.inner.is_null() { return false; }
2842         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2843 }
2844
2845 use lightning::ln::msgs::SpliceAck as nativeSpliceAckImport;
2846 pub(crate) type nativeSpliceAck = nativeSpliceAckImport;
2847
2848 /// A splice_ack message to be received by or sent to the splice initiator.
2849 ///
2850 #[must_use]
2851 #[repr(C)]
2852 pub struct SpliceAck {
2853         /// A pointer to the opaque Rust object.
2854
2855         /// Nearly everywhere, inner must be non-null, however in places where
2856         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2857         pub inner: *mut nativeSpliceAck,
2858         /// Indicates that this is the only struct which contains the same pointer.
2859
2860         /// Rust functions which take ownership of an object provided via an argument require
2861         /// this to be true and invalidate the object pointed to by inner.
2862         pub is_owned: bool,
2863 }
2864
2865 impl Drop for SpliceAck {
2866         fn drop(&mut self) {
2867                 if self.is_owned && !<*mut nativeSpliceAck>::is_null(self.inner) {
2868                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2869                 }
2870         }
2871 }
2872 /// Frees any resources used by the SpliceAck, if is_owned is set and inner is non-NULL.
2873 #[no_mangle]
2874 pub extern "C" fn SpliceAck_free(this_obj: SpliceAck) { }
2875 #[allow(unused)]
2876 /// Used only if an object of this type is returned as a trait impl by a method
2877 pub(crate) extern "C" fn SpliceAck_free_void(this_ptr: *mut c_void) {
2878         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceAck) };
2879 }
2880 #[allow(unused)]
2881 impl SpliceAck {
2882         pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceAck {
2883                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2884         }
2885         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceAck {
2886                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2887         }
2888         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2889         pub(crate) fn take_inner(mut self) -> *mut nativeSpliceAck {
2890                 assert!(self.is_owned);
2891                 let ret = ObjOps::untweak_ptr(self.inner);
2892                 self.inner = core::ptr::null_mut();
2893                 ret
2894         }
2895 }
2896 /// The channel ID where splicing is intended
2897 #[no_mangle]
2898 pub extern "C" fn SpliceAck_get_channel_id(this_ptr: &SpliceAck) -> crate::lightning::ln::types::ChannelId {
2899         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2900         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2901 }
2902 /// The channel ID where splicing is intended
2903 #[no_mangle]
2904 pub extern "C" fn SpliceAck_set_channel_id(this_ptr: &mut SpliceAck, mut val: crate::lightning::ln::types::ChannelId) {
2905         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2906 }
2907 /// The genesis hash of the blockchain where the channel is intended to be spliced
2908 #[no_mangle]
2909 pub extern "C" fn SpliceAck_get_chain_hash(this_ptr: &SpliceAck) -> *const [u8; 32] {
2910         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
2911         inner_val.as_ref()
2912 }
2913 /// The genesis hash of the blockchain where the channel is intended to be spliced
2914 #[no_mangle]
2915 pub extern "C" fn SpliceAck_set_chain_hash(this_ptr: &mut SpliceAck, mut val: crate::c_types::ThirtyTwoBytes) {
2916         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
2917 }
2918 /// The intended change in channel capacity: the amount to be added (positive value)
2919 /// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
2920 #[no_mangle]
2921 pub extern "C" fn SpliceAck_get_relative_satoshis(this_ptr: &SpliceAck) -> i64 {
2922         let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis;
2923         *inner_val
2924 }
2925 /// The intended change in channel capacity: the amount to be added (positive value)
2926 /// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
2927 #[no_mangle]
2928 pub extern "C" fn SpliceAck_set_relative_satoshis(this_ptr: &mut SpliceAck, mut val: i64) {
2929         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val;
2930 }
2931 /// The key of the sender (splice acceptor) controlling the new funding transaction
2932 #[no_mangle]
2933 pub extern "C" fn SpliceAck_get_funding_pubkey(this_ptr: &SpliceAck) -> crate::c_types::PublicKey {
2934         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
2935         crate::c_types::PublicKey::from_rust(&inner_val)
2936 }
2937 /// The key of the sender (splice acceptor) controlling the new funding transaction
2938 #[no_mangle]
2939 pub extern "C" fn SpliceAck_set_funding_pubkey(this_ptr: &mut SpliceAck, mut val: crate::c_types::PublicKey) {
2940         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
2941 }
2942 /// Constructs a new SpliceAck given each field
2943 #[must_use]
2944 #[no_mangle]
2945 pub extern "C" fn SpliceAck_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_pubkey_arg: crate::c_types::PublicKey) -> SpliceAck {
2946         SpliceAck { inner: ObjOps::heap_alloc(nativeSpliceAck {
2947                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2948                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
2949                 relative_satoshis: relative_satoshis_arg,
2950                 funding_pubkey: funding_pubkey_arg.into_rust(),
2951         }), is_owned: true }
2952 }
2953 impl Clone for SpliceAck {
2954         fn clone(&self) -> Self {
2955                 Self {
2956                         inner: if <*mut nativeSpliceAck>::is_null(self.inner) { core::ptr::null_mut() } else {
2957                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2958                         is_owned: true,
2959                 }
2960         }
2961 }
2962 #[allow(unused)]
2963 /// Used only if an object of this type is returned as a trait impl by a method
2964 pub(crate) extern "C" fn SpliceAck_clone_void(this_ptr: *const c_void) -> *mut c_void {
2965         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceAck)).clone() })) as *mut c_void
2966 }
2967 #[no_mangle]
2968 /// Creates a copy of the SpliceAck
2969 pub extern "C" fn SpliceAck_clone(orig: &SpliceAck) -> SpliceAck {
2970         orig.clone()
2971 }
2972 /// Get a string which allows debug introspection of a SpliceAck object
2973 pub extern "C" fn SpliceAck_debug_str_void(o: *const c_void) -> Str {
2974         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceAck }).into()}
2975 /// Checks if two SpliceAcks contain equal inner contents.
2976 /// This ignores pointers and is_owned flags and looks at the values in fields.
2977 /// Two objects with NULL inner values will be considered "equal" here.
2978 #[no_mangle]
2979 pub extern "C" fn SpliceAck_eq(a: &SpliceAck, b: &SpliceAck) -> bool {
2980         if a.inner == b.inner { return true; }
2981         if a.inner.is_null() || b.inner.is_null() { return false; }
2982         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2983 }
2984
2985 use lightning::ln::msgs::SpliceLocked as nativeSpliceLockedImport;
2986 pub(crate) type nativeSpliceLocked = nativeSpliceLockedImport;
2987
2988 /// A splice_locked message to be sent to or received from a peer.
2989 ///
2990 #[must_use]
2991 #[repr(C)]
2992 pub struct SpliceLocked {
2993         /// A pointer to the opaque Rust object.
2994
2995         /// Nearly everywhere, inner must be non-null, however in places where
2996         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2997         pub inner: *mut nativeSpliceLocked,
2998         /// Indicates that this is the only struct which contains the same pointer.
2999
3000         /// Rust functions which take ownership of an object provided via an argument require
3001         /// this to be true and invalidate the object pointed to by inner.
3002         pub is_owned: bool,
3003 }
3004
3005 impl Drop for SpliceLocked {
3006         fn drop(&mut self) {
3007                 if self.is_owned && !<*mut nativeSpliceLocked>::is_null(self.inner) {
3008                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3009                 }
3010         }
3011 }
3012 /// Frees any resources used by the SpliceLocked, if is_owned is set and inner is non-NULL.
3013 #[no_mangle]
3014 pub extern "C" fn SpliceLocked_free(this_obj: SpliceLocked) { }
3015 #[allow(unused)]
3016 /// Used only if an object of this type is returned as a trait impl by a method
3017 pub(crate) extern "C" fn SpliceLocked_free_void(this_ptr: *mut c_void) {
3018         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceLocked) };
3019 }
3020 #[allow(unused)]
3021 impl SpliceLocked {
3022         pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceLocked {
3023                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3024         }
3025         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceLocked {
3026                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3027         }
3028         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3029         pub(crate) fn take_inner(mut self) -> *mut nativeSpliceLocked {
3030                 assert!(self.is_owned);
3031                 let ret = ObjOps::untweak_ptr(self.inner);
3032                 self.inner = core::ptr::null_mut();
3033                 ret
3034         }
3035 }
3036 /// The channel ID
3037 #[no_mangle]
3038 pub extern "C" fn SpliceLocked_get_channel_id(this_ptr: &SpliceLocked) -> crate::lightning::ln::types::ChannelId {
3039         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3040         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3041 }
3042 /// The channel ID
3043 #[no_mangle]
3044 pub extern "C" fn SpliceLocked_set_channel_id(this_ptr: &mut SpliceLocked, mut val: crate::lightning::ln::types::ChannelId) {
3045         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3046 }
3047 /// Constructs a new SpliceLocked given each field
3048 #[must_use]
3049 #[no_mangle]
3050 pub extern "C" fn SpliceLocked_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId) -> SpliceLocked {
3051         SpliceLocked { inner: ObjOps::heap_alloc(nativeSpliceLocked {
3052                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3053         }), is_owned: true }
3054 }
3055 impl Clone for SpliceLocked {
3056         fn clone(&self) -> Self {
3057                 Self {
3058                         inner: if <*mut nativeSpliceLocked>::is_null(self.inner) { core::ptr::null_mut() } else {
3059                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3060                         is_owned: true,
3061                 }
3062         }
3063 }
3064 #[allow(unused)]
3065 /// Used only if an object of this type is returned as a trait impl by a method
3066 pub(crate) extern "C" fn SpliceLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
3067         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceLocked)).clone() })) as *mut c_void
3068 }
3069 #[no_mangle]
3070 /// Creates a copy of the SpliceLocked
3071 pub extern "C" fn SpliceLocked_clone(orig: &SpliceLocked) -> SpliceLocked {
3072         orig.clone()
3073 }
3074 /// Get a string which allows debug introspection of a SpliceLocked object
3075 pub extern "C" fn SpliceLocked_debug_str_void(o: *const c_void) -> Str {
3076         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceLocked }).into()}
3077 /// Checks if two SpliceLockeds contain equal inner contents.
3078 /// This ignores pointers and is_owned flags and looks at the values in fields.
3079 /// Two objects with NULL inner values will be considered "equal" here.
3080 #[no_mangle]
3081 pub extern "C" fn SpliceLocked_eq(a: &SpliceLocked, b: &SpliceLocked) -> bool {
3082         if a.inner == b.inner { return true; }
3083         if a.inner.is_null() || b.inner.is_null() { return false; }
3084         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3085 }
3086
3087 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
3088 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
3089
3090 /// A tx_add_input message for adding an input during interactive transaction construction
3091 ///
3092 #[must_use]
3093 #[repr(C)]
3094 pub struct TxAddInput {
3095         /// A pointer to the opaque Rust object.
3096
3097         /// Nearly everywhere, inner must be non-null, however in places where
3098         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3099         pub inner: *mut nativeTxAddInput,
3100         /// Indicates that this is the only struct which contains the same pointer.
3101
3102         /// Rust functions which take ownership of an object provided via an argument require
3103         /// this to be true and invalidate the object pointed to by inner.
3104         pub is_owned: bool,
3105 }
3106
3107 impl Drop for TxAddInput {
3108         fn drop(&mut self) {
3109                 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
3110                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3111                 }
3112         }
3113 }
3114 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
3115 #[no_mangle]
3116 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
3117 #[allow(unused)]
3118 /// Used only if an object of this type is returned as a trait impl by a method
3119 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
3120         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
3121 }
3122 #[allow(unused)]
3123 impl TxAddInput {
3124         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
3125                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3126         }
3127         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
3128                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3129         }
3130         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3131         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
3132                 assert!(self.is_owned);
3133                 let ret = ObjOps::untweak_ptr(self.inner);
3134                 self.inner = core::ptr::null_mut();
3135                 ret
3136         }
3137 }
3138 /// The channel ID
3139 #[no_mangle]
3140 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> crate::lightning::ln::types::ChannelId {
3141         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3142         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3143 }
3144 /// The channel ID
3145 #[no_mangle]
3146 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::lightning::ln::types::ChannelId) {
3147         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3148 }
3149 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
3150 /// non-initiators.
3151 #[no_mangle]
3152 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
3153         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3154         *inner_val
3155 }
3156 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
3157 /// non-initiators.
3158 #[no_mangle]
3159 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
3160         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3161 }
3162 /// Serialized transaction that contains the output this input spends to verify that it is non
3163 /// malleable.
3164 #[no_mangle]
3165 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
3166         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
3167         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 }
3168 }
3169 /// Serialized transaction that contains the output this input spends to verify that it is non
3170 /// malleable.
3171 #[no_mangle]
3172 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
3173         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
3174 }
3175 /// The index of the output being spent
3176 #[no_mangle]
3177 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
3178         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
3179         *inner_val
3180 }
3181 /// The index of the output being spent
3182 #[no_mangle]
3183 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
3184         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
3185 }
3186 /// The sequence number of this input
3187 #[no_mangle]
3188 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
3189         let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
3190         *inner_val
3191 }
3192 /// The sequence number of this input
3193 #[no_mangle]
3194 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
3195         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
3196 }
3197 /// Constructs a new TxAddInput given each field
3198 #[must_use]
3199 #[no_mangle]
3200 pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput {
3201         TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
3202                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3203                 serial_id: serial_id_arg,
3204                 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
3205                 prevtx_out: prevtx_out_arg,
3206                 sequence: sequence_arg,
3207         }), is_owned: true }
3208 }
3209 impl Clone for TxAddInput {
3210         fn clone(&self) -> Self {
3211                 Self {
3212                         inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
3213                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3214                         is_owned: true,
3215                 }
3216         }
3217 }
3218 #[allow(unused)]
3219 /// Used only if an object of this type is returned as a trait impl by a method
3220 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3221         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddInput)).clone() })) as *mut c_void
3222 }
3223 #[no_mangle]
3224 /// Creates a copy of the TxAddInput
3225 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
3226         orig.clone()
3227 }
3228 /// Get a string which allows debug introspection of a TxAddInput object
3229 pub extern "C" fn TxAddInput_debug_str_void(o: *const c_void) -> Str {
3230         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAddInput }).into()}
3231 /// Generates a non-cryptographic 64-bit hash of the TxAddInput.
3232 #[no_mangle]
3233 pub extern "C" fn TxAddInput_hash(o: &TxAddInput) -> u64 {
3234         if o.inner.is_null() { return 0; }
3235         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3236         #[allow(deprecated)]
3237         let mut hasher = core::hash::SipHasher::new();
3238         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3239         core::hash::Hasher::finish(&hasher)
3240 }
3241 /// Checks if two TxAddInputs contain equal inner contents.
3242 /// This ignores pointers and is_owned flags and looks at the values in fields.
3243 /// Two objects with NULL inner values will be considered "equal" here.
3244 #[no_mangle]
3245 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
3246         if a.inner == b.inner { return true; }
3247         if a.inner.is_null() || b.inner.is_null() { return false; }
3248         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3249 }
3250
3251 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
3252 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
3253
3254 /// A tx_add_output message for adding an output during interactive transaction construction.
3255 ///
3256 #[must_use]
3257 #[repr(C)]
3258 pub struct TxAddOutput {
3259         /// A pointer to the opaque Rust object.
3260
3261         /// Nearly everywhere, inner must be non-null, however in places where
3262         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3263         pub inner: *mut nativeTxAddOutput,
3264         /// Indicates that this is the only struct which contains the same pointer.
3265
3266         /// Rust functions which take ownership of an object provided via an argument require
3267         /// this to be true and invalidate the object pointed to by inner.
3268         pub is_owned: bool,
3269 }
3270
3271 impl Drop for TxAddOutput {
3272         fn drop(&mut self) {
3273                 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
3274                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3275                 }
3276         }
3277 }
3278 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
3279 #[no_mangle]
3280 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
3281 #[allow(unused)]
3282 /// Used only if an object of this type is returned as a trait impl by a method
3283 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
3284         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
3285 }
3286 #[allow(unused)]
3287 impl TxAddOutput {
3288         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
3289                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3290         }
3291         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
3292                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3293         }
3294         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3295         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
3296                 assert!(self.is_owned);
3297                 let ret = ObjOps::untweak_ptr(self.inner);
3298                 self.inner = core::ptr::null_mut();
3299                 ret
3300         }
3301 }
3302 /// The channel ID
3303 #[no_mangle]
3304 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> crate::lightning::ln::types::ChannelId {
3305         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3306         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3307 }
3308 /// The channel ID
3309 #[no_mangle]
3310 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::lightning::ln::types::ChannelId) {
3311         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3312 }
3313 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
3314 /// non-initiators.
3315 #[no_mangle]
3316 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
3317         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3318         *inner_val
3319 }
3320 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
3321 /// non-initiators.
3322 #[no_mangle]
3323 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
3324         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3325 }
3326 /// The satoshi value of the output
3327 #[no_mangle]
3328 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
3329         let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
3330         *inner_val
3331 }
3332 /// The satoshi value of the output
3333 #[no_mangle]
3334 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
3335         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
3336 }
3337 /// The scriptPubKey for the output
3338 #[no_mangle]
3339 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
3340         let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
3341         inner_val.as_bytes().to_vec().into()
3342 }
3343 /// The scriptPubKey for the output
3344 #[no_mangle]
3345 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
3346         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust());
3347 }
3348 /// Constructs a new TxAddOutput given each field
3349 #[must_use]
3350 #[no_mangle]
3351 pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput {
3352         TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
3353                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3354                 serial_id: serial_id_arg,
3355                 sats: sats_arg,
3356                 script: ::bitcoin::blockdata::script::ScriptBuf::from(script_arg.into_rust()),
3357         }), is_owned: true }
3358 }
3359 impl Clone for TxAddOutput {
3360         fn clone(&self) -> Self {
3361                 Self {
3362                         inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3363                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3364                         is_owned: true,
3365                 }
3366         }
3367 }
3368 #[allow(unused)]
3369 /// Used only if an object of this type is returned as a trait impl by a method
3370 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3371         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddOutput)).clone() })) as *mut c_void
3372 }
3373 #[no_mangle]
3374 /// Creates a copy of the TxAddOutput
3375 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
3376         orig.clone()
3377 }
3378 /// Get a string which allows debug introspection of a TxAddOutput object
3379 pub extern "C" fn TxAddOutput_debug_str_void(o: *const c_void) -> Str {
3380         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAddOutput }).into()}
3381 /// Generates a non-cryptographic 64-bit hash of the TxAddOutput.
3382 #[no_mangle]
3383 pub extern "C" fn TxAddOutput_hash(o: &TxAddOutput) -> u64 {
3384         if o.inner.is_null() { return 0; }
3385         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3386         #[allow(deprecated)]
3387         let mut hasher = core::hash::SipHasher::new();
3388         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3389         core::hash::Hasher::finish(&hasher)
3390 }
3391 /// Checks if two TxAddOutputs contain equal inner contents.
3392 /// This ignores pointers and is_owned flags and looks at the values in fields.
3393 /// Two objects with NULL inner values will be considered "equal" here.
3394 #[no_mangle]
3395 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
3396         if a.inner == b.inner { return true; }
3397         if a.inner.is_null() || b.inner.is_null() { return false; }
3398         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3399 }
3400
3401 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
3402 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
3403
3404 /// A tx_remove_input message for removing an input during interactive transaction construction.
3405 ///
3406 #[must_use]
3407 #[repr(C)]
3408 pub struct TxRemoveInput {
3409         /// A pointer to the opaque Rust object.
3410
3411         /// Nearly everywhere, inner must be non-null, however in places where
3412         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3413         pub inner: *mut nativeTxRemoveInput,
3414         /// Indicates that this is the only struct which contains the same pointer.
3415
3416         /// Rust functions which take ownership of an object provided via an argument require
3417         /// this to be true and invalidate the object pointed to by inner.
3418         pub is_owned: bool,
3419 }
3420
3421 impl Drop for TxRemoveInput {
3422         fn drop(&mut self) {
3423                 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
3424                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3425                 }
3426         }
3427 }
3428 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
3429 #[no_mangle]
3430 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
3431 #[allow(unused)]
3432 /// Used only if an object of this type is returned as a trait impl by a method
3433 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
3434         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
3435 }
3436 #[allow(unused)]
3437 impl TxRemoveInput {
3438         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
3439                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3440         }
3441         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
3442                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3443         }
3444         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3445         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
3446                 assert!(self.is_owned);
3447                 let ret = ObjOps::untweak_ptr(self.inner);
3448                 self.inner = core::ptr::null_mut();
3449                 ret
3450         }
3451 }
3452 /// The channel ID
3453 #[no_mangle]
3454 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> crate::lightning::ln::types::ChannelId {
3455         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3456         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3457 }
3458 /// The channel ID
3459 #[no_mangle]
3460 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::lightning::ln::types::ChannelId) {
3461         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3462 }
3463 /// The serial ID of the input to be removed
3464 #[no_mangle]
3465 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
3466         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3467         *inner_val
3468 }
3469 /// The serial ID of the input to be removed
3470 #[no_mangle]
3471 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
3472         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3473 }
3474 /// Constructs a new TxRemoveInput given each field
3475 #[must_use]
3476 #[no_mangle]
3477 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64) -> TxRemoveInput {
3478         TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
3479                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3480                 serial_id: serial_id_arg,
3481         }), is_owned: true }
3482 }
3483 impl Clone for TxRemoveInput {
3484         fn clone(&self) -> Self {
3485                 Self {
3486                         inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
3487                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3488                         is_owned: true,
3489                 }
3490         }
3491 }
3492 #[allow(unused)]
3493 /// Used only if an object of this type is returned as a trait impl by a method
3494 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3495         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveInput)).clone() })) as *mut c_void
3496 }
3497 #[no_mangle]
3498 /// Creates a copy of the TxRemoveInput
3499 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
3500         orig.clone()
3501 }
3502 /// Get a string which allows debug introspection of a TxRemoveInput object
3503 pub extern "C" fn TxRemoveInput_debug_str_void(o: *const c_void) -> Str {
3504         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxRemoveInput }).into()}
3505 /// Generates a non-cryptographic 64-bit hash of the TxRemoveInput.
3506 #[no_mangle]
3507 pub extern "C" fn TxRemoveInput_hash(o: &TxRemoveInput) -> u64 {
3508         if o.inner.is_null() { return 0; }
3509         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3510         #[allow(deprecated)]
3511         let mut hasher = core::hash::SipHasher::new();
3512         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3513         core::hash::Hasher::finish(&hasher)
3514 }
3515 /// Checks if two TxRemoveInputs contain equal inner contents.
3516 /// This ignores pointers and is_owned flags and looks at the values in fields.
3517 /// Two objects with NULL inner values will be considered "equal" here.
3518 #[no_mangle]
3519 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
3520         if a.inner == b.inner { return true; }
3521         if a.inner.is_null() || b.inner.is_null() { return false; }
3522         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3523 }
3524
3525 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
3526 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
3527
3528 /// A tx_remove_output message for removing an output during interactive transaction construction.
3529 ///
3530 #[must_use]
3531 #[repr(C)]
3532 pub struct TxRemoveOutput {
3533         /// A pointer to the opaque Rust object.
3534
3535         /// Nearly everywhere, inner must be non-null, however in places where
3536         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3537         pub inner: *mut nativeTxRemoveOutput,
3538         /// Indicates that this is the only struct which contains the same pointer.
3539
3540         /// Rust functions which take ownership of an object provided via an argument require
3541         /// this to be true and invalidate the object pointed to by inner.
3542         pub is_owned: bool,
3543 }
3544
3545 impl Drop for TxRemoveOutput {
3546         fn drop(&mut self) {
3547                 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
3548                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3549                 }
3550         }
3551 }
3552 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
3553 #[no_mangle]
3554 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
3555 #[allow(unused)]
3556 /// Used only if an object of this type is returned as a trait impl by a method
3557 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
3558         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
3559 }
3560 #[allow(unused)]
3561 impl TxRemoveOutput {
3562         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
3563                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3564         }
3565         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
3566                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3567         }
3568         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3569         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
3570                 assert!(self.is_owned);
3571                 let ret = ObjOps::untweak_ptr(self.inner);
3572                 self.inner = core::ptr::null_mut();
3573                 ret
3574         }
3575 }
3576 /// The channel ID
3577 #[no_mangle]
3578 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> crate::lightning::ln::types::ChannelId {
3579         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3580         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3581 }
3582 /// The channel ID
3583 #[no_mangle]
3584 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::lightning::ln::types::ChannelId) {
3585         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3586 }
3587 /// The serial ID of the output to be removed
3588 #[no_mangle]
3589 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3590         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3591         *inner_val
3592 }
3593 /// The serial ID of the output to be removed
3594 #[no_mangle]
3595 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3596         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3597 }
3598 /// Constructs a new TxRemoveOutput given each field
3599 #[must_use]
3600 #[no_mangle]
3601 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64) -> TxRemoveOutput {
3602         TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3603                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3604                 serial_id: serial_id_arg,
3605         }), is_owned: true }
3606 }
3607 impl Clone for TxRemoveOutput {
3608         fn clone(&self) -> Self {
3609                 Self {
3610                         inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3611                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3612                         is_owned: true,
3613                 }
3614         }
3615 }
3616 #[allow(unused)]
3617 /// Used only if an object of this type is returned as a trait impl by a method
3618 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3619         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveOutput)).clone() })) as *mut c_void
3620 }
3621 #[no_mangle]
3622 /// Creates a copy of the TxRemoveOutput
3623 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3624         orig.clone()
3625 }
3626 /// Get a string which allows debug introspection of a TxRemoveOutput object
3627 pub extern "C" fn TxRemoveOutput_debug_str_void(o: *const c_void) -> Str {
3628         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxRemoveOutput }).into()}
3629 /// Generates a non-cryptographic 64-bit hash of the TxRemoveOutput.
3630 #[no_mangle]
3631 pub extern "C" fn TxRemoveOutput_hash(o: &TxRemoveOutput) -> u64 {
3632         if o.inner.is_null() { return 0; }
3633         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3634         #[allow(deprecated)]
3635         let mut hasher = core::hash::SipHasher::new();
3636         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3637         core::hash::Hasher::finish(&hasher)
3638 }
3639 /// Checks if two TxRemoveOutputs contain equal inner contents.
3640 /// This ignores pointers and is_owned flags and looks at the values in fields.
3641 /// Two objects with NULL inner values will be considered "equal" here.
3642 #[no_mangle]
3643 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3644         if a.inner == b.inner { return true; }
3645         if a.inner.is_null() || b.inner.is_null() { return false; }
3646         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3647 }
3648
3649 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3650 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3651
3652 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3653 /// interactive transaction construction.
3654 ///
3655 #[must_use]
3656 #[repr(C)]
3657 pub struct TxComplete {
3658         /// A pointer to the opaque Rust object.
3659
3660         /// Nearly everywhere, inner must be non-null, however in places where
3661         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3662         pub inner: *mut nativeTxComplete,
3663         /// Indicates that this is the only struct which contains the same pointer.
3664
3665         /// Rust functions which take ownership of an object provided via an argument require
3666         /// this to be true and invalidate the object pointed to by inner.
3667         pub is_owned: bool,
3668 }
3669
3670 impl Drop for TxComplete {
3671         fn drop(&mut self) {
3672                 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3673                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3674                 }
3675         }
3676 }
3677 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3678 #[no_mangle]
3679 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3680 #[allow(unused)]
3681 /// Used only if an object of this type is returned as a trait impl by a method
3682 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3683         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3684 }
3685 #[allow(unused)]
3686 impl TxComplete {
3687         pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3688                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3689         }
3690         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3691                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3692         }
3693         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3694         pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3695                 assert!(self.is_owned);
3696                 let ret = ObjOps::untweak_ptr(self.inner);
3697                 self.inner = core::ptr::null_mut();
3698                 ret
3699         }
3700 }
3701 /// The channel ID
3702 #[no_mangle]
3703 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> crate::lightning::ln::types::ChannelId {
3704         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3705         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3706 }
3707 /// The channel ID
3708 #[no_mangle]
3709 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::lightning::ln::types::ChannelId) {
3710         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3711 }
3712 /// Constructs a new TxComplete given each field
3713 #[must_use]
3714 #[no_mangle]
3715 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId) -> TxComplete {
3716         TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3717                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3718         }), is_owned: true }
3719 }
3720 impl Clone for TxComplete {
3721         fn clone(&self) -> Self {
3722                 Self {
3723                         inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3724                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3725                         is_owned: true,
3726                 }
3727         }
3728 }
3729 #[allow(unused)]
3730 /// Used only if an object of this type is returned as a trait impl by a method
3731 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3732         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxComplete)).clone() })) as *mut c_void
3733 }
3734 #[no_mangle]
3735 /// Creates a copy of the TxComplete
3736 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3737         orig.clone()
3738 }
3739 /// Get a string which allows debug introspection of a TxComplete object
3740 pub extern "C" fn TxComplete_debug_str_void(o: *const c_void) -> Str {
3741         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxComplete }).into()}
3742 /// Generates a non-cryptographic 64-bit hash of the TxComplete.
3743 #[no_mangle]
3744 pub extern "C" fn TxComplete_hash(o: &TxComplete) -> u64 {
3745         if o.inner.is_null() { return 0; }
3746         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3747         #[allow(deprecated)]
3748         let mut hasher = core::hash::SipHasher::new();
3749         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3750         core::hash::Hasher::finish(&hasher)
3751 }
3752 /// Checks if two TxCompletes contain equal inner contents.
3753 /// This ignores pointers and is_owned flags and looks at the values in fields.
3754 /// Two objects with NULL inner values will be considered "equal" here.
3755 #[no_mangle]
3756 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3757         if a.inner == b.inner { return true; }
3758         if a.inner.is_null() || b.inner.is_null() { return false; }
3759         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3760 }
3761
3762 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3763 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3764
3765 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3766 /// interactive transaction construction.
3767 ///
3768 #[must_use]
3769 #[repr(C)]
3770 pub struct TxSignatures {
3771         /// A pointer to the opaque Rust object.
3772
3773         /// Nearly everywhere, inner must be non-null, however in places where
3774         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3775         pub inner: *mut nativeTxSignatures,
3776         /// Indicates that this is the only struct which contains the same pointer.
3777
3778         /// Rust functions which take ownership of an object provided via an argument require
3779         /// this to be true and invalidate the object pointed to by inner.
3780         pub is_owned: bool,
3781 }
3782
3783 impl Drop for TxSignatures {
3784         fn drop(&mut self) {
3785                 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3786                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3787                 }
3788         }
3789 }
3790 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3791 #[no_mangle]
3792 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3793 #[allow(unused)]
3794 /// Used only if an object of this type is returned as a trait impl by a method
3795 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3796         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3797 }
3798 #[allow(unused)]
3799 impl TxSignatures {
3800         pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3801                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3802         }
3803         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3804                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3805         }
3806         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3807         pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3808                 assert!(self.is_owned);
3809                 let ret = ObjOps::untweak_ptr(self.inner);
3810                 self.inner = core::ptr::null_mut();
3811                 ret
3812         }
3813 }
3814 /// The channel ID
3815 #[no_mangle]
3816 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> crate::lightning::ln::types::ChannelId {
3817         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3818         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3819 }
3820 /// The channel ID
3821 #[no_mangle]
3822 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::lightning::ln::types::ChannelId) {
3823         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3824 }
3825 /// The TXID
3826 #[no_mangle]
3827 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3828         let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3829         inner_val.as_ref()
3830 }
3831 /// The TXID
3832 #[no_mangle]
3833 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3834         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3835 }
3836 /// The list of witnesses
3837 ///
3838 /// Returns a copy of the field.
3839 #[no_mangle]
3840 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3841         let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
3842         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) }); };
3843         local_inner_val.into()
3844 }
3845 /// The list of witnesses
3846 #[no_mangle]
3847 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
3848         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
3849         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
3850 }
3851 /// Optional signature for the shared input -- the previous funding outpoint -- signed by both peers
3852 #[no_mangle]
3853 pub extern "C" fn TxSignatures_get_funding_outpoint_sig(this_ptr: &TxSignatures) -> crate::c_types::derived::COption_ECDSASignatureZ {
3854         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_outpoint_sig;
3855         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ECDSASignatureZ::None } else { crate::c_types::derived::COption_ECDSASignatureZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ECDSASignature::from_rust(&(*inner_val.as_ref().unwrap()).clone()) }) };
3856         local_inner_val
3857 }
3858 /// Optional signature for the shared input -- the previous funding outpoint -- signed by both peers
3859 #[no_mangle]
3860 pub extern "C" fn TxSignatures_set_funding_outpoint_sig(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::COption_ECDSASignatureZ) {
3861         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_rust() }})} };
3862         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_outpoint_sig = local_val;
3863 }
3864 /// Constructs a new TxSignatures given each field
3865 #[must_use]
3866 #[no_mangle]
3867 pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ, mut funding_outpoint_sig_arg: crate::c_types::derived::COption_ECDSASignatureZ) -> TxSignatures {
3868         let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
3869         let mut local_funding_outpoint_sig_arg = { /*funding_outpoint_sig_arg*/ let funding_outpoint_sig_arg_opt = funding_outpoint_sig_arg; if funding_outpoint_sig_arg_opt.is_none() { None } else { Some({ { { funding_outpoint_sig_arg_opt.take() }.into_rust() }})} };
3870         TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
3871                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3872                 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
3873                 witnesses: local_witnesses_arg,
3874                 funding_outpoint_sig: local_funding_outpoint_sig_arg,
3875         }), is_owned: true }
3876 }
3877 impl Clone for TxSignatures {
3878         fn clone(&self) -> Self {
3879                 Self {
3880                         inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3881                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3882                         is_owned: true,
3883                 }
3884         }
3885 }
3886 #[allow(unused)]
3887 /// Used only if an object of this type is returned as a trait impl by a method
3888 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3889         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxSignatures)).clone() })) as *mut c_void
3890 }
3891 #[no_mangle]
3892 /// Creates a copy of the TxSignatures
3893 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
3894         orig.clone()
3895 }
3896 /// Get a string which allows debug introspection of a TxSignatures object
3897 pub extern "C" fn TxSignatures_debug_str_void(o: *const c_void) -> Str {
3898         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxSignatures }).into()}
3899 /// Generates a non-cryptographic 64-bit hash of the TxSignatures.
3900 #[no_mangle]
3901 pub extern "C" fn TxSignatures_hash(o: &TxSignatures) -> u64 {
3902         if o.inner.is_null() { return 0; }
3903         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3904         #[allow(deprecated)]
3905         let mut hasher = core::hash::SipHasher::new();
3906         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3907         core::hash::Hasher::finish(&hasher)
3908 }
3909 /// Checks if two TxSignaturess contain equal inner contents.
3910 /// This ignores pointers and is_owned flags and looks at the values in fields.
3911 /// Two objects with NULL inner values will be considered "equal" here.
3912 #[no_mangle]
3913 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
3914         if a.inner == b.inner { return true; }
3915         if a.inner.is_null() || b.inner.is_null() { return false; }
3916         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3917 }
3918
3919 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
3920 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
3921
3922 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
3923 /// completed.
3924 ///
3925 #[must_use]
3926 #[repr(C)]
3927 pub struct TxInitRbf {
3928         /// A pointer to the opaque Rust object.
3929
3930         /// Nearly everywhere, inner must be non-null, however in places where
3931         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3932         pub inner: *mut nativeTxInitRbf,
3933         /// Indicates that this is the only struct which contains the same pointer.
3934
3935         /// Rust functions which take ownership of an object provided via an argument require
3936         /// this to be true and invalidate the object pointed to by inner.
3937         pub is_owned: bool,
3938 }
3939
3940 impl Drop for TxInitRbf {
3941         fn drop(&mut self) {
3942                 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
3943                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3944                 }
3945         }
3946 }
3947 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
3948 #[no_mangle]
3949 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
3950 #[allow(unused)]
3951 /// Used only if an object of this type is returned as a trait impl by a method
3952 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
3953         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
3954 }
3955 #[allow(unused)]
3956 impl TxInitRbf {
3957         pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
3958                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3959         }
3960         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
3961                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3962         }
3963         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3964         pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
3965                 assert!(self.is_owned);
3966                 let ret = ObjOps::untweak_ptr(self.inner);
3967                 self.inner = core::ptr::null_mut();
3968                 ret
3969         }
3970 }
3971 /// The channel ID
3972 #[no_mangle]
3973 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> crate::lightning::ln::types::ChannelId {
3974         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3975         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3976 }
3977 /// The channel ID
3978 #[no_mangle]
3979 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::lightning::ln::types::ChannelId) {
3980         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3981 }
3982 /// The locktime of the transaction
3983 #[no_mangle]
3984 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
3985         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
3986         *inner_val
3987 }
3988 /// The locktime of the transaction
3989 #[no_mangle]
3990 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
3991         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
3992 }
3993 /// The feerate of the transaction
3994 #[no_mangle]
3995 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
3996         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
3997         *inner_val
3998 }
3999 /// The feerate of the transaction
4000 #[no_mangle]
4001 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
4002         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
4003 }
4004 /// The number of satoshis the sender will contribute to or, if negative, remove from
4005 /// (e.g. splice-out) the funding output of the transaction
4006 #[no_mangle]
4007 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
4008         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
4009         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() }) };
4010         local_inner_val
4011 }
4012 /// The number of satoshis the sender will contribute to or, if negative, remove from
4013 /// (e.g. splice-out) the funding output of the transaction
4014 #[no_mangle]
4015 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
4016         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4017         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
4018 }
4019 /// Constructs a new TxInitRbf given each field
4020 #[must_use]
4021 #[no_mangle]
4022 pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf {
4023         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
4024         TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
4025                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4026                 locktime: locktime_arg,
4027                 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
4028                 funding_output_contribution: local_funding_output_contribution_arg,
4029         }), is_owned: true }
4030 }
4031 impl Clone for TxInitRbf {
4032         fn clone(&self) -> Self {
4033                 Self {
4034                         inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
4035                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4036                         is_owned: true,
4037                 }
4038         }
4039 }
4040 #[allow(unused)]
4041 /// Used only if an object of this type is returned as a trait impl by a method
4042 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
4043         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxInitRbf)).clone() })) as *mut c_void
4044 }
4045 #[no_mangle]
4046 /// Creates a copy of the TxInitRbf
4047 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
4048         orig.clone()
4049 }
4050 /// Get a string which allows debug introspection of a TxInitRbf object
4051 pub extern "C" fn TxInitRbf_debug_str_void(o: *const c_void) -> Str {
4052         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxInitRbf }).into()}
4053 /// Generates a non-cryptographic 64-bit hash of the TxInitRbf.
4054 #[no_mangle]
4055 pub extern "C" fn TxInitRbf_hash(o: &TxInitRbf) -> u64 {
4056         if o.inner.is_null() { return 0; }
4057         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4058         #[allow(deprecated)]
4059         let mut hasher = core::hash::SipHasher::new();
4060         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4061         core::hash::Hasher::finish(&hasher)
4062 }
4063 /// Checks if two TxInitRbfs contain equal inner contents.
4064 /// This ignores pointers and is_owned flags and looks at the values in fields.
4065 /// Two objects with NULL inner values will be considered "equal" here.
4066 #[no_mangle]
4067 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
4068         if a.inner == b.inner { return true; }
4069         if a.inner.is_null() || b.inner.is_null() { return false; }
4070         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4071 }
4072
4073 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
4074 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
4075
4076 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
4077 /// completed.
4078 ///
4079 #[must_use]
4080 #[repr(C)]
4081 pub struct TxAckRbf {
4082         /// A pointer to the opaque Rust object.
4083
4084         /// Nearly everywhere, inner must be non-null, however in places where
4085         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4086         pub inner: *mut nativeTxAckRbf,
4087         /// Indicates that this is the only struct which contains the same pointer.
4088
4089         /// Rust functions which take ownership of an object provided via an argument require
4090         /// this to be true and invalidate the object pointed to by inner.
4091         pub is_owned: bool,
4092 }
4093
4094 impl Drop for TxAckRbf {
4095         fn drop(&mut self) {
4096                 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
4097                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4098                 }
4099         }
4100 }
4101 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
4102 #[no_mangle]
4103 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
4104 #[allow(unused)]
4105 /// Used only if an object of this type is returned as a trait impl by a method
4106 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
4107         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
4108 }
4109 #[allow(unused)]
4110 impl TxAckRbf {
4111         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
4112                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4113         }
4114         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
4115                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4116         }
4117         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4118         pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
4119                 assert!(self.is_owned);
4120                 let ret = ObjOps::untweak_ptr(self.inner);
4121                 self.inner = core::ptr::null_mut();
4122                 ret
4123         }
4124 }
4125 /// The channel ID
4126 #[no_mangle]
4127 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> crate::lightning::ln::types::ChannelId {
4128         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4129         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4130 }
4131 /// The channel ID
4132 #[no_mangle]
4133 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::lightning::ln::types::ChannelId) {
4134         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4135 }
4136 /// The number of satoshis the sender will contribute to or, if negative, remove from
4137 /// (e.g. splice-out) the funding output of the transaction
4138 #[no_mangle]
4139 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
4140         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
4141         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() }) };
4142         local_inner_val
4143 }
4144 /// The number of satoshis the sender will contribute to or, if negative, remove from
4145 /// (e.g. splice-out) the funding output of the transaction
4146 #[no_mangle]
4147 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
4148         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4149         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
4150 }
4151 /// Constructs a new TxAckRbf given each field
4152 #[must_use]
4153 #[no_mangle]
4154 pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf {
4155         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
4156         TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
4157                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4158                 funding_output_contribution: local_funding_output_contribution_arg,
4159         }), is_owned: true }
4160 }
4161 impl Clone for TxAckRbf {
4162         fn clone(&self) -> Self {
4163                 Self {
4164                         inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
4165                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4166                         is_owned: true,
4167                 }
4168         }
4169 }
4170 #[allow(unused)]
4171 /// Used only if an object of this type is returned as a trait impl by a method
4172 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
4173         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAckRbf)).clone() })) as *mut c_void
4174 }
4175 #[no_mangle]
4176 /// Creates a copy of the TxAckRbf
4177 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
4178         orig.clone()
4179 }
4180 /// Get a string which allows debug introspection of a TxAckRbf object
4181 pub extern "C" fn TxAckRbf_debug_str_void(o: *const c_void) -> Str {
4182         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAckRbf }).into()}
4183 /// Generates a non-cryptographic 64-bit hash of the TxAckRbf.
4184 #[no_mangle]
4185 pub extern "C" fn TxAckRbf_hash(o: &TxAckRbf) -> u64 {
4186         if o.inner.is_null() { return 0; }
4187         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4188         #[allow(deprecated)]
4189         let mut hasher = core::hash::SipHasher::new();
4190         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4191         core::hash::Hasher::finish(&hasher)
4192 }
4193 /// Checks if two TxAckRbfs contain equal inner contents.
4194 /// This ignores pointers and is_owned flags and looks at the values in fields.
4195 /// Two objects with NULL inner values will be considered "equal" here.
4196 #[no_mangle]
4197 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
4198         if a.inner == b.inner { return true; }
4199         if a.inner.is_null() || b.inner.is_null() { return false; }
4200         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4201 }
4202
4203 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
4204 pub(crate) type nativeTxAbort = nativeTxAbortImport;
4205
4206 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
4207 ///
4208 #[must_use]
4209 #[repr(C)]
4210 pub struct TxAbort {
4211         /// A pointer to the opaque Rust object.
4212
4213         /// Nearly everywhere, inner must be non-null, however in places where
4214         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4215         pub inner: *mut nativeTxAbort,
4216         /// Indicates that this is the only struct which contains the same pointer.
4217
4218         /// Rust functions which take ownership of an object provided via an argument require
4219         /// this to be true and invalidate the object pointed to by inner.
4220         pub is_owned: bool,
4221 }
4222
4223 impl Drop for TxAbort {
4224         fn drop(&mut self) {
4225                 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
4226                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4227                 }
4228         }
4229 }
4230 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
4231 #[no_mangle]
4232 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
4233 #[allow(unused)]
4234 /// Used only if an object of this type is returned as a trait impl by a method
4235 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
4236         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
4237 }
4238 #[allow(unused)]
4239 impl TxAbort {
4240         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
4241                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4242         }
4243         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
4244                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4245         }
4246         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4247         pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
4248                 assert!(self.is_owned);
4249                 let ret = ObjOps::untweak_ptr(self.inner);
4250                 self.inner = core::ptr::null_mut();
4251                 ret
4252         }
4253 }
4254 /// The channel ID
4255 #[no_mangle]
4256 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> crate::lightning::ln::types::ChannelId {
4257         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4258         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4259 }
4260 /// The channel ID
4261 #[no_mangle]
4262 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::lightning::ln::types::ChannelId) {
4263         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4264 }
4265 /// Message data
4266 ///
4267 /// Returns a copy of the field.
4268 #[no_mangle]
4269 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
4270         let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
4271         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4272         local_inner_val.into()
4273 }
4274 /// Message data
4275 #[no_mangle]
4276 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
4277         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4278         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
4279 }
4280 /// Constructs a new TxAbort given each field
4281 #[must_use]
4282 #[no_mangle]
4283 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
4284         let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
4285         TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
4286                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4287                 data: local_data_arg,
4288         }), is_owned: true }
4289 }
4290 impl Clone for TxAbort {
4291         fn clone(&self) -> Self {
4292                 Self {
4293                         inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
4294                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4295                         is_owned: true,
4296                 }
4297         }
4298 }
4299 #[allow(unused)]
4300 /// Used only if an object of this type is returned as a trait impl by a method
4301 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
4302         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAbort)).clone() })) as *mut c_void
4303 }
4304 #[no_mangle]
4305 /// Creates a copy of the TxAbort
4306 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
4307         orig.clone()
4308 }
4309 /// Get a string which allows debug introspection of a TxAbort object
4310 pub extern "C" fn TxAbort_debug_str_void(o: *const c_void) -> Str {
4311         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAbort }).into()}
4312 /// Generates a non-cryptographic 64-bit hash of the TxAbort.
4313 #[no_mangle]
4314 pub extern "C" fn TxAbort_hash(o: &TxAbort) -> u64 {
4315         if o.inner.is_null() { return 0; }
4316         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4317         #[allow(deprecated)]
4318         let mut hasher = core::hash::SipHasher::new();
4319         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4320         core::hash::Hasher::finish(&hasher)
4321 }
4322 /// Checks if two TxAborts contain equal inner contents.
4323 /// This ignores pointers and is_owned flags and looks at the values in fields.
4324 /// Two objects with NULL inner values will be considered "equal" here.
4325 #[no_mangle]
4326 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
4327         if a.inner == b.inner { return true; }
4328         if a.inner.is_null() || b.inner.is_null() { return false; }
4329         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4330 }
4331
4332 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
4333 pub(crate) type nativeShutdown = nativeShutdownImport;
4334
4335 /// A [`shutdown`] message to be sent to or received from a peer.
4336 ///
4337 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
4338 #[must_use]
4339 #[repr(C)]
4340 pub struct Shutdown {
4341         /// A pointer to the opaque Rust object.
4342
4343         /// Nearly everywhere, inner must be non-null, however in places where
4344         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4345         pub inner: *mut nativeShutdown,
4346         /// Indicates that this is the only struct which contains the same pointer.
4347
4348         /// Rust functions which take ownership of an object provided via an argument require
4349         /// this to be true and invalidate the object pointed to by inner.
4350         pub is_owned: bool,
4351 }
4352
4353 impl Drop for Shutdown {
4354         fn drop(&mut self) {
4355                 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
4356                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4357                 }
4358         }
4359 }
4360 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
4361 #[no_mangle]
4362 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
4363 #[allow(unused)]
4364 /// Used only if an object of this type is returned as a trait impl by a method
4365 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
4366         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
4367 }
4368 #[allow(unused)]
4369 impl Shutdown {
4370         pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
4371                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4372         }
4373         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
4374                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4375         }
4376         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4377         pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
4378                 assert!(self.is_owned);
4379                 let ret = ObjOps::untweak_ptr(self.inner);
4380                 self.inner = core::ptr::null_mut();
4381                 ret
4382         }
4383 }
4384 /// The channel ID
4385 #[no_mangle]
4386 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> crate::lightning::ln::types::ChannelId {
4387         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4388         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4389 }
4390 /// The channel ID
4391 #[no_mangle]
4392 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::lightning::ln::types::ChannelId) {
4393         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4394 }
4395 /// The destination of this peer's funds on closing.
4396 ///
4397 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
4398 #[no_mangle]
4399 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
4400         let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
4401         inner_val.as_bytes().to_vec().into()
4402 }
4403 /// The destination of this peer's funds on closing.
4404 ///
4405 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
4406 #[no_mangle]
4407 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
4408         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust());
4409 }
4410 /// Constructs a new Shutdown given each field
4411 #[must_use]
4412 #[no_mangle]
4413 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
4414         Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
4415                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4416                 scriptpubkey: ::bitcoin::blockdata::script::ScriptBuf::from(scriptpubkey_arg.into_rust()),
4417         }), is_owned: true }
4418 }
4419 impl Clone for Shutdown {
4420         fn clone(&self) -> Self {
4421                 Self {
4422                         inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
4423                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4424                         is_owned: true,
4425                 }
4426         }
4427 }
4428 #[allow(unused)]
4429 /// Used only if an object of this type is returned as a trait impl by a method
4430 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
4431         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeShutdown)).clone() })) as *mut c_void
4432 }
4433 #[no_mangle]
4434 /// Creates a copy of the Shutdown
4435 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
4436         orig.clone()
4437 }
4438 /// Get a string which allows debug introspection of a Shutdown object
4439 pub extern "C" fn Shutdown_debug_str_void(o: *const c_void) -> Str {
4440         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Shutdown }).into()}
4441 /// Generates a non-cryptographic 64-bit hash of the Shutdown.
4442 #[no_mangle]
4443 pub extern "C" fn Shutdown_hash(o: &Shutdown) -> u64 {
4444         if o.inner.is_null() { return 0; }
4445         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4446         #[allow(deprecated)]
4447         let mut hasher = core::hash::SipHasher::new();
4448         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4449         core::hash::Hasher::finish(&hasher)
4450 }
4451 /// Checks if two Shutdowns contain equal inner contents.
4452 /// This ignores pointers and is_owned flags and looks at the values in fields.
4453 /// Two objects with NULL inner values will be considered "equal" here.
4454 #[no_mangle]
4455 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
4456         if a.inner == b.inner { return true; }
4457         if a.inner.is_null() || b.inner.is_null() { return false; }
4458         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4459 }
4460
4461 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
4462 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
4463
4464 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
4465 ///
4466 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
4467 /// to use.
4468 #[must_use]
4469 #[repr(C)]
4470 pub struct ClosingSignedFeeRange {
4471         /// A pointer to the opaque Rust object.
4472
4473         /// Nearly everywhere, inner must be non-null, however in places where
4474         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4475         pub inner: *mut nativeClosingSignedFeeRange,
4476         /// Indicates that this is the only struct which contains the same pointer.
4477
4478         /// Rust functions which take ownership of an object provided via an argument require
4479         /// this to be true and invalidate the object pointed to by inner.
4480         pub is_owned: bool,
4481 }
4482
4483 impl Drop for ClosingSignedFeeRange {
4484         fn drop(&mut self) {
4485                 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
4486                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4487                 }
4488         }
4489 }
4490 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
4491 #[no_mangle]
4492 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
4493 #[allow(unused)]
4494 /// Used only if an object of this type is returned as a trait impl by a method
4495 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
4496         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
4497 }
4498 #[allow(unused)]
4499 impl ClosingSignedFeeRange {
4500         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
4501                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4502         }
4503         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
4504                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4505         }
4506         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4507         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
4508                 assert!(self.is_owned);
4509                 let ret = ObjOps::untweak_ptr(self.inner);
4510                 self.inner = core::ptr::null_mut();
4511                 ret
4512         }
4513 }
4514 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
4515 /// transaction.
4516 #[no_mangle]
4517 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
4518         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
4519         *inner_val
4520 }
4521 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
4522 /// transaction.
4523 #[no_mangle]
4524 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
4525         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
4526 }
4527 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
4528 /// transaction.
4529 #[no_mangle]
4530 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
4531         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
4532         *inner_val
4533 }
4534 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
4535 /// transaction.
4536 #[no_mangle]
4537 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
4538         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
4539 }
4540 /// Constructs a new ClosingSignedFeeRange given each field
4541 #[must_use]
4542 #[no_mangle]
4543 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
4544         ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
4545                 min_fee_satoshis: min_fee_satoshis_arg,
4546                 max_fee_satoshis: max_fee_satoshis_arg,
4547         }), is_owned: true }
4548 }
4549 impl Clone for ClosingSignedFeeRange {
4550         fn clone(&self) -> Self {
4551                 Self {
4552                         inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4553                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4554                         is_owned: true,
4555                 }
4556         }
4557 }
4558 #[allow(unused)]
4559 /// Used only if an object of this type is returned as a trait impl by a method
4560 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4561         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSignedFeeRange)).clone() })) as *mut c_void
4562 }
4563 #[no_mangle]
4564 /// Creates a copy of the ClosingSignedFeeRange
4565 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
4566         orig.clone()
4567 }
4568 /// Get a string which allows debug introspection of a ClosingSignedFeeRange object
4569 pub extern "C" fn ClosingSignedFeeRange_debug_str_void(o: *const c_void) -> Str {
4570         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ClosingSignedFeeRange }).into()}
4571 /// Generates a non-cryptographic 64-bit hash of the ClosingSignedFeeRange.
4572 #[no_mangle]
4573 pub extern "C" fn ClosingSignedFeeRange_hash(o: &ClosingSignedFeeRange) -> u64 {
4574         if o.inner.is_null() { return 0; }
4575         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4576         #[allow(deprecated)]
4577         let mut hasher = core::hash::SipHasher::new();
4578         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4579         core::hash::Hasher::finish(&hasher)
4580 }
4581 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
4582 /// This ignores pointers and is_owned flags and looks at the values in fields.
4583 /// Two objects with NULL inner values will be considered "equal" here.
4584 #[no_mangle]
4585 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
4586         if a.inner == b.inner { return true; }
4587         if a.inner.is_null() || b.inner.is_null() { return false; }
4588         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4589 }
4590
4591 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
4592 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
4593
4594 /// A [`closing_signed`] message to be sent to or received from a peer.
4595 ///
4596 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
4597 #[must_use]
4598 #[repr(C)]
4599 pub struct ClosingSigned {
4600         /// A pointer to the opaque Rust object.
4601
4602         /// Nearly everywhere, inner must be non-null, however in places where
4603         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4604         pub inner: *mut nativeClosingSigned,
4605         /// Indicates that this is the only struct which contains the same pointer.
4606
4607         /// Rust functions which take ownership of an object provided via an argument require
4608         /// this to be true and invalidate the object pointed to by inner.
4609         pub is_owned: bool,
4610 }
4611
4612 impl Drop for ClosingSigned {
4613         fn drop(&mut self) {
4614                 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
4615                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4616                 }
4617         }
4618 }
4619 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
4620 #[no_mangle]
4621 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
4622 #[allow(unused)]
4623 /// Used only if an object of this type is returned as a trait impl by a method
4624 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
4625         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
4626 }
4627 #[allow(unused)]
4628 impl ClosingSigned {
4629         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
4630                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4631         }
4632         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
4633                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4634         }
4635         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4636         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
4637                 assert!(self.is_owned);
4638                 let ret = ObjOps::untweak_ptr(self.inner);
4639                 self.inner = core::ptr::null_mut();
4640                 ret
4641         }
4642 }
4643 /// The channel ID
4644 #[no_mangle]
4645 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> crate::lightning::ln::types::ChannelId {
4646         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4647         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4648 }
4649 /// The channel ID
4650 #[no_mangle]
4651 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::types::ChannelId) {
4652         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4653 }
4654 /// The proposed total fee for the closing transaction
4655 #[no_mangle]
4656 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
4657         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
4658         *inner_val
4659 }
4660 /// The proposed total fee for the closing transaction
4661 #[no_mangle]
4662 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
4663         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
4664 }
4665 /// A signature on the closing transaction
4666 #[no_mangle]
4667 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::ECDSASignature {
4668         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4669         crate::c_types::ECDSASignature::from_rust(&inner_val)
4670 }
4671 /// A signature on the closing transaction
4672 #[no_mangle]
4673 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ECDSASignature) {
4674         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4675 }
4676 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4677 /// nodes.
4678 ///
4679 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4680 #[no_mangle]
4681 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
4682         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
4683         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 };
4684         local_inner_val
4685 }
4686 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4687 /// nodes.
4688 ///
4689 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4690 #[no_mangle]
4691 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
4692         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4693         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
4694 }
4695 /// Constructs a new ClosingSigned given each field
4696 ///
4697 /// Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4698 #[must_use]
4699 #[no_mangle]
4700 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::ECDSASignature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
4701         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()) } }) };
4702         ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
4703                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4704                 fee_satoshis: fee_satoshis_arg,
4705                 signature: signature_arg.into_rust(),
4706                 fee_range: local_fee_range_arg,
4707         }), is_owned: true }
4708 }
4709 impl Clone for ClosingSigned {
4710         fn clone(&self) -> Self {
4711                 Self {
4712                         inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4713                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4714                         is_owned: true,
4715                 }
4716         }
4717 }
4718 #[allow(unused)]
4719 /// Used only if an object of this type is returned as a trait impl by a method
4720 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4721         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSigned)).clone() })) as *mut c_void
4722 }
4723 #[no_mangle]
4724 /// Creates a copy of the ClosingSigned
4725 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4726         orig.clone()
4727 }
4728 /// Get a string which allows debug introspection of a ClosingSigned object
4729 pub extern "C" fn ClosingSigned_debug_str_void(o: *const c_void) -> Str {
4730         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ClosingSigned }).into()}
4731 /// Generates a non-cryptographic 64-bit hash of the ClosingSigned.
4732 #[no_mangle]
4733 pub extern "C" fn ClosingSigned_hash(o: &ClosingSigned) -> u64 {
4734         if o.inner.is_null() { return 0; }
4735         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4736         #[allow(deprecated)]
4737         let mut hasher = core::hash::SipHasher::new();
4738         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4739         core::hash::Hasher::finish(&hasher)
4740 }
4741 /// Checks if two ClosingSigneds contain equal inner contents.
4742 /// This ignores pointers and is_owned flags and looks at the values in fields.
4743 /// Two objects with NULL inner values will be considered "equal" here.
4744 #[no_mangle]
4745 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4746         if a.inner == b.inner { return true; }
4747         if a.inner.is_null() || b.inner.is_null() { return false; }
4748         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4749 }
4750
4751 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4752 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4753
4754 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4755 ///
4756 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4757 #[must_use]
4758 #[repr(C)]
4759 pub struct UpdateAddHTLC {
4760         /// A pointer to the opaque Rust object.
4761
4762         /// Nearly everywhere, inner must be non-null, however in places where
4763         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4764         pub inner: *mut nativeUpdateAddHTLC,
4765         /// Indicates that this is the only struct which contains the same pointer.
4766
4767         /// Rust functions which take ownership of an object provided via an argument require
4768         /// this to be true and invalidate the object pointed to by inner.
4769         pub is_owned: bool,
4770 }
4771
4772 impl Drop for UpdateAddHTLC {
4773         fn drop(&mut self) {
4774                 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4775                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4776                 }
4777         }
4778 }
4779 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4780 #[no_mangle]
4781 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4782 #[allow(unused)]
4783 /// Used only if an object of this type is returned as a trait impl by a method
4784 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4785         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4786 }
4787 #[allow(unused)]
4788 impl UpdateAddHTLC {
4789         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4790                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4791         }
4792         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4793                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4794         }
4795         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4796         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4797                 assert!(self.is_owned);
4798                 let ret = ObjOps::untweak_ptr(self.inner);
4799                 self.inner = core::ptr::null_mut();
4800                 ret
4801         }
4802 }
4803 /// The channel ID
4804 #[no_mangle]
4805 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> crate::lightning::ln::types::ChannelId {
4806         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4807         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4808 }
4809 /// The channel ID
4810 #[no_mangle]
4811 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::lightning::ln::types::ChannelId) {
4812         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4813 }
4814 /// The HTLC ID
4815 #[no_mangle]
4816 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4817         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4818         *inner_val
4819 }
4820 /// The HTLC ID
4821 #[no_mangle]
4822 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4823         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4824 }
4825 /// The HTLC value in milli-satoshi
4826 #[no_mangle]
4827 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4828         let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4829         *inner_val
4830 }
4831 /// The HTLC value in milli-satoshi
4832 #[no_mangle]
4833 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4834         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4835 }
4836 /// The payment hash, the pre-image of which controls HTLC redemption
4837 #[no_mangle]
4838 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4839         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4840         &inner_val.0
4841 }
4842 /// The payment hash, the pre-image of which controls HTLC redemption
4843 #[no_mangle]
4844 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4845         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::types::PaymentHash(val.data);
4846 }
4847 /// The expiry height of the HTLC
4848 #[no_mangle]
4849 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4850         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4851         *inner_val
4852 }
4853 /// The expiry height of the HTLC
4854 #[no_mangle]
4855 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4856         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
4857 }
4858 /// The extra fee skimmed by the sender of this message. See
4859 /// [`ChannelConfig::accept_underpaying_htlcs`].
4860 ///
4861 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4862 #[no_mangle]
4863 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
4864         let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
4865         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() }) };
4866         local_inner_val
4867 }
4868 /// The extra fee skimmed by the sender of this message. See
4869 /// [`ChannelConfig::accept_underpaying_htlcs`].
4870 ///
4871 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4872 #[no_mangle]
4873 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
4874         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4875         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
4876 }
4877 /// The onion routing packet with encrypted data for the next hop.
4878 #[no_mangle]
4879 pub extern "C" fn UpdateAddHTLC_get_onion_routing_packet(this_ptr: &UpdateAddHTLC) -> crate::lightning::ln::msgs::OnionPacket {
4880         let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
4881         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 }
4882 }
4883 /// The onion routing packet with encrypted data for the next hop.
4884 #[no_mangle]
4885 pub extern "C" fn UpdateAddHTLC_set_onion_routing_packet(this_ptr: &mut UpdateAddHTLC, mut val: crate::lightning::ln::msgs::OnionPacket) {
4886         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
4887 }
4888 /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
4889 /// routing packet and the recipient-provided encrypted payload within.
4890 ///
4891 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4892 #[no_mangle]
4893 pub extern "C" fn UpdateAddHTLC_get_blinding_point(this_ptr: &UpdateAddHTLC) -> crate::c_types::PublicKey {
4894         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
4895         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())) } };
4896         local_inner_val
4897 }
4898 /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
4899 /// routing packet and the recipient-provided encrypted payload within.
4900 ///
4901 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4902 #[no_mangle]
4903 pub extern "C" fn UpdateAddHTLC_set_blinding_point(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::PublicKey) {
4904         let mut local_val = if val.is_null() { None } else { Some( { val.into_rust() }) };
4905         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = local_val;
4906 }
4907 /// Constructs a new UpdateAddHTLC given each field
4908 ///
4909 /// Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4910 #[must_use]
4911 #[no_mangle]
4912 pub extern "C" fn UpdateAddHTLC_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, 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 {
4913         let mut local_skimmed_fee_msat_arg = if skimmed_fee_msat_arg.is_some() { Some( { skimmed_fee_msat_arg.take() }) } else { None };
4914         let mut local_blinding_point_arg = if blinding_point_arg.is_null() { None } else { Some( { blinding_point_arg.into_rust() }) };
4915         UpdateAddHTLC { inner: ObjOps::heap_alloc(nativeUpdateAddHTLC {
4916                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4917                 htlc_id: htlc_id_arg,
4918                 amount_msat: amount_msat_arg,
4919                 payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_arg.data),
4920                 cltv_expiry: cltv_expiry_arg,
4921                 skimmed_fee_msat: local_skimmed_fee_msat_arg,
4922                 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
4923                 blinding_point: local_blinding_point_arg,
4924         }), is_owned: true }
4925 }
4926 impl Clone for UpdateAddHTLC {
4927         fn clone(&self) -> Self {
4928                 Self {
4929                         inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4930                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4931                         is_owned: true,
4932                 }
4933         }
4934 }
4935 #[allow(unused)]
4936 /// Used only if an object of this type is returned as a trait impl by a method
4937 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4938         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateAddHTLC)).clone() })) as *mut c_void
4939 }
4940 #[no_mangle]
4941 /// Creates a copy of the UpdateAddHTLC
4942 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
4943         orig.clone()
4944 }
4945 /// Get a string which allows debug introspection of a UpdateAddHTLC object
4946 pub extern "C" fn UpdateAddHTLC_debug_str_void(o: *const c_void) -> Str {
4947         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateAddHTLC }).into()}
4948 /// Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC.
4949 #[no_mangle]
4950 pub extern "C" fn UpdateAddHTLC_hash(o: &UpdateAddHTLC) -> u64 {
4951         if o.inner.is_null() { return 0; }
4952         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4953         #[allow(deprecated)]
4954         let mut hasher = core::hash::SipHasher::new();
4955         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4956         core::hash::Hasher::finish(&hasher)
4957 }
4958 /// Checks if two UpdateAddHTLCs contain equal inner contents.
4959 /// This ignores pointers and is_owned flags and looks at the values in fields.
4960 /// Two objects with NULL inner values will be considered "equal" here.
4961 #[no_mangle]
4962 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
4963         if a.inner == b.inner { return true; }
4964         if a.inner.is_null() || b.inner.is_null() { return false; }
4965         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4966 }
4967
4968 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
4969 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
4970
4971 /// An onion message to be sent to or received from a peer.
4972 ///
4973 #[must_use]
4974 #[repr(C)]
4975 pub struct OnionMessage {
4976         /// A pointer to the opaque Rust object.
4977
4978         /// Nearly everywhere, inner must be non-null, however in places where
4979         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4980         pub inner: *mut nativeOnionMessage,
4981         /// Indicates that this is the only struct which contains the same pointer.
4982
4983         /// Rust functions which take ownership of an object provided via an argument require
4984         /// this to be true and invalidate the object pointed to by inner.
4985         pub is_owned: bool,
4986 }
4987
4988 impl Drop for OnionMessage {
4989         fn drop(&mut self) {
4990                 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
4991                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4992                 }
4993         }
4994 }
4995 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
4996 #[no_mangle]
4997 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
4998 #[allow(unused)]
4999 /// Used only if an object of this type is returned as a trait impl by a method
5000 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
5001         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
5002 }
5003 #[allow(unused)]
5004 impl OnionMessage {
5005         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
5006                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5007         }
5008         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
5009                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5010         }
5011         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5012         pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
5013                 assert!(self.is_owned);
5014                 let ret = ObjOps::untweak_ptr(self.inner);
5015                 self.inner = core::ptr::null_mut();
5016                 ret
5017         }
5018 }
5019 /// Used in decrypting the onion packet's payload.
5020 #[no_mangle]
5021 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
5022         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
5023         crate::c_types::PublicKey::from_rust(&inner_val)
5024 }
5025 /// Used in decrypting the onion packet's payload.
5026 #[no_mangle]
5027 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
5028         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
5029 }
5030 /// The full onion packet including hop data, pubkey, and hmac
5031 #[no_mangle]
5032 pub extern "C" fn OnionMessage_get_onion_routing_packet(this_ptr: &OnionMessage) -> crate::lightning::onion_message::packet::Packet {
5033         let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
5034         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 }
5035 }
5036 /// The full onion packet including hop data, pubkey, and hmac
5037 #[no_mangle]
5038 pub extern "C" fn OnionMessage_set_onion_routing_packet(this_ptr: &mut OnionMessage, mut val: crate::lightning::onion_message::packet::Packet) {
5039         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
5040 }
5041 /// Constructs a new OnionMessage given each field
5042 #[must_use]
5043 #[no_mangle]
5044 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 {
5045         OnionMessage { inner: ObjOps::heap_alloc(nativeOnionMessage {
5046                 blinding_point: blinding_point_arg.into_rust(),
5047                 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
5048         }), is_owned: true }
5049 }
5050 impl Clone for OnionMessage {
5051         fn clone(&self) -> Self {
5052                 Self {
5053                         inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
5054                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5055                         is_owned: true,
5056                 }
5057         }
5058 }
5059 #[allow(unused)]
5060 /// Used only if an object of this type is returned as a trait impl by a method
5061 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
5062         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionMessage)).clone() })) as *mut c_void
5063 }
5064 #[no_mangle]
5065 /// Creates a copy of the OnionMessage
5066 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
5067         orig.clone()
5068 }
5069 /// Get a string which allows debug introspection of a OnionMessage object
5070 pub extern "C" fn OnionMessage_debug_str_void(o: *const c_void) -> Str {
5071         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionMessage }).into()}
5072 /// Generates a non-cryptographic 64-bit hash of the OnionMessage.
5073 #[no_mangle]
5074 pub extern "C" fn OnionMessage_hash(o: &OnionMessage) -> u64 {
5075         if o.inner.is_null() { return 0; }
5076         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5077         #[allow(deprecated)]
5078         let mut hasher = core::hash::SipHasher::new();
5079         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5080         core::hash::Hasher::finish(&hasher)
5081 }
5082 /// Checks if two OnionMessages contain equal inner contents.
5083 /// This ignores pointers and is_owned flags and looks at the values in fields.
5084 /// Two objects with NULL inner values will be considered "equal" here.
5085 #[no_mangle]
5086 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
5087         if a.inner == b.inner { return true; }
5088         if a.inner.is_null() || b.inner.is_null() { return false; }
5089         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5090 }
5091
5092 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
5093 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
5094
5095 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
5096 ///
5097 /// [`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
5098 #[must_use]
5099 #[repr(C)]
5100 pub struct UpdateFulfillHTLC {
5101         /// A pointer to the opaque Rust object.
5102
5103         /// Nearly everywhere, inner must be non-null, however in places where
5104         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5105         pub inner: *mut nativeUpdateFulfillHTLC,
5106         /// Indicates that this is the only struct which contains the same pointer.
5107
5108         /// Rust functions which take ownership of an object provided via an argument require
5109         /// this to be true and invalidate the object pointed to by inner.
5110         pub is_owned: bool,
5111 }
5112
5113 impl Drop for UpdateFulfillHTLC {
5114         fn drop(&mut self) {
5115                 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
5116                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5117                 }
5118         }
5119 }
5120 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
5121 #[no_mangle]
5122 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
5123 #[allow(unused)]
5124 /// Used only if an object of this type is returned as a trait impl by a method
5125 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
5126         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
5127 }
5128 #[allow(unused)]
5129 impl UpdateFulfillHTLC {
5130         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
5131                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5132         }
5133         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
5134                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5135         }
5136         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5137         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
5138                 assert!(self.is_owned);
5139                 let ret = ObjOps::untweak_ptr(self.inner);
5140                 self.inner = core::ptr::null_mut();
5141                 ret
5142         }
5143 }
5144 /// The channel ID
5145 #[no_mangle]
5146 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> crate::lightning::ln::types::ChannelId {
5147         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5148         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5149 }
5150 /// The channel ID
5151 #[no_mangle]
5152 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::lightning::ln::types::ChannelId) {
5153         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5154 }
5155 /// The HTLC ID
5156 #[no_mangle]
5157 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
5158         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5159         *inner_val
5160 }
5161 /// The HTLC ID
5162 #[no_mangle]
5163 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
5164         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5165 }
5166 /// The pre-image of the payment hash, allowing HTLC redemption
5167 #[no_mangle]
5168 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
5169         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
5170         &inner_val.0
5171 }
5172 /// The pre-image of the payment hash, allowing HTLC redemption
5173 #[no_mangle]
5174 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5175         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::types::PaymentPreimage(val.data);
5176 }
5177 /// Constructs a new UpdateFulfillHTLC given each field
5178 #[must_use]
5179 #[no_mangle]
5180 pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC {
5181         UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
5182                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5183                 htlc_id: htlc_id_arg,
5184                 payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage_arg.data),
5185         }), is_owned: true }
5186 }
5187 impl Clone for UpdateFulfillHTLC {
5188         fn clone(&self) -> Self {
5189                 Self {
5190                         inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5191                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5192                         is_owned: true,
5193                 }
5194         }
5195 }
5196 #[allow(unused)]
5197 /// Used only if an object of this type is returned as a trait impl by a method
5198 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5199         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
5200 }
5201 #[no_mangle]
5202 /// Creates a copy of the UpdateFulfillHTLC
5203 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
5204         orig.clone()
5205 }
5206 /// Get a string which allows debug introspection of a UpdateFulfillHTLC object
5207 pub extern "C" fn UpdateFulfillHTLC_debug_str_void(o: *const c_void) -> Str {
5208         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFulfillHTLC }).into()}
5209 /// Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC.
5210 #[no_mangle]
5211 pub extern "C" fn UpdateFulfillHTLC_hash(o: &UpdateFulfillHTLC) -> u64 {
5212         if o.inner.is_null() { return 0; }
5213         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5214         #[allow(deprecated)]
5215         let mut hasher = core::hash::SipHasher::new();
5216         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5217         core::hash::Hasher::finish(&hasher)
5218 }
5219 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
5220 /// This ignores pointers and is_owned flags and looks at the values in fields.
5221 /// Two objects with NULL inner values will be considered "equal" here.
5222 #[no_mangle]
5223 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
5224         if a.inner == b.inner { return true; }
5225         if a.inner.is_null() || b.inner.is_null() { return false; }
5226         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5227 }
5228
5229 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
5230 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
5231
5232 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
5233 ///
5234 /// [`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
5235 #[must_use]
5236 #[repr(C)]
5237 pub struct UpdateFailHTLC {
5238         /// A pointer to the opaque Rust object.
5239
5240         /// Nearly everywhere, inner must be non-null, however in places where
5241         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5242         pub inner: *mut nativeUpdateFailHTLC,
5243         /// Indicates that this is the only struct which contains the same pointer.
5244
5245         /// Rust functions which take ownership of an object provided via an argument require
5246         /// this to be true and invalidate the object pointed to by inner.
5247         pub is_owned: bool,
5248 }
5249
5250 impl Drop for UpdateFailHTLC {
5251         fn drop(&mut self) {
5252                 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
5253                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5254                 }
5255         }
5256 }
5257 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
5258 #[no_mangle]
5259 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
5260 #[allow(unused)]
5261 /// Used only if an object of this type is returned as a trait impl by a method
5262 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
5263         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
5264 }
5265 #[allow(unused)]
5266 impl UpdateFailHTLC {
5267         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
5268                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5269         }
5270         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
5271                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5272         }
5273         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5274         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
5275                 assert!(self.is_owned);
5276                 let ret = ObjOps::untweak_ptr(self.inner);
5277                 self.inner = core::ptr::null_mut();
5278                 ret
5279         }
5280 }
5281 /// The channel ID
5282 #[no_mangle]
5283 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> crate::lightning::ln::types::ChannelId {
5284         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5285         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5286 }
5287 /// The channel ID
5288 #[no_mangle]
5289 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::lightning::ln::types::ChannelId) {
5290         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5291 }
5292 /// The HTLC ID
5293 #[no_mangle]
5294 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
5295         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5296         *inner_val
5297 }
5298 /// The HTLC ID
5299 #[no_mangle]
5300 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
5301         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5302 }
5303 impl Clone for UpdateFailHTLC {
5304         fn clone(&self) -> Self {
5305                 Self {
5306                         inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5307                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5308                         is_owned: true,
5309                 }
5310         }
5311 }
5312 #[allow(unused)]
5313 /// Used only if an object of this type is returned as a trait impl by a method
5314 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5315         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailHTLC)).clone() })) as *mut c_void
5316 }
5317 #[no_mangle]
5318 /// Creates a copy of the UpdateFailHTLC
5319 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
5320         orig.clone()
5321 }
5322 /// Get a string which allows debug introspection of a UpdateFailHTLC object
5323 pub extern "C" fn UpdateFailHTLC_debug_str_void(o: *const c_void) -> Str {
5324         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailHTLC }).into()}
5325 /// Generates a non-cryptographic 64-bit hash of the UpdateFailHTLC.
5326 #[no_mangle]
5327 pub extern "C" fn UpdateFailHTLC_hash(o: &UpdateFailHTLC) -> u64 {
5328         if o.inner.is_null() { return 0; }
5329         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5330         #[allow(deprecated)]
5331         let mut hasher = core::hash::SipHasher::new();
5332         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5333         core::hash::Hasher::finish(&hasher)
5334 }
5335 /// Checks if two UpdateFailHTLCs contain equal inner contents.
5336 /// This ignores pointers and is_owned flags and looks at the values in fields.
5337 /// Two objects with NULL inner values will be considered "equal" here.
5338 #[no_mangle]
5339 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
5340         if a.inner == b.inner { return true; }
5341         if a.inner.is_null() || b.inner.is_null() { return false; }
5342         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5343 }
5344
5345 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
5346 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
5347
5348 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
5349 ///
5350 /// [`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
5351 #[must_use]
5352 #[repr(C)]
5353 pub struct UpdateFailMalformedHTLC {
5354         /// A pointer to the opaque Rust object.
5355
5356         /// Nearly everywhere, inner must be non-null, however in places where
5357         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5358         pub inner: *mut nativeUpdateFailMalformedHTLC,
5359         /// Indicates that this is the only struct which contains the same pointer.
5360
5361         /// Rust functions which take ownership of an object provided via an argument require
5362         /// this to be true and invalidate the object pointed to by inner.
5363         pub is_owned: bool,
5364 }
5365
5366 impl Drop for UpdateFailMalformedHTLC {
5367         fn drop(&mut self) {
5368                 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
5369                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5370                 }
5371         }
5372 }
5373 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
5374 #[no_mangle]
5375 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
5376 #[allow(unused)]
5377 /// Used only if an object of this type is returned as a trait impl by a method
5378 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
5379         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
5380 }
5381 #[allow(unused)]
5382 impl UpdateFailMalformedHTLC {
5383         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
5384                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5385         }
5386         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
5387                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5388         }
5389         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5390         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
5391                 assert!(self.is_owned);
5392                 let ret = ObjOps::untweak_ptr(self.inner);
5393                 self.inner = core::ptr::null_mut();
5394                 ret
5395         }
5396 }
5397 /// The channel ID
5398 #[no_mangle]
5399 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> crate::lightning::ln::types::ChannelId {
5400         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5401         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5402 }
5403 /// The channel ID
5404 #[no_mangle]
5405 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::lightning::ln::types::ChannelId) {
5406         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5407 }
5408 /// The HTLC ID
5409 #[no_mangle]
5410 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
5411         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5412         *inner_val
5413 }
5414 /// The HTLC ID
5415 #[no_mangle]
5416 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
5417         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5418 }
5419 /// The failure code
5420 #[no_mangle]
5421 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
5422         let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
5423         *inner_val
5424 }
5425 /// The failure code
5426 #[no_mangle]
5427 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
5428         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
5429 }
5430 impl Clone for UpdateFailMalformedHTLC {
5431         fn clone(&self) -> Self {
5432                 Self {
5433                         inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5434                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5435                         is_owned: true,
5436                 }
5437         }
5438 }
5439 #[allow(unused)]
5440 /// Used only if an object of this type is returned as a trait impl by a method
5441 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5442         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
5443 }
5444 #[no_mangle]
5445 /// Creates a copy of the UpdateFailMalformedHTLC
5446 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
5447         orig.clone()
5448 }
5449 /// Get a string which allows debug introspection of a UpdateFailMalformedHTLC object
5450 pub extern "C" fn UpdateFailMalformedHTLC_debug_str_void(o: *const c_void) -> Str {
5451         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailMalformedHTLC }).into()}
5452 /// Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC.
5453 #[no_mangle]
5454 pub extern "C" fn UpdateFailMalformedHTLC_hash(o: &UpdateFailMalformedHTLC) -> u64 {
5455         if o.inner.is_null() { return 0; }
5456         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5457         #[allow(deprecated)]
5458         let mut hasher = core::hash::SipHasher::new();
5459         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5460         core::hash::Hasher::finish(&hasher)
5461 }
5462 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
5463 /// This ignores pointers and is_owned flags and looks at the values in fields.
5464 /// Two objects with NULL inner values will be considered "equal" here.
5465 #[no_mangle]
5466 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
5467         if a.inner == b.inner { return true; }
5468         if a.inner.is_null() || b.inner.is_null() { return false; }
5469         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5470 }
5471
5472 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
5473 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
5474
5475 /// A [`commitment_signed`] message to be sent to or received from a peer.
5476 ///
5477 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
5478 #[must_use]
5479 #[repr(C)]
5480 pub struct CommitmentSigned {
5481         /// A pointer to the opaque Rust object.
5482
5483         /// Nearly everywhere, inner must be non-null, however in places where
5484         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5485         pub inner: *mut nativeCommitmentSigned,
5486         /// Indicates that this is the only struct which contains the same pointer.
5487
5488         /// Rust functions which take ownership of an object provided via an argument require
5489         /// this to be true and invalidate the object pointed to by inner.
5490         pub is_owned: bool,
5491 }
5492
5493 impl Drop for CommitmentSigned {
5494         fn drop(&mut self) {
5495                 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
5496                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5497                 }
5498         }
5499 }
5500 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
5501 #[no_mangle]
5502 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
5503 #[allow(unused)]
5504 /// Used only if an object of this type is returned as a trait impl by a method
5505 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
5506         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
5507 }
5508 #[allow(unused)]
5509 impl CommitmentSigned {
5510         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
5511                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5512         }
5513         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
5514                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5515         }
5516         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5517         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
5518                 assert!(self.is_owned);
5519                 let ret = ObjOps::untweak_ptr(self.inner);
5520                 self.inner = core::ptr::null_mut();
5521                 ret
5522         }
5523 }
5524 /// The channel ID
5525 #[no_mangle]
5526 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> crate::lightning::ln::types::ChannelId {
5527         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5528         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5529 }
5530 /// The channel ID
5531 #[no_mangle]
5532 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::lightning::ln::types::ChannelId) {
5533         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5534 }
5535 /// A signature on the commitment transaction
5536 #[no_mangle]
5537 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::ECDSASignature {
5538         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
5539         crate::c_types::ECDSASignature::from_rust(&inner_val)
5540 }
5541 /// A signature on the commitment transaction
5542 #[no_mangle]
5543 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ECDSASignature) {
5544         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
5545 }
5546 /// Signatures on the HTLC transactions
5547 ///
5548 /// Returns a copy of the field.
5549 #[no_mangle]
5550 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_ECDSASignatureZ {
5551         let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
5552         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) }); };
5553         local_inner_val.into()
5554 }
5555 /// Signatures on the HTLC transactions
5556 #[no_mangle]
5557 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_ECDSASignatureZ) {
5558         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
5559         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
5560 }
5561 /// Constructs a new CommitmentSigned given each field
5562 #[must_use]
5563 #[no_mangle]
5564 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ) -> CommitmentSigned {
5565         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() }); };
5566         CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
5567                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5568                 signature: signature_arg.into_rust(),
5569                 htlc_signatures: local_htlc_signatures_arg,
5570         }), is_owned: true }
5571 }
5572 impl Clone for CommitmentSigned {
5573         fn clone(&self) -> Self {
5574                 Self {
5575                         inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
5576                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5577                         is_owned: true,
5578                 }
5579         }
5580 }
5581 #[allow(unused)]
5582 /// Used only if an object of this type is returned as a trait impl by a method
5583 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
5584         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentSigned)).clone() })) as *mut c_void
5585 }
5586 #[no_mangle]
5587 /// Creates a copy of the CommitmentSigned
5588 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
5589         orig.clone()
5590 }
5591 /// Get a string which allows debug introspection of a CommitmentSigned object
5592 pub extern "C" fn CommitmentSigned_debug_str_void(o: *const c_void) -> Str {
5593         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentSigned }).into()}
5594 /// Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
5595 #[no_mangle]
5596 pub extern "C" fn CommitmentSigned_hash(o: &CommitmentSigned) -> u64 {
5597         if o.inner.is_null() { return 0; }
5598         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5599         #[allow(deprecated)]
5600         let mut hasher = core::hash::SipHasher::new();
5601         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5602         core::hash::Hasher::finish(&hasher)
5603 }
5604 /// Checks if two CommitmentSigneds contain equal inner contents.
5605 /// This ignores pointers and is_owned flags and looks at the values in fields.
5606 /// Two objects with NULL inner values will be considered "equal" here.
5607 #[no_mangle]
5608 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
5609         if a.inner == b.inner { return true; }
5610         if a.inner.is_null() || b.inner.is_null() { return false; }
5611         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5612 }
5613
5614 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
5615 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
5616
5617 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
5618 ///
5619 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
5620 #[must_use]
5621 #[repr(C)]
5622 pub struct RevokeAndACK {
5623         /// A pointer to the opaque Rust object.
5624
5625         /// Nearly everywhere, inner must be non-null, however in places where
5626         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5627         pub inner: *mut nativeRevokeAndACK,
5628         /// Indicates that this is the only struct which contains the same pointer.
5629
5630         /// Rust functions which take ownership of an object provided via an argument require
5631         /// this to be true and invalidate the object pointed to by inner.
5632         pub is_owned: bool,
5633 }
5634
5635 impl Drop for RevokeAndACK {
5636         fn drop(&mut self) {
5637                 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
5638                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5639                 }
5640         }
5641 }
5642 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
5643 #[no_mangle]
5644 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
5645 #[allow(unused)]
5646 /// Used only if an object of this type is returned as a trait impl by a method
5647 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
5648         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
5649 }
5650 #[allow(unused)]
5651 impl RevokeAndACK {
5652         pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
5653                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5654         }
5655         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
5656                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5657         }
5658         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5659         pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
5660                 assert!(self.is_owned);
5661                 let ret = ObjOps::untweak_ptr(self.inner);
5662                 self.inner = core::ptr::null_mut();
5663                 ret
5664         }
5665 }
5666 /// The channel ID
5667 #[no_mangle]
5668 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> crate::lightning::ln::types::ChannelId {
5669         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5670         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5671 }
5672 /// The channel ID
5673 #[no_mangle]
5674 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::lightning::ln::types::ChannelId) {
5675         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5676 }
5677 /// The secret corresponding to the per-commitment point
5678 #[no_mangle]
5679 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
5680         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
5681         inner_val
5682 }
5683 /// The secret corresponding to the per-commitment point
5684 #[no_mangle]
5685 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
5686         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
5687 }
5688 /// The next sender-broadcast commitment transaction's per-commitment point
5689 #[no_mangle]
5690 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
5691         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
5692         crate::c_types::PublicKey::from_rust(&inner_val)
5693 }
5694 /// The next sender-broadcast commitment transaction's per-commitment point
5695 #[no_mangle]
5696 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
5697         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
5698 }
5699 /// Constructs a new RevokeAndACK given each field
5700 #[must_use]
5701 #[no_mangle]
5702 pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK {
5703         RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
5704                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5705                 per_commitment_secret: per_commitment_secret_arg.data,
5706                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
5707         }), is_owned: true }
5708 }
5709 impl Clone for RevokeAndACK {
5710         fn clone(&self) -> Self {
5711                 Self {
5712                         inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
5713                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5714                         is_owned: true,
5715                 }
5716         }
5717 }
5718 #[allow(unused)]
5719 /// Used only if an object of this type is returned as a trait impl by a method
5720 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
5721         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRevokeAndACK)).clone() })) as *mut c_void
5722 }
5723 #[no_mangle]
5724 /// Creates a copy of the RevokeAndACK
5725 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
5726         orig.clone()
5727 }
5728 /// Get a string which allows debug introspection of a RevokeAndACK object
5729 pub extern "C" fn RevokeAndACK_debug_str_void(o: *const c_void) -> Str {
5730         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::RevokeAndACK }).into()}
5731 /// Generates a non-cryptographic 64-bit hash of the RevokeAndACK.
5732 #[no_mangle]
5733 pub extern "C" fn RevokeAndACK_hash(o: &RevokeAndACK) -> u64 {
5734         if o.inner.is_null() { return 0; }
5735         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5736         #[allow(deprecated)]
5737         let mut hasher = core::hash::SipHasher::new();
5738         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5739         core::hash::Hasher::finish(&hasher)
5740 }
5741 /// Checks if two RevokeAndACKs contain equal inner contents.
5742 /// This ignores pointers and is_owned flags and looks at the values in fields.
5743 /// Two objects with NULL inner values will be considered "equal" here.
5744 #[no_mangle]
5745 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
5746         if a.inner == b.inner { return true; }
5747         if a.inner.is_null() || b.inner.is_null() { return false; }
5748         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5749 }
5750
5751 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
5752 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
5753
5754 /// An [`update_fee`] message to be sent to or received from a peer
5755 ///
5756 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
5757 #[must_use]
5758 #[repr(C)]
5759 pub struct UpdateFee {
5760         /// A pointer to the opaque Rust object.
5761
5762         /// Nearly everywhere, inner must be non-null, however in places where
5763         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5764         pub inner: *mut nativeUpdateFee,
5765         /// Indicates that this is the only struct which contains the same pointer.
5766
5767         /// Rust functions which take ownership of an object provided via an argument require
5768         /// this to be true and invalidate the object pointed to by inner.
5769         pub is_owned: bool,
5770 }
5771
5772 impl Drop for UpdateFee {
5773         fn drop(&mut self) {
5774                 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
5775                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5776                 }
5777         }
5778 }
5779 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
5780 #[no_mangle]
5781 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
5782 #[allow(unused)]
5783 /// Used only if an object of this type is returned as a trait impl by a method
5784 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
5785         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
5786 }
5787 #[allow(unused)]
5788 impl UpdateFee {
5789         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
5790                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5791         }
5792         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
5793                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5794         }
5795         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5796         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
5797                 assert!(self.is_owned);
5798                 let ret = ObjOps::untweak_ptr(self.inner);
5799                 self.inner = core::ptr::null_mut();
5800                 ret
5801         }
5802 }
5803 /// The channel ID
5804 #[no_mangle]
5805 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> crate::lightning::ln::types::ChannelId {
5806         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5807         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5808 }
5809 /// The channel ID
5810 #[no_mangle]
5811 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::lightning::ln::types::ChannelId) {
5812         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5813 }
5814 /// Fee rate per 1000-weight of the transaction
5815 #[no_mangle]
5816 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
5817         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
5818         *inner_val
5819 }
5820 /// Fee rate per 1000-weight of the transaction
5821 #[no_mangle]
5822 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
5823         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
5824 }
5825 /// Constructs a new UpdateFee given each field
5826 #[must_use]
5827 #[no_mangle]
5828 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut feerate_per_kw_arg: u32) -> UpdateFee {
5829         UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
5830                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5831                 feerate_per_kw: feerate_per_kw_arg,
5832         }), is_owned: true }
5833 }
5834 impl Clone for UpdateFee {
5835         fn clone(&self) -> Self {
5836                 Self {
5837                         inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
5838                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5839                         is_owned: true,
5840                 }
5841         }
5842 }
5843 #[allow(unused)]
5844 /// Used only if an object of this type is returned as a trait impl by a method
5845 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
5846         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFee)).clone() })) as *mut c_void
5847 }
5848 #[no_mangle]
5849 /// Creates a copy of the UpdateFee
5850 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
5851         orig.clone()
5852 }
5853 /// Get a string which allows debug introspection of a UpdateFee object
5854 pub extern "C" fn UpdateFee_debug_str_void(o: *const c_void) -> Str {
5855         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFee }).into()}
5856 /// Generates a non-cryptographic 64-bit hash of the UpdateFee.
5857 #[no_mangle]
5858 pub extern "C" fn UpdateFee_hash(o: &UpdateFee) -> u64 {
5859         if o.inner.is_null() { return 0; }
5860         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5861         #[allow(deprecated)]
5862         let mut hasher = core::hash::SipHasher::new();
5863         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5864         core::hash::Hasher::finish(&hasher)
5865 }
5866 /// Checks if two UpdateFees contain equal inner contents.
5867 /// This ignores pointers and is_owned flags and looks at the values in fields.
5868 /// Two objects with NULL inner values will be considered "equal" here.
5869 #[no_mangle]
5870 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
5871         if a.inner == b.inner { return true; }
5872         if a.inner.is_null() || b.inner.is_null() { return false; }
5873         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5874 }
5875
5876 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
5877 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
5878
5879 /// A [`channel_reestablish`] message to be sent to or received from a peer.
5880 ///
5881 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
5882 #[must_use]
5883 #[repr(C)]
5884 pub struct ChannelReestablish {
5885         /// A pointer to the opaque Rust object.
5886
5887         /// Nearly everywhere, inner must be non-null, however in places where
5888         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5889         pub inner: *mut nativeChannelReestablish,
5890         /// Indicates that this is the only struct which contains the same pointer.
5891
5892         /// Rust functions which take ownership of an object provided via an argument require
5893         /// this to be true and invalidate the object pointed to by inner.
5894         pub is_owned: bool,
5895 }
5896
5897 impl Drop for ChannelReestablish {
5898         fn drop(&mut self) {
5899                 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
5900                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5901                 }
5902         }
5903 }
5904 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
5905 #[no_mangle]
5906 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
5907 #[allow(unused)]
5908 /// Used only if an object of this type is returned as a trait impl by a method
5909 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
5910         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
5911 }
5912 #[allow(unused)]
5913 impl ChannelReestablish {
5914         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
5915                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5916         }
5917         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
5918                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5919         }
5920         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5921         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
5922                 assert!(self.is_owned);
5923                 let ret = ObjOps::untweak_ptr(self.inner);
5924                 self.inner = core::ptr::null_mut();
5925                 ret
5926         }
5927 }
5928 /// The channel ID
5929 #[no_mangle]
5930 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> crate::lightning::ln::types::ChannelId {
5931         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5932         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5933 }
5934 /// The channel ID
5935 #[no_mangle]
5936 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::lightning::ln::types::ChannelId) {
5937         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5938 }
5939 /// The next commitment number for the sender
5940 #[no_mangle]
5941 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5942         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
5943         *inner_val
5944 }
5945 /// The next commitment number for the sender
5946 #[no_mangle]
5947 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5948         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
5949 }
5950 /// The next commitment number for the recipient
5951 #[no_mangle]
5952 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5953         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
5954         *inner_val
5955 }
5956 /// The next commitment number for the recipient
5957 #[no_mangle]
5958 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5959         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
5960 }
5961 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5962 /// belonging to the recipient
5963 #[no_mangle]
5964 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5965         let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
5966         inner_val
5967 }
5968 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5969 /// belonging to the recipient
5970 #[no_mangle]
5971 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5972         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
5973 }
5974 /// The sender's per-commitment point for their current commitment transaction
5975 #[no_mangle]
5976 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
5977         let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
5978         crate::c_types::PublicKey::from_rust(&inner_val)
5979 }
5980 /// The sender's per-commitment point for their current commitment transaction
5981 #[no_mangle]
5982 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
5983         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
5984 }
5985 /// The next funding transaction ID
5986 #[no_mangle]
5987 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
5988         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
5989         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() } }) };
5990         local_inner_val
5991 }
5992 /// The next funding transaction ID
5993 #[no_mangle]
5994 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
5995         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() }})} };
5996         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
5997 }
5998 /// Constructs a new ChannelReestablish given each field
5999 #[must_use]
6000 #[no_mangle]
6001 pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, 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 {
6002         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() }})} };
6003         ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
6004                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
6005                 next_local_commitment_number: next_local_commitment_number_arg,
6006                 next_remote_commitment_number: next_remote_commitment_number_arg,
6007                 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
6008                 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
6009                 next_funding_txid: local_next_funding_txid_arg,
6010         }), is_owned: true }
6011 }
6012 impl Clone for ChannelReestablish {
6013         fn clone(&self) -> Self {
6014                 Self {
6015                         inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
6016                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6017                         is_owned: true,
6018                 }
6019         }
6020 }
6021 #[allow(unused)]
6022 /// Used only if an object of this type is returned as a trait impl by a method
6023 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
6024         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReestablish)).clone() })) as *mut c_void
6025 }
6026 #[no_mangle]
6027 /// Creates a copy of the ChannelReestablish
6028 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
6029         orig.clone()
6030 }
6031 /// Get a string which allows debug introspection of a ChannelReestablish object
6032 pub extern "C" fn ChannelReestablish_debug_str_void(o: *const c_void) -> Str {
6033         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelReestablish }).into()}
6034 /// Generates a non-cryptographic 64-bit hash of the ChannelReestablish.
6035 #[no_mangle]
6036 pub extern "C" fn ChannelReestablish_hash(o: &ChannelReestablish) -> u64 {
6037         if o.inner.is_null() { return 0; }
6038         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6039         #[allow(deprecated)]
6040         let mut hasher = core::hash::SipHasher::new();
6041         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6042         core::hash::Hasher::finish(&hasher)
6043 }
6044 /// Checks if two ChannelReestablishs contain equal inner contents.
6045 /// This ignores pointers and is_owned flags and looks at the values in fields.
6046 /// Two objects with NULL inner values will be considered "equal" here.
6047 #[no_mangle]
6048 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
6049         if a.inner == b.inner { return true; }
6050         if a.inner.is_null() || b.inner.is_null() { return false; }
6051         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6052 }
6053
6054 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
6055 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
6056
6057 /// An [`announcement_signatures`] message to be sent to or received from a peer.
6058 ///
6059 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
6060 #[must_use]
6061 #[repr(C)]
6062 pub struct AnnouncementSignatures {
6063         /// A pointer to the opaque Rust object.
6064
6065         /// Nearly everywhere, inner must be non-null, however in places where
6066         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6067         pub inner: *mut nativeAnnouncementSignatures,
6068         /// Indicates that this is the only struct which contains the same pointer.
6069
6070         /// Rust functions which take ownership of an object provided via an argument require
6071         /// this to be true and invalidate the object pointed to by inner.
6072         pub is_owned: bool,
6073 }
6074
6075 impl Drop for AnnouncementSignatures {
6076         fn drop(&mut self) {
6077                 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
6078                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6079                 }
6080         }
6081 }
6082 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
6083 #[no_mangle]
6084 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
6085 #[allow(unused)]
6086 /// Used only if an object of this type is returned as a trait impl by a method
6087 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
6088         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
6089 }
6090 #[allow(unused)]
6091 impl AnnouncementSignatures {
6092         pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
6093                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6094         }
6095         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
6096                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6097         }
6098         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6099         pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
6100                 assert!(self.is_owned);
6101                 let ret = ObjOps::untweak_ptr(self.inner);
6102                 self.inner = core::ptr::null_mut();
6103                 ret
6104         }
6105 }
6106 /// The channel ID
6107 #[no_mangle]
6108 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> crate::lightning::ln::types::ChannelId {
6109         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
6110         crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
6111 }
6112 /// The channel ID
6113 #[no_mangle]
6114 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::lightning::ln::types::ChannelId) {
6115         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
6116 }
6117 /// The short channel ID
6118 #[no_mangle]
6119 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
6120         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6121         *inner_val
6122 }
6123 /// The short channel ID
6124 #[no_mangle]
6125 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
6126         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6127 }
6128 /// A signature by the node key
6129 #[no_mangle]
6130 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
6131         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
6132         crate::c_types::ECDSASignature::from_rust(&inner_val)
6133 }
6134 /// A signature by the node key
6135 #[no_mangle]
6136 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
6137         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
6138 }
6139 /// A signature by the funding key
6140 #[no_mangle]
6141 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
6142         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
6143         crate::c_types::ECDSASignature::from_rust(&inner_val)
6144 }
6145 /// A signature by the funding key
6146 #[no_mangle]
6147 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
6148         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
6149 }
6150 /// Constructs a new AnnouncementSignatures given each field
6151 #[must_use]
6152 #[no_mangle]
6153 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_arg: crate::c_types::ECDSASignature) -> AnnouncementSignatures {
6154         AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
6155                 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
6156                 short_channel_id: short_channel_id_arg,
6157                 node_signature: node_signature_arg.into_rust(),
6158                 bitcoin_signature: bitcoin_signature_arg.into_rust(),
6159         }), is_owned: true }
6160 }
6161 impl Clone for AnnouncementSignatures {
6162         fn clone(&self) -> Self {
6163                 Self {
6164                         inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
6165                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6166                         is_owned: true,
6167                 }
6168         }
6169 }
6170 #[allow(unused)]
6171 /// Used only if an object of this type is returned as a trait impl by a method
6172 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
6173         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAnnouncementSignatures)).clone() })) as *mut c_void
6174 }
6175 #[no_mangle]
6176 /// Creates a copy of the AnnouncementSignatures
6177 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
6178         orig.clone()
6179 }
6180 /// Get a string which allows debug introspection of a AnnouncementSignatures object
6181 pub extern "C" fn AnnouncementSignatures_debug_str_void(o: *const c_void) -> Str {
6182         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AnnouncementSignatures }).into()}
6183 /// Generates a non-cryptographic 64-bit hash of the AnnouncementSignatures.
6184 #[no_mangle]
6185 pub extern "C" fn AnnouncementSignatures_hash(o: &AnnouncementSignatures) -> u64 {
6186         if o.inner.is_null() { return 0; }
6187         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6188         #[allow(deprecated)]
6189         let mut hasher = core::hash::SipHasher::new();
6190         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6191         core::hash::Hasher::finish(&hasher)
6192 }
6193 /// Checks if two AnnouncementSignaturess contain equal inner contents.
6194 /// This ignores pointers and is_owned flags and looks at the values in fields.
6195 /// Two objects with NULL inner values will be considered "equal" here.
6196 #[no_mangle]
6197 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
6198         if a.inner == b.inner { return true; }
6199         if a.inner.is_null() || b.inner.is_null() { return false; }
6200         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6201 }
6202 /// An address which can be used to connect to a remote peer.
6203 #[derive(Clone)]
6204 #[must_use]
6205 #[repr(C)]
6206 pub enum SocketAddress {
6207         /// An IPv4 address and port on which the peer is listening.
6208         TcpIpV4 {
6209                 /// The 4-byte IPv4 address
6210                 addr: crate::c_types::FourBytes,
6211                 /// The port on which the node is listening
6212                 port: u16,
6213         },
6214         /// An IPv6 address and port on which the peer is listening.
6215         TcpIpV6 {
6216                 /// The 16-byte IPv6 address
6217                 addr: crate::c_types::SixteenBytes,
6218                 /// The port on which the node is listening
6219                 port: u16,
6220         },
6221         /// An old-style Tor onion address/port on which the peer is listening.
6222         ///
6223         /// This field is deprecated and the Tor network generally no longer supports V2 Onion
6224         /// addresses. Thus, the details are not parsed here.
6225         OnionV2(
6226                 crate::c_types::TwelveBytes),
6227         /// A new-style Tor onion address/port on which the peer is listening.
6228         ///
6229         /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
6230         /// wrap as base32 and append \".onion\".
6231         OnionV3 {
6232                 /// The ed25519 long-term public key of the peer
6233                 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
6234                 /// The checksum of the pubkey and version, as included in the onion address
6235                 checksum: u16,
6236                 /// The version byte, as defined by the Tor Onion v3 spec.
6237                 version: u8,
6238                 /// The port on which the node is listening
6239                 port: u16,
6240         },
6241         /// A hostname/port on which the peer is listening.
6242         Hostname {
6243                 /// The hostname on which the node is listening.
6244                 hostname: crate::lightning::util::ser::Hostname,
6245                 /// The port on which the node is listening.
6246                 port: u16,
6247         },
6248 }
6249 use lightning::ln::msgs::SocketAddress as SocketAddressImport;
6250 pub(crate) type nativeSocketAddress = SocketAddressImport;
6251
6252 impl SocketAddress {
6253         #[allow(unused)]
6254         pub(crate) fn to_native(&self) -> nativeSocketAddress {
6255                 match self {
6256                         SocketAddress::TcpIpV4 {ref addr, ref port, } => {
6257                                 let mut addr_nonref = Clone::clone(addr);
6258                                 let mut port_nonref = Clone::clone(port);
6259                                 nativeSocketAddress::TcpIpV4 {
6260                                         addr: addr_nonref.data,
6261                                         port: port_nonref,
6262                                 }
6263                         },
6264                         SocketAddress::TcpIpV6 {ref addr, ref port, } => {
6265                                 let mut addr_nonref = Clone::clone(addr);
6266                                 let mut port_nonref = Clone::clone(port);
6267                                 nativeSocketAddress::TcpIpV6 {
6268                                         addr: addr_nonref.data,
6269                                         port: port_nonref,
6270                                 }
6271                         },
6272                         SocketAddress::OnionV2 (ref a, ) => {
6273                                 let mut a_nonref = Clone::clone(a);
6274                                 nativeSocketAddress::OnionV2 (
6275                                         a_nonref.data,
6276                                 )
6277                         },
6278                         SocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
6279                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
6280                                 let mut checksum_nonref = Clone::clone(checksum);
6281                                 let mut version_nonref = Clone::clone(version);
6282                                 let mut port_nonref = Clone::clone(port);
6283                                 nativeSocketAddress::OnionV3 {
6284                                         ed25519_pubkey: ed25519_pubkey_nonref.data,
6285                                         checksum: checksum_nonref,
6286                                         version: version_nonref,
6287                                         port: port_nonref,
6288                                 }
6289                         },
6290                         SocketAddress::Hostname {ref hostname, ref port, } => {
6291                                 let mut hostname_nonref = Clone::clone(hostname);
6292                                 let mut port_nonref = Clone::clone(port);
6293                                 nativeSocketAddress::Hostname {
6294                                         hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
6295                                         port: port_nonref,
6296                                 }
6297                         },
6298                 }
6299         }
6300         #[allow(unused)]
6301         pub(crate) fn into_native(self) -> nativeSocketAddress {
6302                 match self {
6303                         SocketAddress::TcpIpV4 {mut addr, mut port, } => {
6304                                 nativeSocketAddress::TcpIpV4 {
6305                                         addr: addr.data,
6306                                         port: port,
6307                                 }
6308                         },
6309                         SocketAddress::TcpIpV6 {mut addr, mut port, } => {
6310                                 nativeSocketAddress::TcpIpV6 {
6311                                         addr: addr.data,
6312                                         port: port,
6313                                 }
6314                         },
6315                         SocketAddress::OnionV2 (mut a, ) => {
6316                                 nativeSocketAddress::OnionV2 (
6317                                         a.data,
6318                                 )
6319                         },
6320                         SocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
6321                                 nativeSocketAddress::OnionV3 {
6322                                         ed25519_pubkey: ed25519_pubkey.data,
6323                                         checksum: checksum,
6324                                         version: version,
6325                                         port: port,
6326                                 }
6327                         },
6328                         SocketAddress::Hostname {mut hostname, mut port, } => {
6329                                 nativeSocketAddress::Hostname {
6330                                         hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
6331                                         port: port,
6332                                 }
6333                         },
6334                 }
6335         }
6336         #[allow(unused)]
6337         pub(crate) fn from_native(native: &SocketAddressImport) -> Self {
6338                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSocketAddress) };
6339                 match native {
6340                         nativeSocketAddress::TcpIpV4 {ref addr, ref port, } => {
6341                                 let mut addr_nonref = Clone::clone(addr);
6342                                 let mut port_nonref = Clone::clone(port);
6343                                 SocketAddress::TcpIpV4 {
6344                                         addr: crate::c_types::FourBytes { data: addr_nonref },
6345                                         port: port_nonref,
6346                                 }
6347                         },
6348                         nativeSocketAddress::TcpIpV6 {ref addr, ref port, } => {
6349                                 let mut addr_nonref = Clone::clone(addr);
6350                                 let mut port_nonref = Clone::clone(port);
6351                                 SocketAddress::TcpIpV6 {
6352                                         addr: crate::c_types::SixteenBytes { data: addr_nonref },
6353                                         port: port_nonref,
6354                                 }
6355                         },
6356                         nativeSocketAddress::OnionV2 (ref a, ) => {
6357                                 let mut a_nonref = Clone::clone(a);
6358                                 SocketAddress::OnionV2 (
6359                                         crate::c_types::TwelveBytes { data: a_nonref },
6360                                 )
6361                         },
6362                         nativeSocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
6363                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
6364                                 let mut checksum_nonref = Clone::clone(checksum);
6365                                 let mut version_nonref = Clone::clone(version);
6366                                 let mut port_nonref = Clone::clone(port);
6367                                 SocketAddress::OnionV3 {
6368                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
6369                                         checksum: checksum_nonref,
6370                                         version: version_nonref,
6371                                         port: port_nonref,
6372                                 }
6373                         },
6374                         nativeSocketAddress::Hostname {ref hostname, ref port, } => {
6375                                 let mut hostname_nonref = Clone::clone(hostname);
6376                                 let mut port_nonref = Clone::clone(port);
6377                                 SocketAddress::Hostname {
6378                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
6379                                         port: port_nonref,
6380                                 }
6381                         },
6382                 }
6383         }
6384         #[allow(unused)]
6385         pub(crate) fn native_into(native: nativeSocketAddress) -> Self {
6386                 match native {
6387                         nativeSocketAddress::TcpIpV4 {mut addr, mut port, } => {
6388                                 SocketAddress::TcpIpV4 {
6389                                         addr: crate::c_types::FourBytes { data: addr },
6390                                         port: port,
6391                                 }
6392                         },
6393                         nativeSocketAddress::TcpIpV6 {mut addr, mut port, } => {
6394                                 SocketAddress::TcpIpV6 {
6395                                         addr: crate::c_types::SixteenBytes { data: addr },
6396                                         port: port,
6397                                 }
6398                         },
6399                         nativeSocketAddress::OnionV2 (mut a, ) => {
6400                                 SocketAddress::OnionV2 (
6401                                         crate::c_types::TwelveBytes { data: a },
6402                                 )
6403                         },
6404                         nativeSocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
6405                                 SocketAddress::OnionV3 {
6406                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
6407                                         checksum: checksum,
6408                                         version: version,
6409                                         port: port,
6410                                 }
6411                         },
6412                         nativeSocketAddress::Hostname {mut hostname, mut port, } => {
6413                                 SocketAddress::Hostname {
6414                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
6415                                         port: port,
6416                                 }
6417                         },
6418                 }
6419         }
6420 }
6421 /// Frees any resources used by the SocketAddress
6422 #[no_mangle]
6423 pub extern "C" fn SocketAddress_free(this_ptr: SocketAddress) { }
6424 /// Creates a copy of the SocketAddress
6425 #[no_mangle]
6426 pub extern "C" fn SocketAddress_clone(orig: &SocketAddress) -> SocketAddress {
6427         orig.clone()
6428 }
6429 #[allow(unused)]
6430 /// Used only if an object of this type is returned as a trait impl by a method
6431 pub(crate) extern "C" fn SocketAddress_clone_void(this_ptr: *const c_void) -> *mut c_void {
6432         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddress)).clone() })) as *mut c_void
6433 }
6434 #[allow(unused)]
6435 /// Used only if an object of this type is returned as a trait impl by a method
6436 pub(crate) extern "C" fn SocketAddress_free_void(this_ptr: *mut c_void) {
6437         let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddress) };
6438 }
6439 #[no_mangle]
6440 /// Utility method to constructs a new TcpIpV4-variant SocketAddress
6441 pub extern "C" fn SocketAddress_tcp_ip_v4(addr: crate::c_types::FourBytes, port: u16) -> SocketAddress {
6442         SocketAddress::TcpIpV4 {
6443                 addr,
6444                 port,
6445         }
6446 }
6447 #[no_mangle]
6448 /// Utility method to constructs a new TcpIpV6-variant SocketAddress
6449 pub extern "C" fn SocketAddress_tcp_ip_v6(addr: crate::c_types::SixteenBytes, port: u16) -> SocketAddress {
6450         SocketAddress::TcpIpV6 {
6451                 addr,
6452                 port,
6453         }
6454 }
6455 #[no_mangle]
6456 /// Utility method to constructs a new OnionV2-variant SocketAddress
6457 pub extern "C" fn SocketAddress_onion_v2(a: crate::c_types::TwelveBytes) -> SocketAddress {
6458         SocketAddress::OnionV2(a, )
6459 }
6460 #[no_mangle]
6461 /// Utility method to constructs a new OnionV3-variant SocketAddress
6462 pub extern "C" fn SocketAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> SocketAddress {
6463         SocketAddress::OnionV3 {
6464                 ed25519_pubkey,
6465                 checksum,
6466                 version,
6467                 port,
6468         }
6469 }
6470 #[no_mangle]
6471 /// Utility method to constructs a new Hostname-variant SocketAddress
6472 pub extern "C" fn SocketAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> SocketAddress {
6473         SocketAddress::Hostname {
6474                 hostname,
6475                 port,
6476         }
6477 }
6478 /// Get a string which allows debug introspection of a SocketAddress object
6479 pub extern "C" fn SocketAddress_debug_str_void(o: *const c_void) -> Str {
6480         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SocketAddress }).into()}
6481 /// Generates a non-cryptographic 64-bit hash of the SocketAddress.
6482 #[no_mangle]
6483 pub extern "C" fn SocketAddress_hash(o: &SocketAddress) -> u64 {
6484         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6485         #[allow(deprecated)]
6486         let mut hasher = core::hash::SipHasher::new();
6487         core::hash::Hash::hash(&o.to_native(), &mut hasher);
6488         core::hash::Hasher::finish(&hasher)
6489 }
6490 /// Checks if two SocketAddresss contain equal inner contents.
6491 /// This ignores pointers and is_owned flags and looks at the values in fields.
6492 #[no_mangle]
6493 pub extern "C" fn SocketAddress_eq(a: &SocketAddress, b: &SocketAddress) -> bool {
6494         if &a.to_native() == &b.to_native() { true } else { false }
6495 }
6496 #[no_mangle]
6497 /// Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read
6498 pub extern "C" fn SocketAddress_write(obj: &crate::lightning::ln::msgs::SocketAddress) -> crate::c_types::derived::CVec_u8Z {
6499         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6500 }
6501 #[allow(unused)]
6502 pub(crate) extern "C" fn SocketAddress_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6503         SocketAddress_write(unsafe { &*(obj as *const SocketAddress) })
6504 }
6505 #[no_mangle]
6506 /// Read a SocketAddress from a byte array, created by SocketAddress_write
6507 pub extern "C" fn SocketAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SocketAddressDecodeErrorZ {
6508         let res: Result<lightning::ln::msgs::SocketAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6509         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() };
6510         local_res
6511 }
6512 /// [`SocketAddress`] error variants
6513 #[derive(Clone)]
6514 #[must_use]
6515 #[repr(C)]
6516 pub enum SocketAddressParseError {
6517         /// Socket address (IPv4/IPv6) parsing error
6518         SocketAddrParse,
6519         /// Invalid input format
6520         InvalidInput,
6521         /// Invalid port
6522         InvalidPort,
6523         /// Invalid onion v3 address
6524         InvalidOnionV3,
6525 }
6526 use lightning::ln::msgs::SocketAddressParseError as SocketAddressParseErrorImport;
6527 pub(crate) type nativeSocketAddressParseError = SocketAddressParseErrorImport;
6528
6529 impl SocketAddressParseError {
6530         #[allow(unused)]
6531         pub(crate) fn to_native(&self) -> nativeSocketAddressParseError {
6532                 match self {
6533                         SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
6534                         SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
6535                         SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
6536                         SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
6537                 }
6538         }
6539         #[allow(unused)]
6540         pub(crate) fn into_native(self) -> nativeSocketAddressParseError {
6541                 match self {
6542                         SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
6543                         SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
6544                         SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
6545                         SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
6546                 }
6547         }
6548         #[allow(unused)]
6549         pub(crate) fn from_native(native: &SocketAddressParseErrorImport) -> Self {
6550                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSocketAddressParseError) };
6551                 match native {
6552                         nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
6553                         nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
6554                         nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
6555                         nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
6556                 }
6557         }
6558         #[allow(unused)]
6559         pub(crate) fn native_into(native: nativeSocketAddressParseError) -> Self {
6560                 match native {
6561                         nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
6562                         nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
6563                         nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
6564                         nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
6565                 }
6566         }
6567 }
6568 /// Creates a copy of the SocketAddressParseError
6569 #[no_mangle]
6570 pub extern "C" fn SocketAddressParseError_clone(orig: &SocketAddressParseError) -> SocketAddressParseError {
6571         orig.clone()
6572 }
6573 #[allow(unused)]
6574 /// Used only if an object of this type is returned as a trait impl by a method
6575 pub(crate) extern "C" fn SocketAddressParseError_clone_void(this_ptr: *const c_void) -> *mut c_void {
6576         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddressParseError)).clone() })) as *mut c_void
6577 }
6578 #[allow(unused)]
6579 /// Used only if an object of this type is returned as a trait impl by a method
6580 pub(crate) extern "C" fn SocketAddressParseError_free_void(this_ptr: *mut c_void) {
6581         let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddressParseError) };
6582 }
6583 #[no_mangle]
6584 /// Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError
6585 pub extern "C" fn SocketAddressParseError_socket_addr_parse() -> SocketAddressParseError {
6586         SocketAddressParseError::SocketAddrParse}
6587 #[no_mangle]
6588 /// Utility method to constructs a new InvalidInput-variant SocketAddressParseError
6589 pub extern "C" fn SocketAddressParseError_invalid_input() -> SocketAddressParseError {
6590         SocketAddressParseError::InvalidInput}
6591 #[no_mangle]
6592 /// Utility method to constructs a new InvalidPort-variant SocketAddressParseError
6593 pub extern "C" fn SocketAddressParseError_invalid_port() -> SocketAddressParseError {
6594         SocketAddressParseError::InvalidPort}
6595 #[no_mangle]
6596 /// Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError
6597 pub extern "C" fn SocketAddressParseError_invalid_onion_v3() -> SocketAddressParseError {
6598         SocketAddressParseError::InvalidOnionV3}
6599 /// Get a string which allows debug introspection of a SocketAddressParseError object
6600 pub extern "C" fn SocketAddressParseError_debug_str_void(o: *const c_void) -> Str {
6601         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SocketAddressParseError }).into()}
6602 /// Generates a non-cryptographic 64-bit hash of the SocketAddressParseError.
6603 #[no_mangle]
6604 pub extern "C" fn SocketAddressParseError_hash(o: &SocketAddressParseError) -> u64 {
6605         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6606         #[allow(deprecated)]
6607         let mut hasher = core::hash::SipHasher::new();
6608         core::hash::Hash::hash(&o.to_native(), &mut hasher);
6609         core::hash::Hasher::finish(&hasher)
6610 }
6611 /// Checks if two SocketAddressParseErrors contain equal inner contents.
6612 /// This ignores pointers and is_owned flags and looks at the values in fields.
6613 #[no_mangle]
6614 pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool {
6615         if &a.to_native() == &b.to_native() { true } else { false }
6616 }
6617 #[no_mangle]
6618 /// Get the string representation of a SocketAddressParseError object
6619 pub extern "C" fn SocketAddressParseError_to_str(o: &crate::lightning::ln::msgs::SocketAddressParseError) -> Str {
6620         alloc::format!("{}", &o.to_native()).into()
6621 }
6622 /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
6623 ///
6624 /// The host part must end with \".onion\".
6625 #[no_mangle]
6626 pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6627         let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
6628         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() };
6629         local_ret
6630 }
6631
6632 #[no_mangle]
6633 /// Get the string representation of a SocketAddress object
6634 pub extern "C" fn SocketAddress_to_str(o: &crate::lightning::ln::msgs::SocketAddress) -> Str {
6635         alloc::format!("{}", &o.to_native()).into()
6636 }
6637 #[no_mangle]
6638 /// Read a SocketAddress object from a string
6639 pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6640         match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
6641                 Ok(r) => {
6642                         crate::c_types::CResultTempl::ok(
6643                                 crate::lightning::ln::msgs::SocketAddress::native_into(r)
6644                         )
6645                 },
6646                 Err(e) => {
6647                         crate::c_types::CResultTempl::err(
6648                                 crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
6649                         )
6650                 },
6651         }.into()
6652 }
6653 /// Represents the set of gossip messages that require a signature from a node's identity key.
6654 #[derive(Clone)]
6655 #[must_use]
6656 #[repr(C)]
6657 pub enum UnsignedGossipMessage {
6658         /// An unsigned channel announcement.
6659         ChannelAnnouncement(
6660                 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
6661         /// An unsigned channel update.
6662         ChannelUpdate(
6663                 crate::lightning::ln::msgs::UnsignedChannelUpdate),
6664         /// An unsigned node announcement.
6665         NodeAnnouncement(
6666                 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
6667 }
6668 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
6669 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
6670
6671 impl UnsignedGossipMessage {
6672         #[allow(unused)]
6673         pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
6674                 match self {
6675                         UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6676                                 let mut a_nonref = Clone::clone(a);
6677                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
6678                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
6679                                 )
6680                         },
6681                         UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6682                                 let mut a_nonref = Clone::clone(a);
6683                                 nativeUnsignedGossipMessage::ChannelUpdate (
6684                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
6685                                 )
6686                         },
6687                         UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6688                                 let mut a_nonref = Clone::clone(a);
6689                                 nativeUnsignedGossipMessage::NodeAnnouncement (
6690                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
6691                                 )
6692                         },
6693                 }
6694         }
6695         #[allow(unused)]
6696         pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
6697                 match self {
6698                         UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6699                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
6700                                         *unsafe { Box::from_raw(a.take_inner()) },
6701                                 )
6702                         },
6703                         UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6704                                 nativeUnsignedGossipMessage::ChannelUpdate (
6705                                         *unsafe { Box::from_raw(a.take_inner()) },
6706                                 )
6707                         },
6708                         UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6709                                 nativeUnsignedGossipMessage::NodeAnnouncement (
6710                                         *unsafe { Box::from_raw(a.take_inner()) },
6711                                 )
6712                         },
6713                 }
6714         }
6715         #[allow(unused)]
6716         pub(crate) fn from_native(native: &UnsignedGossipMessageImport) -> Self {
6717                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeUnsignedGossipMessage) };
6718                 match native {
6719                         nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6720                                 let mut a_nonref = Clone::clone(a);
6721                                 UnsignedGossipMessage::ChannelAnnouncement (
6722                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6723                                 )
6724                         },
6725                         nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6726                                 let mut a_nonref = Clone::clone(a);
6727                                 UnsignedGossipMessage::ChannelUpdate (
6728                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6729                                 )
6730                         },
6731                         nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6732                                 let mut a_nonref = Clone::clone(a);
6733                                 UnsignedGossipMessage::NodeAnnouncement (
6734                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6735                                 )
6736                         },
6737                 }
6738         }
6739         #[allow(unused)]
6740         pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
6741                 match native {
6742                         nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6743                                 UnsignedGossipMessage::ChannelAnnouncement (
6744                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6745                                 )
6746                         },
6747                         nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6748                                 UnsignedGossipMessage::ChannelUpdate (
6749                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
6750                                 )
6751                         },
6752                         nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6753                                 UnsignedGossipMessage::NodeAnnouncement (
6754                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6755                                 )
6756                         },
6757                 }
6758         }
6759 }
6760 /// Frees any resources used by the UnsignedGossipMessage
6761 #[no_mangle]
6762 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
6763 /// Creates a copy of the UnsignedGossipMessage
6764 #[no_mangle]
6765 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
6766         orig.clone()
6767 }
6768 #[allow(unused)]
6769 /// Used only if an object of this type is returned as a trait impl by a method
6770 pub(crate) extern "C" fn UnsignedGossipMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
6771         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const UnsignedGossipMessage)).clone() })) as *mut c_void
6772 }
6773 #[allow(unused)]
6774 /// Used only if an object of this type is returned as a trait impl by a method
6775 pub(crate) extern "C" fn UnsignedGossipMessage_free_void(this_ptr: *mut c_void) {
6776         let _ = unsafe { Box::from_raw(this_ptr as *mut UnsignedGossipMessage) };
6777 }
6778 #[no_mangle]
6779 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
6780 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
6781         UnsignedGossipMessage::ChannelAnnouncement(a, )
6782 }
6783 #[no_mangle]
6784 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
6785 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
6786         UnsignedGossipMessage::ChannelUpdate(a, )
6787 }
6788 #[no_mangle]
6789 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
6790 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
6791         UnsignedGossipMessage::NodeAnnouncement(a, )
6792 }
6793 #[no_mangle]
6794 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
6795 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
6796         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6797 }
6798 #[allow(unused)]
6799 pub(crate) extern "C" fn UnsignedGossipMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6800         UnsignedGossipMessage_write(unsafe { &*(obj as *const UnsignedGossipMessage) })
6801 }
6802
6803 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
6804 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
6805
6806 /// The unsigned part of a [`node_announcement`] message.
6807 ///
6808 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
6809 #[must_use]
6810 #[repr(C)]
6811 pub struct UnsignedNodeAnnouncement {
6812         /// A pointer to the opaque Rust object.
6813
6814         /// Nearly everywhere, inner must be non-null, however in places where
6815         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6816         pub inner: *mut nativeUnsignedNodeAnnouncement,
6817         /// Indicates that this is the only struct which contains the same pointer.
6818
6819         /// Rust functions which take ownership of an object provided via an argument require
6820         /// this to be true and invalidate the object pointed to by inner.
6821         pub is_owned: bool,
6822 }
6823
6824 impl Drop for UnsignedNodeAnnouncement {
6825         fn drop(&mut self) {
6826                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
6827                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6828                 }
6829         }
6830 }
6831 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
6832 #[no_mangle]
6833 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
6834 #[allow(unused)]
6835 /// Used only if an object of this type is returned as a trait impl by a method
6836 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
6837         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
6838 }
6839 #[allow(unused)]
6840 impl UnsignedNodeAnnouncement {
6841         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
6842                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6843         }
6844         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
6845                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6846         }
6847         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6848         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
6849                 assert!(self.is_owned);
6850                 let ret = ObjOps::untweak_ptr(self.inner);
6851                 self.inner = core::ptr::null_mut();
6852                 ret
6853         }
6854 }
6855 /// The advertised features
6856 #[no_mangle]
6857 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
6858         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6859         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 }
6860 }
6861 /// The advertised features
6862 #[no_mangle]
6863 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
6864         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
6865 }
6866 /// A strictly monotonic announcement counter, with gaps allowed
6867 #[no_mangle]
6868 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
6869         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
6870         *inner_val
6871 }
6872 /// A strictly monotonic announcement counter, with gaps allowed
6873 #[no_mangle]
6874 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
6875         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
6876 }
6877 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
6878 /// to this node).
6879 #[no_mangle]
6880 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6881         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
6882         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 }
6883 }
6884 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
6885 /// to this node).
6886 #[no_mangle]
6887 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6888         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
6889 }
6890 /// An RGB color for UI purposes
6891 #[no_mangle]
6892 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
6893         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
6894         inner_val
6895 }
6896 /// An RGB color for UI purposes
6897 #[no_mangle]
6898 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
6899         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
6900 }
6901 /// An alias, for UI purposes.
6902 ///
6903 /// This should be sanitized before use. There is no guarantee of uniqueness.
6904 #[no_mangle]
6905 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
6906         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
6907         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 }
6908 }
6909 /// An alias, for UI purposes.
6910 ///
6911 /// This should be sanitized before use. There is no guarantee of uniqueness.
6912 #[no_mangle]
6913 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
6914         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
6915 }
6916 /// List of addresses on which this node is reachable
6917 ///
6918 /// Returns a copy of the field.
6919 #[no_mangle]
6920 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
6921         let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
6922         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) }); };
6923         local_inner_val.into()
6924 }
6925 /// List of addresses on which this node is reachable
6926 #[no_mangle]
6927 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
6928         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
6929         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
6930 }
6931 /// Excess address data which was signed as a part of the message which we do not (yet) understand how
6932 /// to decode.
6933 ///
6934 /// This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol.
6935 ///
6936 /// Returns a copy of the field.
6937 #[no_mangle]
6938 pub extern "C" fn UnsignedNodeAnnouncement_get_excess_address_data(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6939         let mut inner_val = this_ptr.get_native_mut_ref().excess_address_data.clone();
6940         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6941         local_inner_val.into()
6942 }
6943 /// Excess address data which was signed as a part of the message which we do not (yet) understand how
6944 /// to decode.
6945 ///
6946 /// This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol.
6947 #[no_mangle]
6948 pub extern "C" fn UnsignedNodeAnnouncement_set_excess_address_data(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6949         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6950         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_address_data = local_val;
6951 }
6952 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6953 /// to decode.
6954 ///
6955 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6956 ///
6957 /// Returns a copy of the field.
6958 #[no_mangle]
6959 pub extern "C" fn UnsignedNodeAnnouncement_get_excess_data(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6960         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6961         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6962         local_inner_val.into()
6963 }
6964 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6965 /// to decode.
6966 ///
6967 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6968 #[no_mangle]
6969 pub extern "C" fn UnsignedNodeAnnouncement_set_excess_data(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6970         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6971         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6972 }
6973 /// Constructs a new UnsignedNodeAnnouncement given each field
6974 #[must_use]
6975 #[no_mangle]
6976 pub extern "C" fn UnsignedNodeAnnouncement_new(mut features_arg: crate::lightning::ln::features::NodeFeatures, mut timestamp_arg: u32, mut node_id_arg: crate::lightning::routing::gossip::NodeId, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut addresses_arg: crate::c_types::derived::CVec_SocketAddressZ, mut excess_address_data_arg: crate::c_types::derived::CVec_u8Z, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedNodeAnnouncement {
6977         let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
6978         let mut local_excess_address_data_arg = Vec::new(); for mut item in excess_address_data_arg.into_rust().drain(..) { local_excess_address_data_arg.push( { item }); };
6979         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6980         UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedNodeAnnouncement {
6981                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
6982                 timestamp: timestamp_arg,
6983                 node_id: *unsafe { Box::from_raw(node_id_arg.take_inner()) },
6984                 rgb: rgb_arg.data,
6985                 alias: *unsafe { Box::from_raw(alias_arg.take_inner()) },
6986                 addresses: local_addresses_arg,
6987                 excess_address_data: local_excess_address_data_arg,
6988                 excess_data: local_excess_data_arg,
6989         }), is_owned: true }
6990 }
6991 impl Clone for UnsignedNodeAnnouncement {
6992         fn clone(&self) -> Self {
6993                 Self {
6994                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6995                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6996                         is_owned: true,
6997                 }
6998         }
6999 }
7000 #[allow(unused)]
7001 /// Used only if an object of this type is returned as a trait impl by a method
7002 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7003         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
7004 }
7005 #[no_mangle]
7006 /// Creates a copy of the UnsignedNodeAnnouncement
7007 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
7008         orig.clone()
7009 }
7010 /// Get a string which allows debug introspection of a UnsignedNodeAnnouncement object
7011 pub extern "C" fn UnsignedNodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7012         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedNodeAnnouncement }).into()}
7013 /// Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement.
7014 #[no_mangle]
7015 pub extern "C" fn UnsignedNodeAnnouncement_hash(o: &UnsignedNodeAnnouncement) -> u64 {
7016         if o.inner.is_null() { return 0; }
7017         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7018         #[allow(deprecated)]
7019         let mut hasher = core::hash::SipHasher::new();
7020         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7021         core::hash::Hasher::finish(&hasher)
7022 }
7023 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
7024 /// This ignores pointers and is_owned flags and looks at the values in fields.
7025 /// Two objects with NULL inner values will be considered "equal" here.
7026 #[no_mangle]
7027 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
7028         if a.inner == b.inner { return true; }
7029         if a.inner.is_null() || b.inner.is_null() { return false; }
7030         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7031 }
7032
7033 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
7034 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
7035
7036 /// A [`node_announcement`] message to be sent to or received from a peer.
7037 ///
7038 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
7039 #[must_use]
7040 #[repr(C)]
7041 pub struct NodeAnnouncement {
7042         /// A pointer to the opaque Rust object.
7043
7044         /// Nearly everywhere, inner must be non-null, however in places where
7045         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7046         pub inner: *mut nativeNodeAnnouncement,
7047         /// Indicates that this is the only struct which contains the same pointer.
7048
7049         /// Rust functions which take ownership of an object provided via an argument require
7050         /// this to be true and invalidate the object pointed to by inner.
7051         pub is_owned: bool,
7052 }
7053
7054 impl Drop for NodeAnnouncement {
7055         fn drop(&mut self) {
7056                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
7057                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7058                 }
7059         }
7060 }
7061 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
7062 #[no_mangle]
7063 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
7064 #[allow(unused)]
7065 /// Used only if an object of this type is returned as a trait impl by a method
7066 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
7067         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
7068 }
7069 #[allow(unused)]
7070 impl NodeAnnouncement {
7071         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
7072                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7073         }
7074         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
7075                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7076         }
7077         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7078         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
7079                 assert!(self.is_owned);
7080                 let ret = ObjOps::untweak_ptr(self.inner);
7081                 self.inner = core::ptr::null_mut();
7082                 ret
7083         }
7084 }
7085 /// The signature by the node key
7086 #[no_mangle]
7087 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
7088         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7089         crate::c_types::ECDSASignature::from_rust(&inner_val)
7090 }
7091 /// The signature by the node key
7092 #[no_mangle]
7093 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
7094         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7095 }
7096 /// The actual content of the announcement
7097 #[no_mangle]
7098 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
7099         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7100         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 }
7101 }
7102 /// The actual content of the announcement
7103 #[no_mangle]
7104 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
7105         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7106 }
7107 /// Constructs a new NodeAnnouncement given each field
7108 #[must_use]
7109 #[no_mangle]
7110 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
7111         NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
7112                 signature: signature_arg.into_rust(),
7113                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7114         }), is_owned: true }
7115 }
7116 impl Clone for NodeAnnouncement {
7117         fn clone(&self) -> Self {
7118                 Self {
7119                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7120                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7121                         is_owned: true,
7122                 }
7123         }
7124 }
7125 #[allow(unused)]
7126 /// Used only if an object of this type is returned as a trait impl by a method
7127 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7128         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncement)).clone() })) as *mut c_void
7129 }
7130 #[no_mangle]
7131 /// Creates a copy of the NodeAnnouncement
7132 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
7133         orig.clone()
7134 }
7135 /// Get a string which allows debug introspection of a NodeAnnouncement object
7136 pub extern "C" fn NodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7137         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::NodeAnnouncement }).into()}
7138 /// Generates a non-cryptographic 64-bit hash of the NodeAnnouncement.
7139 #[no_mangle]
7140 pub extern "C" fn NodeAnnouncement_hash(o: &NodeAnnouncement) -> u64 {
7141         if o.inner.is_null() { return 0; }
7142         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7143         #[allow(deprecated)]
7144         let mut hasher = core::hash::SipHasher::new();
7145         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7146         core::hash::Hasher::finish(&hasher)
7147 }
7148 /// Checks if two NodeAnnouncements contain equal inner contents.
7149 /// This ignores pointers and is_owned flags and looks at the values in fields.
7150 /// Two objects with NULL inner values will be considered "equal" here.
7151 #[no_mangle]
7152 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
7153         if a.inner == b.inner { return true; }
7154         if a.inner.is_null() || b.inner.is_null() { return false; }
7155         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7156 }
7157
7158 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
7159 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
7160
7161 /// The unsigned part of a [`channel_announcement`] message.
7162 ///
7163 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7164 #[must_use]
7165 #[repr(C)]
7166 pub struct UnsignedChannelAnnouncement {
7167         /// A pointer to the opaque Rust object.
7168
7169         /// Nearly everywhere, inner must be non-null, however in places where
7170         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7171         pub inner: *mut nativeUnsignedChannelAnnouncement,
7172         /// Indicates that this is the only struct which contains the same pointer.
7173
7174         /// Rust functions which take ownership of an object provided via an argument require
7175         /// this to be true and invalidate the object pointed to by inner.
7176         pub is_owned: bool,
7177 }
7178
7179 impl Drop for UnsignedChannelAnnouncement {
7180         fn drop(&mut self) {
7181                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
7182                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7183                 }
7184         }
7185 }
7186 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
7187 #[no_mangle]
7188 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
7189 #[allow(unused)]
7190 /// Used only if an object of this type is returned as a trait impl by a method
7191 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7192         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
7193 }
7194 #[allow(unused)]
7195 impl UnsignedChannelAnnouncement {
7196         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
7197                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7198         }
7199         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
7200                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7201         }
7202         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7203         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
7204                 assert!(self.is_owned);
7205                 let ret = ObjOps::untweak_ptr(self.inner);
7206                 self.inner = core::ptr::null_mut();
7207                 ret
7208         }
7209 }
7210 /// The advertised channel features
7211 #[no_mangle]
7212 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
7213         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
7214         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 }
7215 }
7216 /// The advertised channel features
7217 #[no_mangle]
7218 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
7219         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
7220 }
7221 /// The genesis hash of the blockchain where the channel is to be opened
7222 #[no_mangle]
7223 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
7224         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7225         inner_val.as_ref()
7226 }
7227 /// The genesis hash of the blockchain where the channel is to be opened
7228 #[no_mangle]
7229 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
7230         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7231 }
7232 /// The short channel ID
7233 #[no_mangle]
7234 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
7235         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7236         *inner_val
7237 }
7238 /// The short channel ID
7239 #[no_mangle]
7240 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
7241         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7242 }
7243 /// One of the two `node_id`s which are endpoints of this channel
7244 #[no_mangle]
7245 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7246         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
7247         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 }
7248 }
7249 /// One of the two `node_id`s which are endpoints of this channel
7250 #[no_mangle]
7251 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7252         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
7253 }
7254 /// The other of the two `node_id`s which are endpoints of this channel
7255 #[no_mangle]
7256 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7257         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
7258         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 }
7259 }
7260 /// The other of the two `node_id`s which are endpoints of this channel
7261 #[no_mangle]
7262 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7263         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
7264 }
7265 /// The funding key for the first node
7266 #[no_mangle]
7267 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7268         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
7269         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 }
7270 }
7271 /// The funding key for the first node
7272 #[no_mangle]
7273 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7274         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
7275 }
7276 /// The funding key for the second node
7277 #[no_mangle]
7278 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7279         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
7280         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 }
7281 }
7282 /// The funding key for the second node
7283 #[no_mangle]
7284 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7285         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
7286 }
7287 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7288 /// to decode.
7289 ///
7290 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7291 ///
7292 /// Returns a copy of the field.
7293 #[no_mangle]
7294 pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
7295         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7296         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7297         local_inner_val.into()
7298 }
7299 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7300 /// to decode.
7301 ///
7302 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7303 #[no_mangle]
7304 pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
7305         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7306         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7307 }
7308 /// Constructs a new UnsignedChannelAnnouncement given each field
7309 #[must_use]
7310 #[no_mangle]
7311 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 {
7312         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7313         UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
7314                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
7315                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7316                 short_channel_id: short_channel_id_arg,
7317                 node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
7318                 node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
7319                 bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
7320                 bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
7321                 excess_data: local_excess_data_arg,
7322         }), is_owned: true }
7323 }
7324 impl Clone for UnsignedChannelAnnouncement {
7325         fn clone(&self) -> Self {
7326                 Self {
7327                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7328                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7329                         is_owned: true,
7330                 }
7331         }
7332 }
7333 #[allow(unused)]
7334 /// Used only if an object of this type is returned as a trait impl by a method
7335 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7336         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
7337 }
7338 #[no_mangle]
7339 /// Creates a copy of the UnsignedChannelAnnouncement
7340 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
7341         orig.clone()
7342 }
7343 /// Get a string which allows debug introspection of a UnsignedChannelAnnouncement object
7344 pub extern "C" fn UnsignedChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7345         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelAnnouncement }).into()}
7346 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement.
7347 #[no_mangle]
7348 pub extern "C" fn UnsignedChannelAnnouncement_hash(o: &UnsignedChannelAnnouncement) -> u64 {
7349         if o.inner.is_null() { return 0; }
7350         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7351         #[allow(deprecated)]
7352         let mut hasher = core::hash::SipHasher::new();
7353         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7354         core::hash::Hasher::finish(&hasher)
7355 }
7356 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
7357 /// This ignores pointers and is_owned flags and looks at the values in fields.
7358 /// Two objects with NULL inner values will be considered "equal" here.
7359 #[no_mangle]
7360 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
7361         if a.inner == b.inner { return true; }
7362         if a.inner.is_null() || b.inner.is_null() { return false; }
7363         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7364 }
7365
7366 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
7367 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
7368
7369 /// A [`channel_announcement`] message to be sent to or received from a peer.
7370 ///
7371 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7372 #[must_use]
7373 #[repr(C)]
7374 pub struct ChannelAnnouncement {
7375         /// A pointer to the opaque Rust object.
7376
7377         /// Nearly everywhere, inner must be non-null, however in places where
7378         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7379         pub inner: *mut nativeChannelAnnouncement,
7380         /// Indicates that this is the only struct which contains the same pointer.
7381
7382         /// Rust functions which take ownership of an object provided via an argument require
7383         /// this to be true and invalidate the object pointed to by inner.
7384         pub is_owned: bool,
7385 }
7386
7387 impl Drop for ChannelAnnouncement {
7388         fn drop(&mut self) {
7389                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
7390                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7391                 }
7392         }
7393 }
7394 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
7395 #[no_mangle]
7396 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
7397 #[allow(unused)]
7398 /// Used only if an object of this type is returned as a trait impl by a method
7399 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7400         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
7401 }
7402 #[allow(unused)]
7403 impl ChannelAnnouncement {
7404         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
7405                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7406         }
7407         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
7408                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7409         }
7410         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7411         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
7412                 assert!(self.is_owned);
7413                 let ret = ObjOps::untweak_ptr(self.inner);
7414                 self.inner = core::ptr::null_mut();
7415                 ret
7416         }
7417 }
7418 /// Authentication of the announcement by the first public node
7419 #[no_mangle]
7420 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7421         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
7422         crate::c_types::ECDSASignature::from_rust(&inner_val)
7423 }
7424 /// Authentication of the announcement by the first public node
7425 #[no_mangle]
7426 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7427         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
7428 }
7429 /// Authentication of the announcement by the second public node
7430 #[no_mangle]
7431 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7432         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
7433         crate::c_types::ECDSASignature::from_rust(&inner_val)
7434 }
7435 /// Authentication of the announcement by the second public node
7436 #[no_mangle]
7437 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7438         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
7439 }
7440 /// Proof of funding UTXO ownership by the first public node
7441 #[no_mangle]
7442 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7443         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
7444         crate::c_types::ECDSASignature::from_rust(&inner_val)
7445 }
7446 /// Proof of funding UTXO ownership by the first public node
7447 #[no_mangle]
7448 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7449         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
7450 }
7451 /// Proof of funding UTXO ownership by the second public node
7452 #[no_mangle]
7453 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7454         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
7455         crate::c_types::ECDSASignature::from_rust(&inner_val)
7456 }
7457 /// Proof of funding UTXO ownership by the second public node
7458 #[no_mangle]
7459 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7460         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
7461 }
7462 /// The actual announcement
7463 #[no_mangle]
7464 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
7465         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7466         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 }
7467 }
7468 /// The actual announcement
7469 #[no_mangle]
7470 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
7471         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7472 }
7473 /// Constructs a new ChannelAnnouncement given each field
7474 #[must_use]
7475 #[no_mangle]
7476 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 {
7477         ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
7478                 node_signature_1: node_signature_1_arg.into_rust(),
7479                 node_signature_2: node_signature_2_arg.into_rust(),
7480                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
7481                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
7482                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7483         }), is_owned: true }
7484 }
7485 impl Clone for ChannelAnnouncement {
7486         fn clone(&self) -> Self {
7487                 Self {
7488                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7489                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7490                         is_owned: true,
7491                 }
7492         }
7493 }
7494 #[allow(unused)]
7495 /// Used only if an object of this type is returned as a trait impl by a method
7496 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7497         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelAnnouncement)).clone() })) as *mut c_void
7498 }
7499 #[no_mangle]
7500 /// Creates a copy of the ChannelAnnouncement
7501 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
7502         orig.clone()
7503 }
7504 /// Get a string which allows debug introspection of a ChannelAnnouncement object
7505 pub extern "C" fn ChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7506         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelAnnouncement }).into()}
7507 /// Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement.
7508 #[no_mangle]
7509 pub extern "C" fn ChannelAnnouncement_hash(o: &ChannelAnnouncement) -> u64 {
7510         if o.inner.is_null() { return 0; }
7511         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7512         #[allow(deprecated)]
7513         let mut hasher = core::hash::SipHasher::new();
7514         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7515         core::hash::Hasher::finish(&hasher)
7516 }
7517 /// Checks if two ChannelAnnouncements contain equal inner contents.
7518 /// This ignores pointers and is_owned flags and looks at the values in fields.
7519 /// Two objects with NULL inner values will be considered "equal" here.
7520 #[no_mangle]
7521 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
7522         if a.inner == b.inner { return true; }
7523         if a.inner.is_null() || b.inner.is_null() { return false; }
7524         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7525 }
7526
7527 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
7528 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
7529
7530 /// The unsigned part of a [`channel_update`] message.
7531 ///
7532 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7533 #[must_use]
7534 #[repr(C)]
7535 pub struct UnsignedChannelUpdate {
7536         /// A pointer to the opaque Rust object.
7537
7538         /// Nearly everywhere, inner must be non-null, however in places where
7539         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7540         pub inner: *mut nativeUnsignedChannelUpdate,
7541         /// Indicates that this is the only struct which contains the same pointer.
7542
7543         /// Rust functions which take ownership of an object provided via an argument require
7544         /// this to be true and invalidate the object pointed to by inner.
7545         pub is_owned: bool,
7546 }
7547
7548 impl Drop for UnsignedChannelUpdate {
7549         fn drop(&mut self) {
7550                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
7551                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7552                 }
7553         }
7554 }
7555 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
7556 #[no_mangle]
7557 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
7558 #[allow(unused)]
7559 /// Used only if an object of this type is returned as a trait impl by a method
7560 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
7561         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
7562 }
7563 #[allow(unused)]
7564 impl UnsignedChannelUpdate {
7565         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
7566                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7567         }
7568         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
7569                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7570         }
7571         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7572         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
7573                 assert!(self.is_owned);
7574                 let ret = ObjOps::untweak_ptr(self.inner);
7575                 self.inner = core::ptr::null_mut();
7576                 ret
7577         }
7578 }
7579 /// The genesis hash of the blockchain where the channel is to be opened
7580 #[no_mangle]
7581 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
7582         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7583         inner_val.as_ref()
7584 }
7585 /// The genesis hash of the blockchain where the channel is to be opened
7586 #[no_mangle]
7587 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
7588         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7589 }
7590 /// The short channel ID
7591 #[no_mangle]
7592 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
7593         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7594         *inner_val
7595 }
7596 /// The short channel ID
7597 #[no_mangle]
7598 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7599         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7600 }
7601 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7602 #[no_mangle]
7603 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
7604         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
7605         *inner_val
7606 }
7607 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7608 #[no_mangle]
7609 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7610         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
7611 }
7612 /// Channel flags
7613 #[no_mangle]
7614 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
7615         let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
7616         *inner_val
7617 }
7618 /// Channel flags
7619 #[no_mangle]
7620 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
7621         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
7622 }
7623 /// The number of blocks such that if:
7624 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7625 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7626 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7627 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7628 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7629 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7630 /// constructing the route.
7631 #[no_mangle]
7632 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
7633         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
7634         *inner_val
7635 }
7636 /// The number of blocks such that if:
7637 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7638 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7639 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7640 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7641 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7642 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7643 /// constructing the route.
7644 #[no_mangle]
7645 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
7646         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
7647 }
7648 /// The minimum HTLC size incoming to sender, in milli-satoshi
7649 #[no_mangle]
7650 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7651         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
7652         *inner_val
7653 }
7654 /// The minimum HTLC size incoming to sender, in milli-satoshi
7655 #[no_mangle]
7656 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7657         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
7658 }
7659 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7660 ///
7661 /// This used to be optional.
7662 #[no_mangle]
7663 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7664         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
7665         *inner_val
7666 }
7667 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7668 ///
7669 /// This used to be optional.
7670 #[no_mangle]
7671 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7672         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
7673 }
7674 /// The base HTLC fee charged by sender, in milli-satoshi
7675 #[no_mangle]
7676 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
7677         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
7678         *inner_val
7679 }
7680 /// The base HTLC fee charged by sender, in milli-satoshi
7681 #[no_mangle]
7682 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7683         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
7684 }
7685 /// The amount to fee multiplier, in micro-satoshi
7686 #[no_mangle]
7687 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
7688         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
7689         *inner_val
7690 }
7691 /// The amount to fee multiplier, in micro-satoshi
7692 #[no_mangle]
7693 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7694         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
7695 }
7696 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7697 /// to decode.
7698 ///
7699 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7700 ///
7701 /// Returns a copy of the field.
7702 #[no_mangle]
7703 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
7704         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7705         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7706         local_inner_val.into()
7707 }
7708 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7709 /// to decode.
7710 ///
7711 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7712 #[no_mangle]
7713 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
7714         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7715         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7716 }
7717 /// Constructs a new UnsignedChannelUpdate given each field
7718 #[must_use]
7719 #[no_mangle]
7720 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 {
7721         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7722         UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
7723                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7724                 short_channel_id: short_channel_id_arg,
7725                 timestamp: timestamp_arg,
7726                 flags: flags_arg,
7727                 cltv_expiry_delta: cltv_expiry_delta_arg,
7728                 htlc_minimum_msat: htlc_minimum_msat_arg,
7729                 htlc_maximum_msat: htlc_maximum_msat_arg,
7730                 fee_base_msat: fee_base_msat_arg,
7731                 fee_proportional_millionths: fee_proportional_millionths_arg,
7732                 excess_data: local_excess_data_arg,
7733         }), is_owned: true }
7734 }
7735 impl Clone for UnsignedChannelUpdate {
7736         fn clone(&self) -> Self {
7737                 Self {
7738                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7739                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7740                         is_owned: true,
7741                 }
7742         }
7743 }
7744 #[allow(unused)]
7745 /// Used only if an object of this type is returned as a trait impl by a method
7746 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7747         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
7748 }
7749 #[no_mangle]
7750 /// Creates a copy of the UnsignedChannelUpdate
7751 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
7752         orig.clone()
7753 }
7754 /// Get a string which allows debug introspection of a UnsignedChannelUpdate object
7755 pub extern "C" fn UnsignedChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7756         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelUpdate }).into()}
7757 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate.
7758 #[no_mangle]
7759 pub extern "C" fn UnsignedChannelUpdate_hash(o: &UnsignedChannelUpdate) -> u64 {
7760         if o.inner.is_null() { return 0; }
7761         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7762         #[allow(deprecated)]
7763         let mut hasher = core::hash::SipHasher::new();
7764         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7765         core::hash::Hasher::finish(&hasher)
7766 }
7767 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
7768 /// This ignores pointers and is_owned flags and looks at the values in fields.
7769 /// Two objects with NULL inner values will be considered "equal" here.
7770 #[no_mangle]
7771 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
7772         if a.inner == b.inner { return true; }
7773         if a.inner.is_null() || b.inner.is_null() { return false; }
7774         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7775 }
7776
7777 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
7778 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
7779
7780 /// A [`channel_update`] message to be sent to or received from a peer.
7781 ///
7782 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7783 #[must_use]
7784 #[repr(C)]
7785 pub struct ChannelUpdate {
7786         /// A pointer to the opaque Rust object.
7787
7788         /// Nearly everywhere, inner must be non-null, however in places where
7789         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7790         pub inner: *mut nativeChannelUpdate,
7791         /// Indicates that this is the only struct which contains the same pointer.
7792
7793         /// Rust functions which take ownership of an object provided via an argument require
7794         /// this to be true and invalidate the object pointed to by inner.
7795         pub is_owned: bool,
7796 }
7797
7798 impl Drop for ChannelUpdate {
7799         fn drop(&mut self) {
7800                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
7801                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7802                 }
7803         }
7804 }
7805 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
7806 #[no_mangle]
7807 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
7808 #[allow(unused)]
7809 /// Used only if an object of this type is returned as a trait impl by a method
7810 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
7811         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
7812 }
7813 #[allow(unused)]
7814 impl ChannelUpdate {
7815         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
7816                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7817         }
7818         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
7819                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7820         }
7821         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7822         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
7823                 assert!(self.is_owned);
7824                 let ret = ObjOps::untweak_ptr(self.inner);
7825                 self.inner = core::ptr::null_mut();
7826                 ret
7827         }
7828 }
7829 /// A signature of the channel update
7830 #[no_mangle]
7831 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
7832         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7833         crate::c_types::ECDSASignature::from_rust(&inner_val)
7834 }
7835 /// A signature of the channel update
7836 #[no_mangle]
7837 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
7838         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7839 }
7840 /// The actual channel update
7841 #[no_mangle]
7842 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
7843         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7844         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 }
7845 }
7846 /// The actual channel update
7847 #[no_mangle]
7848 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
7849         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7850 }
7851 /// Constructs a new ChannelUpdate given each field
7852 #[must_use]
7853 #[no_mangle]
7854 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
7855         ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
7856                 signature: signature_arg.into_rust(),
7857                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7858         }), is_owned: true }
7859 }
7860 impl Clone for ChannelUpdate {
7861         fn clone(&self) -> Self {
7862                 Self {
7863                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7864                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7865                         is_owned: true,
7866                 }
7867         }
7868 }
7869 #[allow(unused)]
7870 /// Used only if an object of this type is returned as a trait impl by a method
7871 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7872         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelUpdate)).clone() })) as *mut c_void
7873 }
7874 #[no_mangle]
7875 /// Creates a copy of the ChannelUpdate
7876 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
7877         orig.clone()
7878 }
7879 /// Get a string which allows debug introspection of a ChannelUpdate object
7880 pub extern "C" fn ChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7881         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelUpdate }).into()}
7882 /// Generates a non-cryptographic 64-bit hash of the ChannelUpdate.
7883 #[no_mangle]
7884 pub extern "C" fn ChannelUpdate_hash(o: &ChannelUpdate) -> u64 {
7885         if o.inner.is_null() { return 0; }
7886         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7887         #[allow(deprecated)]
7888         let mut hasher = core::hash::SipHasher::new();
7889         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7890         core::hash::Hasher::finish(&hasher)
7891 }
7892 /// Checks if two ChannelUpdates contain equal inner contents.
7893 /// This ignores pointers and is_owned flags and looks at the values in fields.
7894 /// Two objects with NULL inner values will be considered "equal" here.
7895 #[no_mangle]
7896 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
7897         if a.inner == b.inner { return true; }
7898         if a.inner.is_null() || b.inner.is_null() { return false; }
7899         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7900 }
7901
7902 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
7903 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
7904
7905 /// A [`query_channel_range`] message is used to query a peer for channel
7906 /// UTXOs in a range of blocks. The recipient of a query makes a best
7907 /// effort to reply to the query using one or more [`ReplyChannelRange`]
7908 /// messages.
7909 ///
7910 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
7911 #[must_use]
7912 #[repr(C)]
7913 pub struct QueryChannelRange {
7914         /// A pointer to the opaque Rust object.
7915
7916         /// Nearly everywhere, inner must be non-null, however in places where
7917         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7918         pub inner: *mut nativeQueryChannelRange,
7919         /// Indicates that this is the only struct which contains the same pointer.
7920
7921         /// Rust functions which take ownership of an object provided via an argument require
7922         /// this to be true and invalidate the object pointed to by inner.
7923         pub is_owned: bool,
7924 }
7925
7926 impl Drop for QueryChannelRange {
7927         fn drop(&mut self) {
7928                 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
7929                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7930                 }
7931         }
7932 }
7933 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
7934 #[no_mangle]
7935 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
7936 #[allow(unused)]
7937 /// Used only if an object of this type is returned as a trait impl by a method
7938 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
7939         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
7940 }
7941 #[allow(unused)]
7942 impl QueryChannelRange {
7943         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
7944                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7945         }
7946         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
7947                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7948         }
7949         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7950         pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
7951                 assert!(self.is_owned);
7952                 let ret = ObjOps::untweak_ptr(self.inner);
7953                 self.inner = core::ptr::null_mut();
7954                 ret
7955         }
7956 }
7957 /// The genesis hash of the blockchain being queried
7958 #[no_mangle]
7959 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
7960         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7961         inner_val.as_ref()
7962 }
7963 /// The genesis hash of the blockchain being queried
7964 #[no_mangle]
7965 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
7966         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7967 }
7968 /// The height of the first block for the channel UTXOs being queried
7969 #[no_mangle]
7970 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
7971         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
7972         *inner_val
7973 }
7974 /// The height of the first block for the channel UTXOs being queried
7975 #[no_mangle]
7976 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
7977         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
7978 }
7979 /// The number of blocks to include in the query results
7980 #[no_mangle]
7981 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
7982         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
7983         *inner_val
7984 }
7985 /// The number of blocks to include in the query results
7986 #[no_mangle]
7987 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
7988         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
7989 }
7990 /// Constructs a new QueryChannelRange given each field
7991 #[must_use]
7992 #[no_mangle]
7993 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 {
7994         QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
7995                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7996                 first_blocknum: first_blocknum_arg,
7997                 number_of_blocks: number_of_blocks_arg,
7998         }), is_owned: true }
7999 }
8000 impl Clone for QueryChannelRange {
8001         fn clone(&self) -> Self {
8002                 Self {
8003                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
8004                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8005                         is_owned: true,
8006                 }
8007         }
8008 }
8009 #[allow(unused)]
8010 /// Used only if an object of this type is returned as a trait impl by a method
8011 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8012         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryChannelRange)).clone() })) as *mut c_void
8013 }
8014 #[no_mangle]
8015 /// Creates a copy of the QueryChannelRange
8016 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
8017         orig.clone()
8018 }
8019 /// Get a string which allows debug introspection of a QueryChannelRange object
8020 pub extern "C" fn QueryChannelRange_debug_str_void(o: *const c_void) -> Str {
8021         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryChannelRange }).into()}
8022 /// Generates a non-cryptographic 64-bit hash of the QueryChannelRange.
8023 #[no_mangle]
8024 pub extern "C" fn QueryChannelRange_hash(o: &QueryChannelRange) -> u64 {
8025         if o.inner.is_null() { return 0; }
8026         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8027         #[allow(deprecated)]
8028         let mut hasher = core::hash::SipHasher::new();
8029         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8030         core::hash::Hasher::finish(&hasher)
8031 }
8032 /// Checks if two QueryChannelRanges contain equal inner contents.
8033 /// This ignores pointers and is_owned flags and looks at the values in fields.
8034 /// Two objects with NULL inner values will be considered "equal" here.
8035 #[no_mangle]
8036 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
8037         if a.inner == b.inner { return true; }
8038         if a.inner.is_null() || b.inner.is_null() { return false; }
8039         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8040 }
8041
8042 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
8043 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
8044
8045 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
8046 /// message.
8047 ///
8048 /// Multiple `reply_channel_range` messages can be sent in reply
8049 /// to a single [`QueryChannelRange`] message. The query recipient makes a
8050 /// best effort to respond based on their local network view which may
8051 /// not be a perfect view of the network. The `short_channel_id`s in the
8052 /// reply are encoded. We only support `encoding_type=0` uncompressed
8053 /// serialization and do not support `encoding_type=1` zlib serialization.
8054 ///
8055 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
8056 #[must_use]
8057 #[repr(C)]
8058 pub struct ReplyChannelRange {
8059         /// A pointer to the opaque Rust object.
8060
8061         /// Nearly everywhere, inner must be non-null, however in places where
8062         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8063         pub inner: *mut nativeReplyChannelRange,
8064         /// Indicates that this is the only struct which contains the same pointer.
8065
8066         /// Rust functions which take ownership of an object provided via an argument require
8067         /// this to be true and invalidate the object pointed to by inner.
8068         pub is_owned: bool,
8069 }
8070
8071 impl Drop for ReplyChannelRange {
8072         fn drop(&mut self) {
8073                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
8074                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8075                 }
8076         }
8077 }
8078 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
8079 #[no_mangle]
8080 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
8081 #[allow(unused)]
8082 /// Used only if an object of this type is returned as a trait impl by a method
8083 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
8084         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
8085 }
8086 #[allow(unused)]
8087 impl ReplyChannelRange {
8088         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
8089                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8090         }
8091         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
8092                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8093         }
8094         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8095         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
8096                 assert!(self.is_owned);
8097                 let ret = ObjOps::untweak_ptr(self.inner);
8098                 self.inner = core::ptr::null_mut();
8099                 ret
8100         }
8101 }
8102 /// The genesis hash of the blockchain being queried
8103 #[no_mangle]
8104 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
8105         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8106         inner_val.as_ref()
8107 }
8108 /// The genesis hash of the blockchain being queried
8109 #[no_mangle]
8110 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
8111         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8112 }
8113 /// The height of the first block in the range of the reply
8114 #[no_mangle]
8115 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
8116         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
8117         *inner_val
8118 }
8119 /// The height of the first block in the range of the reply
8120 #[no_mangle]
8121 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8122         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
8123 }
8124 /// The number of blocks included in the range of the reply
8125 #[no_mangle]
8126 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
8127         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
8128         *inner_val
8129 }
8130 /// The number of blocks included in the range of the reply
8131 #[no_mangle]
8132 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8133         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
8134 }
8135 /// True when this is the final reply for a query
8136 #[no_mangle]
8137 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
8138         let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
8139         *inner_val
8140 }
8141 /// True when this is the final reply for a query
8142 #[no_mangle]
8143 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
8144         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
8145 }
8146 /// The `short_channel_id`s in the channel range
8147 ///
8148 /// Returns a copy of the field.
8149 #[no_mangle]
8150 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
8151         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8152         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8153         local_inner_val.into()
8154 }
8155 /// The `short_channel_id`s in the channel range
8156 #[no_mangle]
8157 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
8158         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8159         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8160 }
8161 /// Constructs a new ReplyChannelRange given each field
8162 #[must_use]
8163 #[no_mangle]
8164 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 {
8165         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 }); };
8166         ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
8167                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8168                 first_blocknum: first_blocknum_arg,
8169                 number_of_blocks: number_of_blocks_arg,
8170                 sync_complete: sync_complete_arg,
8171                 short_channel_ids: local_short_channel_ids_arg,
8172         }), is_owned: true }
8173 }
8174 impl Clone for ReplyChannelRange {
8175         fn clone(&self) -> Self {
8176                 Self {
8177                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
8178                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8179                         is_owned: true,
8180                 }
8181         }
8182 }
8183 #[allow(unused)]
8184 /// Used only if an object of this type is returned as a trait impl by a method
8185 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8186         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyChannelRange)).clone() })) as *mut c_void
8187 }
8188 #[no_mangle]
8189 /// Creates a copy of the ReplyChannelRange
8190 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
8191         orig.clone()
8192 }
8193 /// Get a string which allows debug introspection of a ReplyChannelRange object
8194 pub extern "C" fn ReplyChannelRange_debug_str_void(o: *const c_void) -> Str {
8195         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyChannelRange }).into()}
8196 /// Generates a non-cryptographic 64-bit hash of the ReplyChannelRange.
8197 #[no_mangle]
8198 pub extern "C" fn ReplyChannelRange_hash(o: &ReplyChannelRange) -> u64 {
8199         if o.inner.is_null() { return 0; }
8200         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8201         #[allow(deprecated)]
8202         let mut hasher = core::hash::SipHasher::new();
8203         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8204         core::hash::Hasher::finish(&hasher)
8205 }
8206 /// Checks if two ReplyChannelRanges contain equal inner contents.
8207 /// This ignores pointers and is_owned flags and looks at the values in fields.
8208 /// Two objects with NULL inner values will be considered "equal" here.
8209 #[no_mangle]
8210 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
8211         if a.inner == b.inner { return true; }
8212         if a.inner.is_null() || b.inner.is_null() { return false; }
8213         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8214 }
8215
8216 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
8217 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
8218
8219 /// A [`query_short_channel_ids`] message is used to query a peer for
8220 /// routing gossip messages related to one or more `short_channel_id`s.
8221 ///
8222 /// The query recipient will reply with the latest, if available,
8223 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
8224 /// it maintains for the requested `short_channel_id`s followed by a
8225 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
8226 /// this query are encoded. We only support `encoding_type=0` uncompressed
8227 /// serialization and do not support `encoding_type=1` zlib serialization.
8228 ///
8229 /// [`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
8230 #[must_use]
8231 #[repr(C)]
8232 pub struct QueryShortChannelIds {
8233         /// A pointer to the opaque Rust object.
8234
8235         /// Nearly everywhere, inner must be non-null, however in places where
8236         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8237         pub inner: *mut nativeQueryShortChannelIds,
8238         /// Indicates that this is the only struct which contains the same pointer.
8239
8240         /// Rust functions which take ownership of an object provided via an argument require
8241         /// this to be true and invalidate the object pointed to by inner.
8242         pub is_owned: bool,
8243 }
8244
8245 impl Drop for QueryShortChannelIds {
8246         fn drop(&mut self) {
8247                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
8248                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8249                 }
8250         }
8251 }
8252 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
8253 #[no_mangle]
8254 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
8255 #[allow(unused)]
8256 /// Used only if an object of this type is returned as a trait impl by a method
8257 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
8258         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
8259 }
8260 #[allow(unused)]
8261 impl QueryShortChannelIds {
8262         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
8263                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8264         }
8265         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
8266                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8267         }
8268         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8269         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
8270                 assert!(self.is_owned);
8271                 let ret = ObjOps::untweak_ptr(self.inner);
8272                 self.inner = core::ptr::null_mut();
8273                 ret
8274         }
8275 }
8276 /// The genesis hash of the blockchain being queried
8277 #[no_mangle]
8278 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
8279         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8280         inner_val.as_ref()
8281 }
8282 /// The genesis hash of the blockchain being queried
8283 #[no_mangle]
8284 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
8285         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8286 }
8287 /// The short_channel_ids that are being queried
8288 ///
8289 /// Returns a copy of the field.
8290 #[no_mangle]
8291 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
8292         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8293         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8294         local_inner_val.into()
8295 }
8296 /// The short_channel_ids that are being queried
8297 #[no_mangle]
8298 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
8299         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8300         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8301 }
8302 /// Constructs a new QueryShortChannelIds given each field
8303 #[must_use]
8304 #[no_mangle]
8305 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 {
8306         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 }); };
8307         QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
8308                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8309                 short_channel_ids: local_short_channel_ids_arg,
8310         }), is_owned: true }
8311 }
8312 impl Clone for QueryShortChannelIds {
8313         fn clone(&self) -> Self {
8314                 Self {
8315                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
8316                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8317                         is_owned: true,
8318                 }
8319         }
8320 }
8321 #[allow(unused)]
8322 /// Used only if an object of this type is returned as a trait impl by a method
8323 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
8324         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryShortChannelIds)).clone() })) as *mut c_void
8325 }
8326 #[no_mangle]
8327 /// Creates a copy of the QueryShortChannelIds
8328 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
8329         orig.clone()
8330 }
8331 /// Get a string which allows debug introspection of a QueryShortChannelIds object
8332 pub extern "C" fn QueryShortChannelIds_debug_str_void(o: *const c_void) -> Str {
8333         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryShortChannelIds }).into()}
8334 /// Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds.
8335 #[no_mangle]
8336 pub extern "C" fn QueryShortChannelIds_hash(o: &QueryShortChannelIds) -> u64 {
8337         if o.inner.is_null() { return 0; }
8338         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8339         #[allow(deprecated)]
8340         let mut hasher = core::hash::SipHasher::new();
8341         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8342         core::hash::Hasher::finish(&hasher)
8343 }
8344 /// Checks if two QueryShortChannelIdss contain equal inner contents.
8345 /// This ignores pointers and is_owned flags and looks at the values in fields.
8346 /// Two objects with NULL inner values will be considered "equal" here.
8347 #[no_mangle]
8348 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
8349         if a.inner == b.inner { return true; }
8350         if a.inner.is_null() || b.inner.is_null() { return false; }
8351         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8352 }
8353
8354 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
8355 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
8356
8357 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
8358 /// message. The query recipient makes a best
8359 /// effort to respond based on their local network view which may not be
8360 /// a perfect view of the network.
8361 ///
8362 /// [`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
8363 #[must_use]
8364 #[repr(C)]
8365 pub struct ReplyShortChannelIdsEnd {
8366         /// A pointer to the opaque Rust object.
8367
8368         /// Nearly everywhere, inner must be non-null, however in places where
8369         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8370         pub inner: *mut nativeReplyShortChannelIdsEnd,
8371         /// Indicates that this is the only struct which contains the same pointer.
8372
8373         /// Rust functions which take ownership of an object provided via an argument require
8374         /// this to be true and invalidate the object pointed to by inner.
8375         pub is_owned: bool,
8376 }
8377
8378 impl Drop for ReplyShortChannelIdsEnd {
8379         fn drop(&mut self) {
8380                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
8381                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8382                 }
8383         }
8384 }
8385 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
8386 #[no_mangle]
8387 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
8388 #[allow(unused)]
8389 /// Used only if an object of this type is returned as a trait impl by a method
8390 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
8391         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
8392 }
8393 #[allow(unused)]
8394 impl ReplyShortChannelIdsEnd {
8395         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
8396                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8397         }
8398         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
8399                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8400         }
8401         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8402         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
8403                 assert!(self.is_owned);
8404                 let ret = ObjOps::untweak_ptr(self.inner);
8405                 self.inner = core::ptr::null_mut();
8406                 ret
8407         }
8408 }
8409 /// The genesis hash of the blockchain that was queried
8410 #[no_mangle]
8411 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
8412         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8413         inner_val.as_ref()
8414 }
8415 /// The genesis hash of the blockchain that was queried
8416 #[no_mangle]
8417 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
8418         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8419 }
8420 /// Indicates if the query recipient maintains up-to-date channel
8421 /// information for the `chain_hash`
8422 #[no_mangle]
8423 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
8424         let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
8425         *inner_val
8426 }
8427 /// Indicates if the query recipient maintains up-to-date channel
8428 /// information for the `chain_hash`
8429 #[no_mangle]
8430 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
8431         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
8432 }
8433 /// Constructs a new ReplyShortChannelIdsEnd given each field
8434 #[must_use]
8435 #[no_mangle]
8436 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
8437         ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
8438                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8439                 full_information: full_information_arg,
8440         }), is_owned: true }
8441 }
8442 impl Clone for ReplyShortChannelIdsEnd {
8443         fn clone(&self) -> Self {
8444                 Self {
8445                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
8446                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8447                         is_owned: true,
8448                 }
8449         }
8450 }
8451 #[allow(unused)]
8452 /// Used only if an object of this type is returned as a trait impl by a method
8453 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
8454         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
8455 }
8456 #[no_mangle]
8457 /// Creates a copy of the ReplyShortChannelIdsEnd
8458 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
8459         orig.clone()
8460 }
8461 /// Get a string which allows debug introspection of a ReplyShortChannelIdsEnd object
8462 pub extern "C" fn ReplyShortChannelIdsEnd_debug_str_void(o: *const c_void) -> Str {
8463         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyShortChannelIdsEnd }).into()}
8464 /// Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd.
8465 #[no_mangle]
8466 pub extern "C" fn ReplyShortChannelIdsEnd_hash(o: &ReplyShortChannelIdsEnd) -> u64 {
8467         if o.inner.is_null() { return 0; }
8468         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8469         #[allow(deprecated)]
8470         let mut hasher = core::hash::SipHasher::new();
8471         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8472         core::hash::Hasher::finish(&hasher)
8473 }
8474 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
8475 /// This ignores pointers and is_owned flags and looks at the values in fields.
8476 /// Two objects with NULL inner values will be considered "equal" here.
8477 #[no_mangle]
8478 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
8479         if a.inner == b.inner { return true; }
8480         if a.inner.is_null() || b.inner.is_null() { return false; }
8481         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8482 }
8483
8484 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
8485 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
8486
8487 /// A [`gossip_timestamp_filter`] message is used by a node to request
8488 /// gossip relay for messages in the requested time range when the
8489 /// `gossip_queries` feature has been negotiated.
8490 ///
8491 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
8492 #[must_use]
8493 #[repr(C)]
8494 pub struct GossipTimestampFilter {
8495         /// A pointer to the opaque Rust object.
8496
8497         /// Nearly everywhere, inner must be non-null, however in places where
8498         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8499         pub inner: *mut nativeGossipTimestampFilter,
8500         /// Indicates that this is the only struct which contains the same pointer.
8501
8502         /// Rust functions which take ownership of an object provided via an argument require
8503         /// this to be true and invalidate the object pointed to by inner.
8504         pub is_owned: bool,
8505 }
8506
8507 impl Drop for GossipTimestampFilter {
8508         fn drop(&mut self) {
8509                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
8510                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8511                 }
8512         }
8513 }
8514 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
8515 #[no_mangle]
8516 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
8517 #[allow(unused)]
8518 /// Used only if an object of this type is returned as a trait impl by a method
8519 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
8520         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
8521 }
8522 #[allow(unused)]
8523 impl GossipTimestampFilter {
8524         pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
8525                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8526         }
8527         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
8528                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8529         }
8530         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8531         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
8532                 assert!(self.is_owned);
8533                 let ret = ObjOps::untweak_ptr(self.inner);
8534                 self.inner = core::ptr::null_mut();
8535                 ret
8536         }
8537 }
8538 /// The genesis hash of the blockchain for channel and node information
8539 #[no_mangle]
8540 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
8541         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8542         inner_val.as_ref()
8543 }
8544 /// The genesis hash of the blockchain for channel and node information
8545 #[no_mangle]
8546 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
8547         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8548 }
8549 /// The starting unix timestamp
8550 #[no_mangle]
8551 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
8552         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
8553         *inner_val
8554 }
8555 /// The starting unix timestamp
8556 #[no_mangle]
8557 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8558         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
8559 }
8560 /// The range of information in seconds
8561 #[no_mangle]
8562 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
8563         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
8564         *inner_val
8565 }
8566 /// The range of information in seconds
8567 #[no_mangle]
8568 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8569         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
8570 }
8571 /// Constructs a new GossipTimestampFilter given each field
8572 #[must_use]
8573 #[no_mangle]
8574 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 {
8575         GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
8576                 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8577                 first_timestamp: first_timestamp_arg,
8578                 timestamp_range: timestamp_range_arg,
8579         }), is_owned: true }
8580 }
8581 impl Clone for GossipTimestampFilter {
8582         fn clone(&self) -> Self {
8583                 Self {
8584                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
8585                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8586                         is_owned: true,
8587                 }
8588         }
8589 }
8590 #[allow(unused)]
8591 /// Used only if an object of this type is returned as a trait impl by a method
8592 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
8593         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeGossipTimestampFilter)).clone() })) as *mut c_void
8594 }
8595 #[no_mangle]
8596 /// Creates a copy of the GossipTimestampFilter
8597 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
8598         orig.clone()
8599 }
8600 /// Get a string which allows debug introspection of a GossipTimestampFilter object
8601 pub extern "C" fn GossipTimestampFilter_debug_str_void(o: *const c_void) -> Str {
8602         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::GossipTimestampFilter }).into()}
8603 /// Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter.
8604 #[no_mangle]
8605 pub extern "C" fn GossipTimestampFilter_hash(o: &GossipTimestampFilter) -> u64 {
8606         if o.inner.is_null() { return 0; }
8607         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8608         #[allow(deprecated)]
8609         let mut hasher = core::hash::SipHasher::new();
8610         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8611         core::hash::Hasher::finish(&hasher)
8612 }
8613 /// Checks if two GossipTimestampFilters contain equal inner contents.
8614 /// This ignores pointers and is_owned flags and looks at the values in fields.
8615 /// Two objects with NULL inner values will be considered "equal" here.
8616 #[no_mangle]
8617 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
8618         if a.inner == b.inner { return true; }
8619         if a.inner.is_null() || b.inner.is_null() { return false; }
8620         if a.get_native_ref() == b.get_native_ref() { true } else { false }
8621 }
8622 /// Used to put an error message in a [`LightningError`].
8623 #[derive(Clone)]
8624 #[must_use]
8625 #[repr(C)]
8626 pub enum ErrorAction {
8627         /// The peer took some action which made us think they were useless. Disconnect them.
8628         DisconnectPeer {
8629                 /// An error message which we should make an effort to send before we disconnect.
8630                 ///
8631                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
8632                 msg: crate::lightning::ln::msgs::ErrorMessage,
8633         },
8634         /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
8635         DisconnectPeerWithWarning {
8636                 /// A warning message which we should make an effort to send before we disconnect.
8637                 msg: crate::lightning::ln::msgs::WarningMessage,
8638         },
8639         /// The peer did something harmless that we weren't able to process, just log and ignore
8640         IgnoreError,
8641         /// The peer did something harmless that we weren't able to meaningfully process.
8642         /// If the error is logged, log it at the given level.
8643         IgnoreAndLog(
8644                 crate::lightning::util::logger::Level),
8645         /// The peer provided us with a gossip message which we'd already seen. In most cases this
8646         /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
8647         /// our own channel announcements.
8648         IgnoreDuplicateGossip,
8649         /// The peer did something incorrect. Tell them.
8650         SendErrorMessage {
8651                 /// The message to send.
8652                 msg: crate::lightning::ln::msgs::ErrorMessage,
8653         },
8654         /// The peer did something incorrect. Tell them without closing any channels.
8655         SendWarningMessage {
8656                 /// The message to send.
8657                 msg: crate::lightning::ln::msgs::WarningMessage,
8658                 /// The peer may have done something harmless that we weren't able to meaningfully process,
8659                 /// though we should still tell them about it.
8660                 /// If this event is logged, log it at the given level.
8661                 log_level: crate::lightning::util::logger::Level,
8662         },
8663 }
8664 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
8665 pub(crate) type nativeErrorAction = ErrorActionImport;
8666
8667 impl ErrorAction {
8668         #[allow(unused)]
8669         pub(crate) fn to_native(&self) -> nativeErrorAction {
8670                 match self {
8671                         ErrorAction::DisconnectPeer {ref msg, } => {
8672                                 let mut msg_nonref = Clone::clone(msg);
8673                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
8674                                 nativeErrorAction::DisconnectPeer {
8675                                         msg: local_msg_nonref,
8676                                 }
8677                         },
8678                         ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8679                                 let mut msg_nonref = Clone::clone(msg);
8680                                 nativeErrorAction::DisconnectPeerWithWarning {
8681                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8682                                 }
8683                         },
8684                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8685                         ErrorAction::IgnoreAndLog (ref a, ) => {
8686                                 let mut a_nonref = Clone::clone(a);
8687                                 nativeErrorAction::IgnoreAndLog (
8688                                         a_nonref.into_native(),
8689                                 )
8690                         },
8691                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8692                         ErrorAction::SendErrorMessage {ref msg, } => {
8693                                 let mut msg_nonref = Clone::clone(msg);
8694                                 nativeErrorAction::SendErrorMessage {
8695                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8696                                 }
8697                         },
8698                         ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8699                                 let mut msg_nonref = Clone::clone(msg);
8700                                 let mut log_level_nonref = Clone::clone(log_level);
8701                                 nativeErrorAction::SendWarningMessage {
8702                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8703                                         log_level: log_level_nonref.into_native(),
8704                                 }
8705                         },
8706                 }
8707         }
8708         #[allow(unused)]
8709         pub(crate) fn into_native(self) -> nativeErrorAction {
8710                 match self {
8711                         ErrorAction::DisconnectPeer {mut msg, } => {
8712                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
8713                                 nativeErrorAction::DisconnectPeer {
8714                                         msg: local_msg,
8715                                 }
8716                         },
8717                         ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8718                                 nativeErrorAction::DisconnectPeerWithWarning {
8719                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
8720                                 }
8721                         },
8722                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8723                         ErrorAction::IgnoreAndLog (mut a, ) => {
8724                                 nativeErrorAction::IgnoreAndLog (
8725                                         a.into_native(),
8726                                 )
8727                         },
8728                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8729                         ErrorAction::SendErrorMessage {mut msg, } => {
8730                                 nativeErrorAction::SendErrorMessage {
8731                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
8732                                 }
8733                         },
8734                         ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8735                                 nativeErrorAction::SendWarningMessage {
8736                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
8737                                         log_level: log_level.into_native(),
8738                                 }
8739                         },
8740                 }
8741         }
8742         #[allow(unused)]
8743         pub(crate) fn from_native(native: &ErrorActionImport) -> Self {
8744                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeErrorAction) };
8745                 match native {
8746                         nativeErrorAction::DisconnectPeer {ref msg, } => {
8747                                 let mut msg_nonref = Clone::clone(msg);
8748                                 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 };
8749                                 ErrorAction::DisconnectPeer {
8750                                         msg: local_msg_nonref,
8751                                 }
8752                         },
8753                         nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8754                                 let mut msg_nonref = Clone::clone(msg);
8755                                 ErrorAction::DisconnectPeerWithWarning {
8756                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8757                                 }
8758                         },
8759                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8760                         nativeErrorAction::IgnoreAndLog (ref a, ) => {
8761                                 let mut a_nonref = Clone::clone(a);
8762                                 ErrorAction::IgnoreAndLog (
8763                                         crate::lightning::util::logger::Level::native_into(a_nonref),
8764                                 )
8765                         },
8766                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8767                         nativeErrorAction::SendErrorMessage {ref msg, } => {
8768                                 let mut msg_nonref = Clone::clone(msg);
8769                                 ErrorAction::SendErrorMessage {
8770                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8771                                 }
8772                         },
8773                         nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8774                                 let mut msg_nonref = Clone::clone(msg);
8775                                 let mut log_level_nonref = Clone::clone(log_level);
8776                                 ErrorAction::SendWarningMessage {
8777                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8778                                         log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
8779                                 }
8780                         },
8781                 }
8782         }
8783         #[allow(unused)]
8784         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
8785                 match native {
8786                         nativeErrorAction::DisconnectPeer {mut msg, } => {
8787                                 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 };
8788                                 ErrorAction::DisconnectPeer {
8789                                         msg: local_msg,
8790                                 }
8791                         },
8792                         nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8793                                 ErrorAction::DisconnectPeerWithWarning {
8794                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8795                                 }
8796                         },
8797                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8798                         nativeErrorAction::IgnoreAndLog (mut a, ) => {
8799                                 ErrorAction::IgnoreAndLog (
8800                                         crate::lightning::util::logger::Level::native_into(a),
8801                                 )
8802                         },
8803                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8804                         nativeErrorAction::SendErrorMessage {mut msg, } => {
8805                                 ErrorAction::SendErrorMessage {
8806                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8807                                 }
8808                         },
8809                         nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8810                                 ErrorAction::SendWarningMessage {
8811                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8812                                         log_level: crate::lightning::util::logger::Level::native_into(log_level),
8813                                 }
8814                         },
8815                 }
8816         }
8817 }
8818 /// Frees any resources used by the ErrorAction
8819 #[no_mangle]
8820 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
8821 /// Creates a copy of the ErrorAction
8822 #[no_mangle]
8823 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
8824         orig.clone()
8825 }
8826 #[allow(unused)]
8827 /// Used only if an object of this type is returned as a trait impl by a method
8828 pub(crate) extern "C" fn ErrorAction_clone_void(this_ptr: *const c_void) -> *mut c_void {
8829         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ErrorAction)).clone() })) as *mut c_void
8830 }
8831 #[allow(unused)]
8832 /// Used only if an object of this type is returned as a trait impl by a method
8833 pub(crate) extern "C" fn ErrorAction_free_void(this_ptr: *mut c_void) {
8834         let _ = unsafe { Box::from_raw(this_ptr as *mut ErrorAction) };
8835 }
8836 #[no_mangle]
8837 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
8838 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8839         ErrorAction::DisconnectPeer {
8840                 msg,
8841         }
8842 }
8843 #[no_mangle]
8844 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
8845 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
8846         ErrorAction::DisconnectPeerWithWarning {
8847                 msg,
8848         }
8849 }
8850 #[no_mangle]
8851 /// Utility method to constructs a new IgnoreError-variant ErrorAction
8852 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
8853         ErrorAction::IgnoreError}
8854 #[no_mangle]
8855 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
8856 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
8857         ErrorAction::IgnoreAndLog(a, )
8858 }
8859 #[no_mangle]
8860 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
8861 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
8862         ErrorAction::IgnoreDuplicateGossip}
8863 #[no_mangle]
8864 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
8865 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8866         ErrorAction::SendErrorMessage {
8867                 msg,
8868         }
8869 }
8870 #[no_mangle]
8871 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
8872 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
8873         ErrorAction::SendWarningMessage {
8874                 msg,
8875                 log_level,
8876         }
8877 }
8878 /// Get a string which allows debug introspection of a ErrorAction object
8879 pub extern "C" fn ErrorAction_debug_str_void(o: *const c_void) -> Str {
8880         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorAction }).into()}
8881 /// Generates a non-cryptographic 64-bit hash of the ErrorAction.
8882 #[no_mangle]
8883 pub extern "C" fn ErrorAction_hash(o: &ErrorAction) -> u64 {
8884         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8885         #[allow(deprecated)]
8886         let mut hasher = core::hash::SipHasher::new();
8887         core::hash::Hash::hash(&o.to_native(), &mut hasher);
8888         core::hash::Hasher::finish(&hasher)
8889 }
8890
8891 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
8892 pub(crate) type nativeLightningError = nativeLightningErrorImport;
8893
8894 /// An Err type for failure to process messages.
8895 #[must_use]
8896 #[repr(C)]
8897 pub struct LightningError {
8898         /// A pointer to the opaque Rust object.
8899
8900         /// Nearly everywhere, inner must be non-null, however in places where
8901         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8902         pub inner: *mut nativeLightningError,
8903         /// Indicates that this is the only struct which contains the same pointer.
8904
8905         /// Rust functions which take ownership of an object provided via an argument require
8906         /// this to be true and invalidate the object pointed to by inner.
8907         pub is_owned: bool,
8908 }
8909
8910 impl Drop for LightningError {
8911         fn drop(&mut self) {
8912                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
8913                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8914                 }
8915         }
8916 }
8917 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
8918 #[no_mangle]
8919 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
8920 #[allow(unused)]
8921 /// Used only if an object of this type is returned as a trait impl by a method
8922 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
8923         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
8924 }
8925 #[allow(unused)]
8926 impl LightningError {
8927         pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
8928                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8929         }
8930         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
8931                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8932         }
8933         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8934         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
8935                 assert!(self.is_owned);
8936                 let ret = ObjOps::untweak_ptr(self.inner);
8937                 self.inner = core::ptr::null_mut();
8938                 ret
8939         }
8940 }
8941 /// A human-readable message describing the error
8942 #[no_mangle]
8943 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
8944         let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
8945         inner_val.as_str().into()
8946 }
8947 /// A human-readable message describing the error
8948 #[no_mangle]
8949 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
8950         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
8951 }
8952 /// The action which should be taken against the offending peer.
8953 #[no_mangle]
8954 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
8955         let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
8956         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
8957 }
8958 /// The action which should be taken against the offending peer.
8959 #[no_mangle]
8960 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
8961         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
8962 }
8963 /// Constructs a new LightningError given each field
8964 #[must_use]
8965 #[no_mangle]
8966 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
8967         LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
8968                 err: err_arg.into_string(),
8969                 action: action_arg.into_native(),
8970         }), is_owned: true }
8971 }
8972 impl Clone for LightningError {
8973         fn clone(&self) -> Self {
8974                 Self {
8975                         inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
8976                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8977                         is_owned: true,
8978                 }
8979         }
8980 }
8981 #[allow(unused)]
8982 /// Used only if an object of this type is returned as a trait impl by a method
8983 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
8984         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLightningError)).clone() })) as *mut c_void
8985 }
8986 #[no_mangle]
8987 /// Creates a copy of the LightningError
8988 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
8989         orig.clone()
8990 }
8991 /// Get a string which allows debug introspection of a LightningError object
8992 pub extern "C" fn LightningError_debug_str_void(o: *const c_void) -> Str {
8993         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::LightningError }).into()}
8994
8995 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
8996 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
8997
8998 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
8999 /// transaction updates if they were pending.
9000 #[must_use]
9001 #[repr(C)]
9002 pub struct CommitmentUpdate {
9003         /// A pointer to the opaque Rust object.
9004
9005         /// Nearly everywhere, inner must be non-null, however in places where
9006         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9007         pub inner: *mut nativeCommitmentUpdate,
9008         /// Indicates that this is the only struct which contains the same pointer.
9009
9010         /// Rust functions which take ownership of an object provided via an argument require
9011         /// this to be true and invalidate the object pointed to by inner.
9012         pub is_owned: bool,
9013 }
9014
9015 impl Drop for CommitmentUpdate {
9016         fn drop(&mut self) {
9017                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
9018                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9019                 }
9020         }
9021 }
9022 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
9023 #[no_mangle]
9024 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
9025 #[allow(unused)]
9026 /// Used only if an object of this type is returned as a trait impl by a method
9027 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
9028         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
9029 }
9030 #[allow(unused)]
9031 impl CommitmentUpdate {
9032         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
9033                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9034         }
9035         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
9036                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9037         }
9038         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9039         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
9040                 assert!(self.is_owned);
9041                 let ret = ObjOps::untweak_ptr(self.inner);
9042                 self.inner = core::ptr::null_mut();
9043                 ret
9044         }
9045 }
9046 /// `update_add_htlc` messages which should be sent
9047 #[no_mangle]
9048 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
9049         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
9050         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 } }); };
9051         local_inner_val.into()
9052 }
9053 /// `update_add_htlc` messages which should be sent
9054 #[no_mangle]
9055 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
9056         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9057         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
9058 }
9059 /// `update_fulfill_htlc` messages which should be sent
9060 #[no_mangle]
9061 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
9062         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
9063         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 } }); };
9064         local_inner_val.into()
9065 }
9066 /// `update_fulfill_htlc` messages which should be sent
9067 #[no_mangle]
9068 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
9069         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9070         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
9071 }
9072 /// `update_fail_htlc` messages which should be sent
9073 #[no_mangle]
9074 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
9075         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
9076         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 } }); };
9077         local_inner_val.into()
9078 }
9079 /// `update_fail_htlc` messages which should be sent
9080 #[no_mangle]
9081 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
9082         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9083         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
9084 }
9085 /// `update_fail_malformed_htlc` messages which should be sent
9086 #[no_mangle]
9087 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
9088         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
9089         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 } }); };
9090         local_inner_val.into()
9091 }
9092 /// `update_fail_malformed_htlc` messages which should be sent
9093 #[no_mangle]
9094 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
9095         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9096         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
9097 }
9098 /// An `update_fee` message which should be sent
9099 ///
9100 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9101 #[no_mangle]
9102 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
9103         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
9104         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 };
9105         local_inner_val
9106 }
9107 /// An `update_fee` message which should be sent
9108 ///
9109 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
9110 #[no_mangle]
9111 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
9112         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
9113         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
9114 }
9115 /// A `commitment_signed` message which should be sent
9116 #[no_mangle]
9117 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
9118         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
9119         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 }
9120 }
9121 /// A `commitment_signed` message which should be sent
9122 #[no_mangle]
9123 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
9124         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
9125 }
9126 /// Constructs a new CommitmentUpdate given each field
9127 ///
9128 /// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
9129 #[must_use]
9130 #[no_mangle]
9131 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 {
9132         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()) } }); };
9133         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()) } }); };
9134         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()) } }); };
9135         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()) } }); };
9136         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()) } }) };
9137         CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
9138                 update_add_htlcs: local_update_add_htlcs_arg,
9139                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
9140                 update_fail_htlcs: local_update_fail_htlcs_arg,
9141                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
9142                 update_fee: local_update_fee_arg,
9143                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
9144         }), is_owned: true }
9145 }
9146 impl Clone for CommitmentUpdate {
9147         fn clone(&self) -> Self {
9148                 Self {
9149                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
9150                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9151                         is_owned: true,
9152                 }
9153         }
9154 }
9155 #[allow(unused)]
9156 /// Used only if an object of this type is returned as a trait impl by a method
9157 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
9158         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentUpdate)).clone() })) as *mut c_void
9159 }
9160 #[no_mangle]
9161 /// Creates a copy of the CommitmentUpdate
9162 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
9163         orig.clone()
9164 }
9165 /// Get a string which allows debug introspection of a CommitmentUpdate object
9166 pub extern "C" fn CommitmentUpdate_debug_str_void(o: *const c_void) -> Str {
9167         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentUpdate }).into()}
9168 /// Generates a non-cryptographic 64-bit hash of the CommitmentUpdate.
9169 #[no_mangle]
9170 pub extern "C" fn CommitmentUpdate_hash(o: &CommitmentUpdate) -> u64 {
9171         if o.inner.is_null() { return 0; }
9172         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
9173         #[allow(deprecated)]
9174         let mut hasher = core::hash::SipHasher::new();
9175         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
9176         core::hash::Hasher::finish(&hasher)
9177 }
9178 /// Checks if two CommitmentUpdates contain equal inner contents.
9179 /// This ignores pointers and is_owned flags and looks at the values in fields.
9180 /// Two objects with NULL inner values will be considered "equal" here.
9181 #[no_mangle]
9182 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
9183         if a.inner == b.inner { return true; }
9184         if a.inner.is_null() || b.inner.is_null() { return false; }
9185         if a.get_native_ref() == b.get_native_ref() { true } else { false }
9186 }
9187 /// A trait to describe an object which can receive channel messages.
9188 ///
9189 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
9190 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
9191 #[repr(C)]
9192 pub struct ChannelMessageHandler {
9193         /// An opaque pointer which is passed to your function implementations as an argument.
9194         /// This has no meaning in the LDK, and can be NULL or any other value.
9195         pub this_arg: *mut c_void,
9196         /// Handle an incoming `open_channel` message from the given peer.
9197         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),
9198         /// Handle an incoming `open_channel2` message from the given peer.
9199         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),
9200         /// Handle an incoming `accept_channel` message from the given peer.
9201         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),
9202         /// Handle an incoming `accept_channel2` message from the given peer.
9203         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),
9204         /// Handle an incoming `funding_created` message from the given peer.
9205         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),
9206         /// Handle an incoming `funding_signed` message from the given peer.
9207         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),
9208         /// Handle an incoming `channel_ready` message from the given peer.
9209         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),
9210         /// Handle an incoming `shutdown` message from the given peer.
9211         pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
9212         /// Handle an incoming `closing_signed` message from the given peer.
9213         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),
9214         /// Handle an incoming `stfu` message from the given peer.
9215         pub handle_stfu: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Stfu),
9216         /// Handle an incoming `tx_add_input message` from the given peer.
9217         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),
9218         /// Handle an incoming `tx_add_output` message from the given peer.
9219         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),
9220         /// Handle an incoming `tx_remove_input` message from the given peer.
9221         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),
9222         /// Handle an incoming `tx_remove_output` message from the given peer.
9223         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),
9224         /// Handle an incoming `tx_complete message` from the given peer.
9225         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),
9226         /// Handle an incoming `tx_signatures` message from the given peer.
9227         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),
9228         /// Handle an incoming `tx_init_rbf` message from the given peer.
9229         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),
9230         /// Handle an incoming `tx_ack_rbf` message from the given peer.
9231         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),
9232         /// Handle an incoming `tx_abort message` from the given peer.
9233         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),
9234         /// Handle an incoming `update_add_htlc` message from the given peer.
9235         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),
9236         /// Handle an incoming `update_fulfill_htlc` message from the given peer.
9237         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),
9238         /// Handle an incoming `update_fail_htlc` message from the given peer.
9239         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),
9240         /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
9241         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),
9242         /// Handle an incoming `commitment_signed` message from the given peer.
9243         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),
9244         /// Handle an incoming `revoke_and_ack` message from the given peer.
9245         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),
9246         /// Handle an incoming `update_fee` message from the given peer.
9247         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),
9248         /// Handle an incoming `announcement_signatures` message from the given peer.
9249         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),
9250         /// Indicates a connection to the peer failed/an existing connection was lost.
9251         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9252         /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
9253         ///
9254         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9255         /// with us. Implementors should be somewhat conservative about doing so, however, as other
9256         /// message handlers may still wish to communicate with this peer.
9257         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,
9258         /// Handle an incoming `channel_reestablish` message from the given peer.
9259         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),
9260         /// Handle an incoming `channel_update` message from the given peer.
9261         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),
9262         /// Handle an incoming `error` message from the given peer.
9263         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
9264         /// Gets the node feature flags which this handler itself supports. All available handlers are
9265         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9266         /// which are broadcasted in our [`NodeAnnouncement`] message.
9267         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9268         /// Gets the init feature flags which should be sent to the given peer. All available handlers
9269         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9270         /// which are sent in our [`Init`] message.
9271         ///
9272         /// Note that this method is called before [`Self::peer_connected`].
9273         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9274         /// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
9275         ///
9276         /// If it's `None`, then no particular network chain hash compatibility will be enforced when
9277         /// connecting to peers.
9278         pub get_chain_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ,
9279         /// Implementation of MessageSendEventsProvider for this object.
9280         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9281         /// Frees any resources associated with this object given its this_arg pointer.
9282         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9283         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9284 }
9285 unsafe impl Send for ChannelMessageHandler {}
9286 unsafe impl Sync for ChannelMessageHandler {}
9287 #[allow(unused)]
9288 pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
9289         ChannelMessageHandler {
9290                 this_arg: orig.this_arg,
9291                 handle_open_channel: Clone::clone(&orig.handle_open_channel),
9292                 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
9293                 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
9294                 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
9295                 handle_funding_created: Clone::clone(&orig.handle_funding_created),
9296                 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
9297                 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
9298                 handle_shutdown: Clone::clone(&orig.handle_shutdown),
9299                 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
9300                 handle_stfu: Clone::clone(&orig.handle_stfu),
9301                 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
9302                 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
9303                 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
9304                 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
9305                 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
9306                 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
9307                 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
9308                 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
9309                 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
9310                 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
9311                 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
9312                 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
9313                 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
9314                 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
9315                 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
9316                 handle_update_fee: Clone::clone(&orig.handle_update_fee),
9317                 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
9318                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9319                 peer_connected: Clone::clone(&orig.peer_connected),
9320                 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
9321                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9322                 handle_error: Clone::clone(&orig.handle_error),
9323                 provided_node_features: Clone::clone(&orig.provided_node_features),
9324                 provided_init_features: Clone::clone(&orig.provided_init_features),
9325                 get_chain_hashes: Clone::clone(&orig.get_chain_hashes),
9326                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9327                 free: Clone::clone(&orig.free),
9328         }
9329 }
9330 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
9331         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9332                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9333                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9334                 local_ret
9335         }
9336 }
9337
9338 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
9339 impl rustChannelMessageHandler for ChannelMessageHandler {
9340         fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
9341                 (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 })
9342         }
9343         fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
9344                 (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 })
9345         }
9346         fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
9347                 (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 })
9348         }
9349         fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
9350                 (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 })
9351         }
9352         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
9353                 (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 })
9354         }
9355         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
9356                 (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 })
9357         }
9358         fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
9359                 (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 })
9360         }
9361         fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
9362                 (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 })
9363         }
9364         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
9365                 (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 })
9366         }
9367         fn handle_stfu(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Stfu) {
9368                 (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 })
9369         }
9370         fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
9371                 (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 })
9372         }
9373         fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
9374                 (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 })
9375         }
9376         fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
9377                 (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 })
9378         }
9379         fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
9380                 (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 })
9381         }
9382         fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
9383                 (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 })
9384         }
9385         fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
9386                 (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 })
9387         }
9388         fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
9389                 (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 })
9390         }
9391         fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
9392                 (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 })
9393         }
9394         fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
9395                 (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 })
9396         }
9397         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
9398                 (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 })
9399         }
9400         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
9401                 (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 })
9402         }
9403         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
9404                 (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 })
9405         }
9406         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
9407                 (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 })
9408         }
9409         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
9410                 (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 })
9411         }
9412         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
9413                 (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 })
9414         }
9415         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
9416                 (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 })
9417         }
9418         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
9419                 (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 })
9420         }
9421         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9422                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9423         }
9424         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9425                 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);
9426                 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)) })*/ })};
9427                 local_ret
9428         }
9429         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
9430                 (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 })
9431         }
9432         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
9433                 (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 })
9434         }
9435         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
9436                 (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 })
9437         }
9438         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9439                 let mut ret = (self.provided_node_features)(self.this_arg);
9440                 *unsafe { Box::from_raw(ret.take_inner()) }
9441         }
9442         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9443                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9444                 *unsafe { Box::from_raw(ret.take_inner()) }
9445         }
9446         fn get_chain_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
9447                 let mut ret = (self.get_chain_hashes)(self.this_arg);
9448                 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 }})} };
9449                 local_ret
9450         }
9451 }
9452
9453 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9454 // directly as a Deref trait in higher-level structs:
9455 impl core::ops::Deref for ChannelMessageHandler {
9456         type Target = Self;
9457         fn deref(&self) -> &Self {
9458                 self
9459         }
9460 }
9461 impl core::ops::DerefMut for ChannelMessageHandler {
9462         fn deref_mut(&mut self) -> &mut Self {
9463                 self
9464         }
9465 }
9466 /// Calls the free function if one is set
9467 #[no_mangle]
9468 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
9469 impl Drop for ChannelMessageHandler {
9470         fn drop(&mut self) {
9471                 if let Some(f) = self.free {
9472                         f(self.this_arg);
9473                 }
9474         }
9475 }
9476 /// A trait to describe an object which can receive routing messages.
9477 ///
9478 /// # Implementor DoS Warnings
9479 ///
9480 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
9481 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
9482 /// repeated disk I/O for queries accessing different parts of the network graph.
9483 #[repr(C)]
9484 pub struct RoutingMessageHandler {
9485         /// An opaque pointer which is passed to your function implementations as an argument.
9486         /// This has no meaning in the LDK, and can be NULL or any other value.
9487         pub this_arg: *mut c_void,
9488         /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
9489         /// `false` or returning an `Err` otherwise.
9490         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9491         /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
9492         /// or returning an `Err` otherwise.
9493         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9494         /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
9495         /// `false` or returning an `Err` otherwise.
9496         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9497         /// Gets channel announcements and updates required to dump our routing table to a remote node,
9498         /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
9499         /// for a single channel.
9500         pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
9501         /// Gets a node announcement required to dump our routing table to a remote node, starting at
9502         /// the node *after* the provided pubkey and including up to one announcement immediately
9503         /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
9504         /// If `None` is provided for `starting_point`, we start at the first node.
9505         ///
9506         /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
9507         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9508         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,
9509         /// Called when a connection is established with a peer. This can be used to
9510         /// perform routing table synchronization using a strategy defined by the
9511         /// implementor.
9512         ///
9513         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9514         /// with us. Implementors should be somewhat conservative about doing so, however, as other
9515         /// message handlers may still wish to communicate with this peer.
9516         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,
9517         /// Handles the reply of a query we initiated to learn about channels
9518         /// for a given range of blocks. We can expect to receive one or more
9519         /// replies to a single query.
9520         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,
9521         /// Handles the reply of a query we initiated asking for routing gossip
9522         /// messages for a list of channels. We should receive this message when
9523         /// a node has completed its best effort to send us the pertaining routing
9524         /// gossip messages.
9525         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,
9526         /// Handles when a peer asks us to send a list of `short_channel_id`s
9527         /// for the requested range of blocks.
9528         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,
9529         /// Handles when a peer asks us to send routing gossip messages for a
9530         /// list of `short_channel_id`s.
9531         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,
9532         /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
9533         /// pending some async action. While there is no guarantee of the rate of future messages, the
9534         /// caller should seek to reduce the rate of new gossip messages handled, especially
9535         /// [`ChannelAnnouncement`]s.
9536         pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
9537         /// Gets the node feature flags which this handler itself supports. All available handlers are
9538         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9539         /// which are broadcasted in our [`NodeAnnouncement`] message.
9540         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9541         /// Gets the init feature flags which should be sent to the given peer. All available handlers
9542         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9543         /// which are sent in our [`Init`] message.
9544         ///
9545         /// Note that this method is called before [`Self::peer_connected`].
9546         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9547         /// Implementation of MessageSendEventsProvider for this object.
9548         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9549         /// Frees any resources associated with this object given its this_arg pointer.
9550         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9551         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9552 }
9553 unsafe impl Send for RoutingMessageHandler {}
9554 unsafe impl Sync for RoutingMessageHandler {}
9555 #[allow(unused)]
9556 pub(crate) fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
9557         RoutingMessageHandler {
9558                 this_arg: orig.this_arg,
9559                 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
9560                 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
9561                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9562                 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
9563                 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
9564                 peer_connected: Clone::clone(&orig.peer_connected),
9565                 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
9566                 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
9567                 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
9568                 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
9569                 processing_queue_high: Clone::clone(&orig.processing_queue_high),
9570                 provided_node_features: Clone::clone(&orig.provided_node_features),
9571                 provided_init_features: Clone::clone(&orig.provided_init_features),
9572                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9573                 free: Clone::clone(&orig.free),
9574         }
9575 }
9576 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
9577         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9578                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9579                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9580                 local_ret
9581         }
9582 }
9583
9584 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
9585 impl rustRoutingMessageHandler for RoutingMessageHandler {
9586         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9587                 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 });
9588                 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()) } })};
9589                 local_ret
9590         }
9591         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9592                 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 });
9593                 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()) } })};
9594                 local_ret
9595         }
9596         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
9597                 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 });
9598                 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()) } })};
9599                 local_ret
9600         }
9601         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>)> {
9602                 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
9603                 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 };
9604                 local_ret
9605         }
9606         fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
9607                 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 };
9608                 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
9609                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9610                 local_ret
9611         }
9612         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9613                 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);
9614                 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)) })*/ })};
9615                 local_ret
9616         }
9617         fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9618                 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 });
9619                 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()) } })};
9620                 local_ret
9621         }
9622         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> {
9623                 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 });
9624                 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()) } })};
9625                 local_ret
9626         }
9627         fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9628                 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 });
9629                 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()) } })};
9630                 local_ret
9631         }
9632         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> {
9633                 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 });
9634                 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()) } })};
9635                 local_ret
9636         }
9637         fn processing_queue_high(&self) -> bool {
9638                 let mut ret = (self.processing_queue_high)(self.this_arg);
9639                 ret
9640         }
9641         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9642                 let mut ret = (self.provided_node_features)(self.this_arg);
9643                 *unsafe { Box::from_raw(ret.take_inner()) }
9644         }
9645         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9646                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9647                 *unsafe { Box::from_raw(ret.take_inner()) }
9648         }
9649 }
9650
9651 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9652 // directly as a Deref trait in higher-level structs:
9653 impl core::ops::Deref for RoutingMessageHandler {
9654         type Target = Self;
9655         fn deref(&self) -> &Self {
9656                 self
9657         }
9658 }
9659 impl core::ops::DerefMut for RoutingMessageHandler {
9660         fn deref_mut(&mut self) -> &mut Self {
9661                 self
9662         }
9663 }
9664 /// Calls the free function if one is set
9665 #[no_mangle]
9666 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
9667 impl Drop for RoutingMessageHandler {
9668         fn drop(&mut self) {
9669                 if let Some(f) = self.free {
9670                         f(self.this_arg);
9671                 }
9672         }
9673 }
9674 /// A handler for received [`OnionMessage`]s and for providing generated ones to send.
9675 #[repr(C)]
9676 pub struct OnionMessageHandler {
9677         /// An opaque pointer which is passed to your function implementations as an argument.
9678         /// This has no meaning in the LDK, and can be NULL or any other value.
9679         pub this_arg: *mut c_void,
9680         /// Because much of the lightning network does not yet support forwarding onion messages, we
9681         /// may need to directly connect to a node which will forward a message for us. In such a case,
9682         /// this method will return the set of nodes which need connection by node_id and the
9683         /// corresponding socket addresses where they may accept incoming connections.
9684         ///
9685         /// Thus, this method should be polled regularly to detect messages await such a direct
9686         /// connection.
9687         pub get_and_clear_connections_needed: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ,
9688         /// Handle an incoming `onion_message` message from the given peer.
9689         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),
9690         /// Returns the next pending onion message for the peer with the given node id.
9691         ///
9692         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9693         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,
9694         /// Called when a connection is established with a peer. Can be used to track which peers
9695         /// advertise onion message support and are online.
9696         ///
9697         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9698         /// with us. Implementors should be somewhat conservative about doing so, however, as other
9699         /// message handlers may still wish to communicate with this peer.
9700         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,
9701         /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
9702         /// drop and refuse to forward onion messages to this peer.
9703         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9704         /// Performs actions that should happen roughly every ten seconds after startup. Allows handlers
9705         /// to drop any buffered onion messages intended for prospective peers.
9706         pub timer_tick_occurred: extern "C" fn (this_arg: *const c_void),
9707         /// Gets the node feature flags which this handler itself supports. All available handlers are
9708         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9709         /// which are broadcasted in our [`NodeAnnouncement`] message.
9710         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9711         /// Gets the init feature flags which should be sent to the given peer. All available handlers
9712         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9713         /// which are sent in our [`Init`] message.
9714         ///
9715         /// Note that this method is called before [`Self::peer_connected`].
9716         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9717         /// Frees any resources associated with this object given its this_arg pointer.
9718         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9719         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9720 }
9721 unsafe impl Send for OnionMessageHandler {}
9722 unsafe impl Sync for OnionMessageHandler {}
9723 #[allow(unused)]
9724 pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
9725         OnionMessageHandler {
9726                 this_arg: orig.this_arg,
9727                 get_and_clear_connections_needed: Clone::clone(&orig.get_and_clear_connections_needed),
9728                 handle_onion_message: Clone::clone(&orig.handle_onion_message),
9729                 next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
9730                 peer_connected: Clone::clone(&orig.peer_connected),
9731                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9732                 timer_tick_occurred: Clone::clone(&orig.timer_tick_occurred),
9733                 provided_node_features: Clone::clone(&orig.provided_node_features),
9734                 provided_init_features: Clone::clone(&orig.provided_init_features),
9735                 free: Clone::clone(&orig.free),
9736         }
9737 }
9738
9739 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
9740 impl rustOnionMessageHandler for OnionMessageHandler {
9741         fn get_and_clear_connections_needed(&self) -> Vec<(bitcoin::secp256k1::PublicKey, Vec<lightning::ln::msgs::SocketAddress>)> {
9742                 let mut ret = (self.get_and_clear_connections_needed)(self.this_arg);
9743                 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 }); };
9744                 local_ret
9745         }
9746         fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
9747                 (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 })
9748         }
9749         fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
9750                 let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
9751                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9752                 local_ret
9753         }
9754         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9755                 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);
9756                 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)) })*/ })};
9757                 local_ret
9758         }
9759         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9760                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9761         }
9762         fn timer_tick_occurred(&self) {
9763                 (self.timer_tick_occurred)(self.this_arg)
9764         }
9765         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9766                 let mut ret = (self.provided_node_features)(self.this_arg);
9767                 *unsafe { Box::from_raw(ret.take_inner()) }
9768         }
9769         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9770                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9771                 *unsafe { Box::from_raw(ret.take_inner()) }
9772         }
9773 }
9774
9775 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9776 // directly as a Deref trait in higher-level structs:
9777 impl core::ops::Deref for OnionMessageHandler {
9778         type Target = Self;
9779         fn deref(&self) -> &Self {
9780                 self
9781         }
9782 }
9783 impl core::ops::DerefMut for OnionMessageHandler {
9784         fn deref_mut(&mut self) -> &mut Self {
9785                 self
9786         }
9787 }
9788 /// Calls the free function if one is set
9789 #[no_mangle]
9790 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
9791 impl Drop for OnionMessageHandler {
9792         fn drop(&mut self) {
9793                 if let Some(f) = self.free {
9794                         f(self.this_arg);
9795                 }
9796         }
9797 }
9798
9799 use lightning::ln::msgs::FinalOnionHopData as nativeFinalOnionHopDataImport;
9800 pub(crate) type nativeFinalOnionHopData = nativeFinalOnionHopDataImport;
9801
9802 /// Information communicated in the onion to the recipient for multi-part tracking and proof that
9803 /// the payment is associated with an invoice.
9804 #[must_use]
9805 #[repr(C)]
9806 pub struct FinalOnionHopData {
9807         /// A pointer to the opaque Rust object.
9808
9809         /// Nearly everywhere, inner must be non-null, however in places where
9810         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9811         pub inner: *mut nativeFinalOnionHopData,
9812         /// Indicates that this is the only struct which contains the same pointer.
9813
9814         /// Rust functions which take ownership of an object provided via an argument require
9815         /// this to be true and invalidate the object pointed to by inner.
9816         pub is_owned: bool,
9817 }
9818
9819 impl Drop for FinalOnionHopData {
9820         fn drop(&mut self) {
9821                 if self.is_owned && !<*mut nativeFinalOnionHopData>::is_null(self.inner) {
9822                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9823                 }
9824         }
9825 }
9826 /// Frees any resources used by the FinalOnionHopData, if is_owned is set and inner is non-NULL.
9827 #[no_mangle]
9828 pub extern "C" fn FinalOnionHopData_free(this_obj: FinalOnionHopData) { }
9829 #[allow(unused)]
9830 /// Used only if an object of this type is returned as a trait impl by a method
9831 pub(crate) extern "C" fn FinalOnionHopData_free_void(this_ptr: *mut c_void) {
9832         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFinalOnionHopData) };
9833 }
9834 #[allow(unused)]
9835 impl FinalOnionHopData {
9836         pub(crate) fn get_native_ref(&self) -> &'static nativeFinalOnionHopData {
9837                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9838         }
9839         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFinalOnionHopData {
9840                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9841         }
9842         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9843         pub(crate) fn take_inner(mut self) -> *mut nativeFinalOnionHopData {
9844                 assert!(self.is_owned);
9845                 let ret = ObjOps::untweak_ptr(self.inner);
9846                 self.inner = core::ptr::null_mut();
9847                 ret
9848         }
9849 }
9850 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9851 /// Because it is generated by the recipient and included in the invoice, it also provides
9852 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9853 #[no_mangle]
9854 pub extern "C" fn FinalOnionHopData_get_payment_secret(this_ptr: &FinalOnionHopData) -> *const [u8; 32] {
9855         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret;
9856         &inner_val.0
9857 }
9858 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9859 /// Because it is generated by the recipient and included in the invoice, it also provides
9860 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9861 #[no_mangle]
9862 pub extern "C" fn FinalOnionHopData_set_payment_secret(this_ptr: &mut FinalOnionHopData, mut val: crate::c_types::ThirtyTwoBytes) {
9863         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::types::PaymentSecret(val.data);
9864 }
9865 /// The intended total amount that this payment is for.
9866 ///
9867 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9868 #[no_mangle]
9869 pub extern "C" fn FinalOnionHopData_get_total_msat(this_ptr: &FinalOnionHopData) -> u64 {
9870         let mut inner_val = &mut this_ptr.get_native_mut_ref().total_msat;
9871         *inner_val
9872 }
9873 /// The intended total amount that this payment is for.
9874 ///
9875 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9876 #[no_mangle]
9877 pub extern "C" fn FinalOnionHopData_set_total_msat(this_ptr: &mut FinalOnionHopData, mut val: u64) {
9878         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.total_msat = val;
9879 }
9880 /// Constructs a new FinalOnionHopData given each field
9881 #[must_use]
9882 #[no_mangle]
9883 pub extern "C" fn FinalOnionHopData_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut total_msat_arg: u64) -> FinalOnionHopData {
9884         FinalOnionHopData { inner: ObjOps::heap_alloc(nativeFinalOnionHopData {
9885                 payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret_arg.data),
9886                 total_msat: total_msat_arg,
9887         }), is_owned: true }
9888 }
9889 impl Clone for FinalOnionHopData {
9890         fn clone(&self) -> Self {
9891                 Self {
9892                         inner: if <*mut nativeFinalOnionHopData>::is_null(self.inner) { core::ptr::null_mut() } else {
9893                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9894                         is_owned: true,
9895                 }
9896         }
9897 }
9898 #[allow(unused)]
9899 /// Used only if an object of this type is returned as a trait impl by a method
9900 pub(crate) extern "C" fn FinalOnionHopData_clone_void(this_ptr: *const c_void) -> *mut c_void {
9901         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFinalOnionHopData)).clone() })) as *mut c_void
9902 }
9903 #[no_mangle]
9904 /// Creates a copy of the FinalOnionHopData
9905 pub extern "C" fn FinalOnionHopData_clone(orig: &FinalOnionHopData) -> FinalOnionHopData {
9906         orig.clone()
9907 }
9908 mod fuzzy_internal_msgs {
9909
9910 use alloc::str::FromStr;
9911 use alloc::string::String;
9912 use core::ffi::c_void;
9913 use core::convert::Infallible;
9914 use bitcoin::hashes::Hash;
9915 use crate::c_types::*;
9916 #[cfg(feature="no-std")]
9917 use alloc::{vec::Vec, boxed::Box};
9918
9919 }
9920
9921 use lightning::ln::msgs::OnionPacket as nativeOnionPacketImport;
9922 pub(crate) type nativeOnionPacket = nativeOnionPacketImport;
9923
9924 /// BOLT 4 onion packet including hop data for the next peer.
9925 #[must_use]
9926 #[repr(C)]
9927 pub struct OnionPacket {
9928         /// A pointer to the opaque Rust object.
9929
9930         /// Nearly everywhere, inner must be non-null, however in places where
9931         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9932         pub inner: *mut nativeOnionPacket,
9933         /// Indicates that this is the only struct which contains the same pointer.
9934
9935         /// Rust functions which take ownership of an object provided via an argument require
9936         /// this to be true and invalidate the object pointed to by inner.
9937         pub is_owned: bool,
9938 }
9939
9940 impl Drop for OnionPacket {
9941         fn drop(&mut self) {
9942                 if self.is_owned && !<*mut nativeOnionPacket>::is_null(self.inner) {
9943                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9944                 }
9945         }
9946 }
9947 /// Frees any resources used by the OnionPacket, if is_owned is set and inner is non-NULL.
9948 #[no_mangle]
9949 pub extern "C" fn OnionPacket_free(this_obj: OnionPacket) { }
9950 #[allow(unused)]
9951 /// Used only if an object of this type is returned as a trait impl by a method
9952 pub(crate) extern "C" fn OnionPacket_free_void(this_ptr: *mut c_void) {
9953         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionPacket) };
9954 }
9955 #[allow(unused)]
9956 impl OnionPacket {
9957         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionPacket {
9958                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9959         }
9960         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionPacket {
9961                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9962         }
9963         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9964         pub(crate) fn take_inner(mut self) -> *mut nativeOnionPacket {
9965                 assert!(self.is_owned);
9966                 let ret = ObjOps::untweak_ptr(self.inner);
9967                 self.inner = core::ptr::null_mut();
9968                 ret
9969         }
9970 }
9971 /// BOLT 4 version number.
9972 #[no_mangle]
9973 pub extern "C" fn OnionPacket_get_version(this_ptr: &OnionPacket) -> u8 {
9974         let mut inner_val = &mut this_ptr.get_native_mut_ref().version;
9975         *inner_val
9976 }
9977 /// BOLT 4 version number.
9978 #[no_mangle]
9979 pub extern "C" fn OnionPacket_set_version(this_ptr: &mut OnionPacket, mut val: u8) {
9980         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val;
9981 }
9982 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
9983 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
9984 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
9985 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
9986 /// like.
9987 ///
9988 /// Returns a copy of the field.
9989 #[no_mangle]
9990 pub extern "C" fn OnionPacket_get_public_key(this_ptr: &OnionPacket) -> crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ {
9991         let mut inner_val = this_ptr.get_native_mut_ref().public_key.clone();
9992         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() };
9993         local_inner_val
9994 }
9995 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
9996 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
9997 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
9998 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
9999 /// like.
10000 #[no_mangle]
10001 pub extern "C" fn OnionPacket_set_public_key(this_ptr: &mut OnionPacket, mut val: crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ) {
10002         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() })};
10003         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = local_val;
10004 }
10005 /// HMAC to verify the integrity of hop_data.
10006 #[no_mangle]
10007 pub extern "C" fn OnionPacket_get_hmac(this_ptr: &OnionPacket) -> *const [u8; 32] {
10008         let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac;
10009         inner_val
10010 }
10011 /// HMAC to verify the integrity of hop_data.
10012 #[no_mangle]
10013 pub extern "C" fn OnionPacket_set_hmac(this_ptr: &mut OnionPacket, mut val: crate::c_types::ThirtyTwoBytes) {
10014         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data;
10015 }
10016 impl Clone for OnionPacket {
10017         fn clone(&self) -> Self {
10018                 Self {
10019                         inner: if <*mut nativeOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else {
10020                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
10021                         is_owned: true,
10022                 }
10023         }
10024 }
10025 #[allow(unused)]
10026 /// Used only if an object of this type is returned as a trait impl by a method
10027 pub(crate) extern "C" fn OnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void {
10028         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionPacket)).clone() })) as *mut c_void
10029 }
10030 #[no_mangle]
10031 /// Creates a copy of the OnionPacket
10032 pub extern "C" fn OnionPacket_clone(orig: &OnionPacket) -> OnionPacket {
10033         orig.clone()
10034 }
10035 /// Generates a non-cryptographic 64-bit hash of the OnionPacket.
10036 #[no_mangle]
10037 pub extern "C" fn OnionPacket_hash(o: &OnionPacket) -> u64 {
10038         if o.inner.is_null() { return 0; }
10039         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
10040         #[allow(deprecated)]
10041         let mut hasher = core::hash::SipHasher::new();
10042         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
10043         core::hash::Hasher::finish(&hasher)
10044 }
10045 /// Checks if two OnionPackets contain equal inner contents.
10046 /// This ignores pointers and is_owned flags and looks at the values in fields.
10047 /// Two objects with NULL inner values will be considered "equal" here.
10048 #[no_mangle]
10049 pub extern "C" fn OnionPacket_eq(a: &OnionPacket, b: &OnionPacket) -> bool {
10050         if a.inner == b.inner { return true; }
10051         if a.inner.is_null() || b.inner.is_null() { return false; }
10052         if a.get_native_ref() == b.get_native_ref() { true } else { false }
10053 }
10054 /// Get a string which allows debug introspection of a OnionPacket object
10055 pub extern "C" fn OnionPacket_debug_str_void(o: *const c_void) -> Str {
10056         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionPacket }).into()}
10057
10058 use lightning::ln::msgs::TrampolineOnionPacket as nativeTrampolineOnionPacketImport;
10059 pub(crate) type nativeTrampolineOnionPacket = nativeTrampolineOnionPacketImport;
10060
10061 /// BOLT 4 onion packet including hop data for the next peer.
10062 #[must_use]
10063 #[repr(C)]
10064 pub struct TrampolineOnionPacket {
10065         /// A pointer to the opaque Rust object.
10066
10067         /// Nearly everywhere, inner must be non-null, however in places where
10068         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
10069         pub inner: *mut nativeTrampolineOnionPacket,
10070         /// Indicates that this is the only struct which contains the same pointer.
10071
10072         /// Rust functions which take ownership of an object provided via an argument require
10073         /// this to be true and invalidate the object pointed to by inner.
10074         pub is_owned: bool,
10075 }
10076
10077 impl Drop for TrampolineOnionPacket {
10078         fn drop(&mut self) {
10079                 if self.is_owned && !<*mut nativeTrampolineOnionPacket>::is_null(self.inner) {
10080                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
10081                 }
10082         }
10083 }
10084 /// Frees any resources used by the TrampolineOnionPacket, if is_owned is set and inner is non-NULL.
10085 #[no_mangle]
10086 pub extern "C" fn TrampolineOnionPacket_free(this_obj: TrampolineOnionPacket) { }
10087 #[allow(unused)]
10088 /// Used only if an object of this type is returned as a trait impl by a method
10089 pub(crate) extern "C" fn TrampolineOnionPacket_free_void(this_ptr: *mut c_void) {
10090         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTrampolineOnionPacket) };
10091 }
10092 #[allow(unused)]
10093 impl TrampolineOnionPacket {
10094         pub(crate) fn get_native_ref(&self) -> &'static nativeTrampolineOnionPacket {
10095                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
10096         }
10097         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTrampolineOnionPacket {
10098                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
10099         }
10100         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
10101         pub(crate) fn take_inner(mut self) -> *mut nativeTrampolineOnionPacket {
10102                 assert!(self.is_owned);
10103                 let ret = ObjOps::untweak_ptr(self.inner);
10104                 self.inner = core::ptr::null_mut();
10105                 ret
10106         }
10107 }
10108 /// Bolt 04 version number
10109 #[no_mangle]
10110 pub extern "C" fn TrampolineOnionPacket_get_version(this_ptr: &TrampolineOnionPacket) -> u8 {
10111         let mut inner_val = &mut this_ptr.get_native_mut_ref().version;
10112         *inner_val
10113 }
10114 /// Bolt 04 version number
10115 #[no_mangle]
10116 pub extern "C" fn TrampolineOnionPacket_set_version(this_ptr: &mut TrampolineOnionPacket, mut val: u8) {
10117         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val;
10118 }
10119 /// A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
10120 #[no_mangle]
10121 pub extern "C" fn TrampolineOnionPacket_get_public_key(this_ptr: &TrampolineOnionPacket) -> crate::c_types::PublicKey {
10122         let mut inner_val = &mut this_ptr.get_native_mut_ref().public_key;
10123         crate::c_types::PublicKey::from_rust(&inner_val)
10124 }
10125 /// A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
10126 #[no_mangle]
10127 pub extern "C" fn TrampolineOnionPacket_set_public_key(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::PublicKey) {
10128         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = val.into_rust();
10129 }
10130 /// Encrypted payload for the next hop
10131 ///
10132 /// Returns a copy of the field.
10133 #[no_mangle]
10134 pub extern "C" fn TrampolineOnionPacket_get_hop_data(this_ptr: &TrampolineOnionPacket) -> crate::c_types::derived::CVec_u8Z {
10135         let mut inner_val = this_ptr.get_native_mut_ref().hop_data.clone();
10136         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
10137         local_inner_val.into()
10138 }
10139 /// Encrypted payload for the next hop
10140 #[no_mangle]
10141 pub extern "C" fn TrampolineOnionPacket_set_hop_data(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::derived::CVec_u8Z) {
10142         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
10143         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hop_data = local_val;
10144 }
10145 /// HMAC to verify the integrity of hop_data
10146 #[no_mangle]
10147 pub extern "C" fn TrampolineOnionPacket_get_hmac(this_ptr: &TrampolineOnionPacket) -> *const [u8; 32] {
10148         let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac;
10149         inner_val
10150 }
10151 /// HMAC to verify the integrity of hop_data
10152 #[no_mangle]
10153 pub extern "C" fn TrampolineOnionPacket_set_hmac(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::ThirtyTwoBytes) {
10154         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data;
10155 }
10156 /// Constructs a new TrampolineOnionPacket given each field
10157 #[must_use]
10158 #[no_mangle]
10159 pub extern "C" fn TrampolineOnionPacket_new(mut version_arg: u8, mut public_key_arg: crate::c_types::PublicKey, mut hop_data_arg: crate::c_types::derived::CVec_u8Z, mut hmac_arg: crate::c_types::ThirtyTwoBytes) -> TrampolineOnionPacket {
10160         let mut local_hop_data_arg = Vec::new(); for mut item in hop_data_arg.into_rust().drain(..) { local_hop_data_arg.push( { item }); };
10161         TrampolineOnionPacket { inner: ObjOps::heap_alloc(nativeTrampolineOnionPacket {
10162                 version: version_arg,
10163                 public_key: public_key_arg.into_rust(),
10164                 hop_data: local_hop_data_arg,
10165                 hmac: hmac_arg.data,
10166         }), is_owned: true }
10167 }
10168 impl Clone for TrampolineOnionPacket {
10169         fn clone(&self) -> Self {
10170                 Self {
10171                         inner: if <*mut nativeTrampolineOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else {
10172                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
10173                         is_owned: true,
10174                 }
10175         }
10176 }
10177 #[allow(unused)]
10178 /// Used only if an object of this type is returned as a trait impl by a method
10179 pub(crate) extern "C" fn TrampolineOnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void {
10180         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTrampolineOnionPacket)).clone() })) as *mut c_void
10181 }
10182 #[no_mangle]
10183 /// Creates a copy of the TrampolineOnionPacket
10184 pub extern "C" fn TrampolineOnionPacket_clone(orig: &TrampolineOnionPacket) -> TrampolineOnionPacket {
10185         orig.clone()
10186 }
10187 /// Generates a non-cryptographic 64-bit hash of the TrampolineOnionPacket.
10188 #[no_mangle]
10189 pub extern "C" fn TrampolineOnionPacket_hash(o: &TrampolineOnionPacket) -> u64 {
10190         if o.inner.is_null() { return 0; }
10191         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
10192         #[allow(deprecated)]
10193         let mut hasher = core::hash::SipHasher::new();
10194         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
10195         core::hash::Hasher::finish(&hasher)
10196 }
10197 /// Checks if two TrampolineOnionPackets contain equal inner contents.
10198 /// This ignores pointers and is_owned flags and looks at the values in fields.
10199 /// Two objects with NULL inner values will be considered "equal" here.
10200 #[no_mangle]
10201 pub extern "C" fn TrampolineOnionPacket_eq(a: &TrampolineOnionPacket, b: &TrampolineOnionPacket) -> bool {
10202         if a.inner == b.inner { return true; }
10203         if a.inner.is_null() || b.inner.is_null() { return false; }
10204         if a.get_native_ref() == b.get_native_ref() { true } else { false }
10205 }
10206 #[no_mangle]
10207 /// Serialize the TrampolineOnionPacket object into a byte array which can be read by TrampolineOnionPacket_read
10208 pub extern "C" fn TrampolineOnionPacket_write(obj: &crate::lightning::ln::msgs::TrampolineOnionPacket) -> crate::c_types::derived::CVec_u8Z {
10209         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10210 }
10211 #[allow(unused)]
10212 pub(crate) extern "C" fn TrampolineOnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10213         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTrampolineOnionPacket) })
10214 }
10215 /// Get a string which allows debug introspection of a TrampolineOnionPacket object
10216 pub extern "C" fn TrampolineOnionPacket_debug_str_void(o: *const c_void) -> Str {
10217         alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TrampolineOnionPacket }).into()}
10218 #[no_mangle]
10219 /// Get the string representation of a DecodeError object
10220 pub extern "C" fn DecodeError_to_str(o: &crate::lightning::ln::msgs::DecodeError) -> Str {
10221         alloc::format!("{}", &o.to_native()).into()
10222 }
10223 #[no_mangle]
10224 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
10225 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
10226         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10227 }
10228 #[allow(unused)]
10229 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10230         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
10231 }
10232 #[no_mangle]
10233 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
10234 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
10235         let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10236         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() };
10237         local_res
10238 }
10239 #[no_mangle]
10240 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
10241 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
10242         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10243 }
10244 #[allow(unused)]
10245 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10246         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
10247 }
10248 #[no_mangle]
10249 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
10250 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
10251         let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10252         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() };
10253         local_res
10254 }
10255 #[no_mangle]
10256 /// Serialize the Stfu object into a byte array which can be read by Stfu_read
10257 pub extern "C" fn Stfu_write(obj: &crate::lightning::ln::msgs::Stfu) -> crate::c_types::derived::CVec_u8Z {
10258         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10259 }
10260 #[allow(unused)]
10261 pub(crate) extern "C" fn Stfu_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10262         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStfu) })
10263 }
10264 #[no_mangle]
10265 /// Read a Stfu from a byte array, created by Stfu_write
10266 pub extern "C" fn Stfu_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_StfuDecodeErrorZ {
10267         let res: Result<lightning::ln::msgs::Stfu, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10268         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() };
10269         local_res
10270 }
10271 #[no_mangle]
10272 /// Serialize the Splice object into a byte array which can be read by Splice_read
10273 pub extern "C" fn Splice_write(obj: &crate::lightning::ln::msgs::Splice) -> crate::c_types::derived::CVec_u8Z {
10274         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10275 }
10276 #[allow(unused)]
10277 pub(crate) extern "C" fn Splice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10278         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSplice) })
10279 }
10280 #[no_mangle]
10281 /// Read a Splice from a byte array, created by Splice_write
10282 pub extern "C" fn Splice_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceDecodeErrorZ {
10283         let res: Result<lightning::ln::msgs::Splice, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10284         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() };
10285         local_res
10286 }
10287 #[no_mangle]
10288 /// Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read
10289 pub extern "C" fn SpliceAck_write(obj: &crate::lightning::ln::msgs::SpliceAck) -> crate::c_types::derived::CVec_u8Z {
10290         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10291 }
10292 #[allow(unused)]
10293 pub(crate) extern "C" fn SpliceAck_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10294         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceAck) })
10295 }
10296 #[no_mangle]
10297 /// Read a SpliceAck from a byte array, created by SpliceAck_write
10298 pub extern "C" fn SpliceAck_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceAckDecodeErrorZ {
10299         let res: Result<lightning::ln::msgs::SpliceAck, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10300         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() };
10301         local_res
10302 }
10303 #[no_mangle]
10304 /// Serialize the SpliceLocked object into a byte array which can be read by SpliceLocked_read
10305 pub extern "C" fn SpliceLocked_write(obj: &crate::lightning::ln::msgs::SpliceLocked) -> crate::c_types::derived::CVec_u8Z {
10306         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10307 }
10308 #[allow(unused)]
10309 pub(crate) extern "C" fn SpliceLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10310         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceLocked) })
10311 }
10312 #[no_mangle]
10313 /// Read a SpliceLocked from a byte array, created by SpliceLocked_write
10314 pub extern "C" fn SpliceLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceLockedDecodeErrorZ {
10315         let res: Result<lightning::ln::msgs::SpliceLocked, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10316         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() };
10317         local_res
10318 }
10319 #[no_mangle]
10320 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
10321 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
10322         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10323 }
10324 #[allow(unused)]
10325 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10326         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
10327 }
10328 #[no_mangle]
10329 /// Read a TxAddInput from a byte array, created by TxAddInput_write
10330 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
10331         let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10332         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() };
10333         local_res
10334 }
10335 #[no_mangle]
10336 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
10337 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
10338         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10339 }
10340 #[allow(unused)]
10341 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10342         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
10343 }
10344 #[no_mangle]
10345 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
10346 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
10347         let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10348         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() };
10349         local_res
10350 }
10351 #[no_mangle]
10352 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
10353 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
10354         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10355 }
10356 #[allow(unused)]
10357 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10358         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
10359 }
10360 #[no_mangle]
10361 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
10362 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
10363         let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10364         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() };
10365         local_res
10366 }
10367 #[no_mangle]
10368 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
10369 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
10370         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10371 }
10372 #[allow(unused)]
10373 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10374         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
10375 }
10376 #[no_mangle]
10377 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
10378 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
10379         let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10380         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() };
10381         local_res
10382 }
10383 #[no_mangle]
10384 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
10385 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
10386         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10387 }
10388 #[allow(unused)]
10389 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10390         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
10391 }
10392 #[no_mangle]
10393 /// Read a TxComplete from a byte array, created by TxComplete_write
10394 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
10395         let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10396         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() };
10397         local_res
10398 }
10399 #[no_mangle]
10400 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
10401 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
10402         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10403 }
10404 #[allow(unused)]
10405 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10406         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
10407 }
10408 #[no_mangle]
10409 /// Read a TxSignatures from a byte array, created by TxSignatures_write
10410 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
10411         let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10412         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() };
10413         local_res
10414 }
10415 #[no_mangle]
10416 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
10417 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
10418         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10419 }
10420 #[allow(unused)]
10421 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10422         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
10423 }
10424 #[no_mangle]
10425 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
10426 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
10427         let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10428         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() };
10429         local_res
10430 }
10431 #[no_mangle]
10432 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
10433 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
10434         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10435 }
10436 #[allow(unused)]
10437 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10438         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
10439 }
10440 #[no_mangle]
10441 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
10442 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
10443         let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10444         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() };
10445         local_res
10446 }
10447 #[no_mangle]
10448 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
10449 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
10450         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10451 }
10452 #[allow(unused)]
10453 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10454         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
10455 }
10456 #[no_mangle]
10457 /// Read a TxAbort from a byte array, created by TxAbort_write
10458 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
10459         let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10460         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() };
10461         local_res
10462 }
10463 #[no_mangle]
10464 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
10465 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
10466         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10467 }
10468 #[allow(unused)]
10469 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10470         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
10471 }
10472 #[no_mangle]
10473 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
10474 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
10475         let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10476         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() };
10477         local_res
10478 }
10479 #[no_mangle]
10480 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
10481 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
10482         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10483 }
10484 #[allow(unused)]
10485 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10486         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
10487 }
10488 #[no_mangle]
10489 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
10490 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
10491         let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10492         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() };
10493         local_res
10494 }
10495 #[no_mangle]
10496 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
10497 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
10498         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10499 }
10500 #[allow(unused)]
10501 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10502         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
10503 }
10504 #[no_mangle]
10505 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
10506 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
10507         let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10508         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() };
10509         local_res
10510 }
10511 #[no_mangle]
10512 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
10513 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
10514         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10515 }
10516 #[allow(unused)]
10517 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10518         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
10519 }
10520 #[no_mangle]
10521 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
10522 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
10523         let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10524         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() };
10525         local_res
10526 }
10527 #[no_mangle]
10528 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
10529 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
10530         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10531 }
10532 #[allow(unused)]
10533 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10534         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
10535 }
10536 #[no_mangle]
10537 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
10538 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
10539         let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10540         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() };
10541         local_res
10542 }
10543 #[no_mangle]
10544 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
10545 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
10546         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10547 }
10548 #[allow(unused)]
10549 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10550         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
10551 }
10552 #[no_mangle]
10553 /// Read a FundingCreated from a byte array, created by FundingCreated_write
10554 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
10555         let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10556         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() };
10557         local_res
10558 }
10559 #[no_mangle]
10560 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
10561 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
10562         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10563 }
10564 #[allow(unused)]
10565 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10566         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
10567 }
10568 #[no_mangle]
10569 /// Read a FundingSigned from a byte array, created by FundingSigned_write
10570 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
10571         let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10572         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() };
10573         local_res
10574 }
10575 #[no_mangle]
10576 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
10577 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
10578         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10579 }
10580 #[allow(unused)]
10581 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10582         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
10583 }
10584 #[no_mangle]
10585 /// Read a ChannelReady from a byte array, created by ChannelReady_write
10586 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
10587         let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10588         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() };
10589         local_res
10590 }
10591 #[no_mangle]
10592 /// Serialize the Init object into a byte array which can be read by Init_read
10593 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
10594         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10595 }
10596 #[allow(unused)]
10597 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10598         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
10599 }
10600 #[no_mangle]
10601 /// Read a Init from a byte array, created by Init_write
10602 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
10603         let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10604         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() };
10605         local_res
10606 }
10607 #[no_mangle]
10608 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
10609 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
10610         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10611 }
10612 #[allow(unused)]
10613 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10614         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
10615 }
10616 #[no_mangle]
10617 /// Read a OpenChannel from a byte array, created by OpenChannel_write
10618 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
10619         let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10620         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() };
10621         local_res
10622 }
10623 #[no_mangle]
10624 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
10625 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
10626         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10627 }
10628 #[allow(unused)]
10629 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10630         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
10631 }
10632 #[no_mangle]
10633 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
10634 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
10635         let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10636         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() };
10637         local_res
10638 }
10639 #[no_mangle]
10640 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
10641 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
10642         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10643 }
10644 #[allow(unused)]
10645 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10646         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
10647 }
10648 #[no_mangle]
10649 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
10650 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
10651         let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10652         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() };
10653         local_res
10654 }
10655 #[no_mangle]
10656 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
10657 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
10658         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10659 }
10660 #[allow(unused)]
10661 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10662         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
10663 }
10664 #[no_mangle]
10665 /// Read a Shutdown from a byte array, created by Shutdown_write
10666 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
10667         let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10668         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() };
10669         local_res
10670 }
10671 #[no_mangle]
10672 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
10673 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
10674         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10675 }
10676 #[allow(unused)]
10677 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10678         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
10679 }
10680 #[no_mangle]
10681 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
10682 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
10683         let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10684         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() };
10685         local_res
10686 }
10687 #[no_mangle]
10688 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
10689 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
10690         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10691 }
10692 #[allow(unused)]
10693 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10694         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
10695 }
10696 #[no_mangle]
10697 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
10698 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
10699         let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10700         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() };
10701         local_res
10702 }
10703 #[no_mangle]
10704 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
10705 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
10706         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10707 }
10708 #[allow(unused)]
10709 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10710         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
10711 }
10712 #[no_mangle]
10713 /// Read a UpdateFee from a byte array, created by UpdateFee_write
10714 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
10715         let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10716         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() };
10717         local_res
10718 }
10719 #[no_mangle]
10720 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
10721 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
10722         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10723 }
10724 #[allow(unused)]
10725 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10726         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
10727 }
10728 #[no_mangle]
10729 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
10730 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
10731         let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10732         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() };
10733         local_res
10734 }
10735 #[no_mangle]
10736 /// Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read
10737 pub extern "C" fn OnionPacket_write(obj: &crate::lightning::ln::msgs::OnionPacket) -> crate::c_types::derived::CVec_u8Z {
10738         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10739 }
10740 #[allow(unused)]
10741 pub(crate) extern "C" fn OnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10742         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionPacket) })
10743 }
10744 #[no_mangle]
10745 /// Read a OnionPacket from a byte array, created by OnionPacket_write
10746 pub extern "C" fn OnionPacket_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionPacketDecodeErrorZ {
10747         let res: Result<lightning::ln::msgs::OnionPacket, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10748         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() };
10749         local_res
10750 }
10751 #[no_mangle]
10752 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
10753 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
10754         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10755 }
10756 #[allow(unused)]
10757 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10758         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
10759 }
10760 #[no_mangle]
10761 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
10762 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
10763         let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10764         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() };
10765         local_res
10766 }
10767 #[no_mangle]
10768 /// Read a OnionMessage from a byte array, created by OnionMessage_write
10769 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
10770         let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10771         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() };
10772         local_res
10773 }
10774 #[no_mangle]
10775 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
10776 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
10777         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10778 }
10779 #[allow(unused)]
10780 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10781         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
10782 }
10783 #[no_mangle]
10784 /// Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read
10785 pub extern "C" fn FinalOnionHopData_write(obj: &crate::lightning::ln::msgs::FinalOnionHopData) -> crate::c_types::derived::CVec_u8Z {
10786         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10787 }
10788 #[allow(unused)]
10789 pub(crate) extern "C" fn FinalOnionHopData_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10790         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFinalOnionHopData) })
10791 }
10792 #[no_mangle]
10793 /// Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write
10794 pub extern "C" fn FinalOnionHopData_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FinalOnionHopDataDecodeErrorZ {
10795         let res: Result<lightning::ln::msgs::FinalOnionHopData, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10796         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() };
10797         local_res
10798 }
10799 #[no_mangle]
10800 /// Serialize the Ping object into a byte array which can be read by Ping_read
10801 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
10802         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10803 }
10804 #[allow(unused)]
10805 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10806         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
10807 }
10808 #[no_mangle]
10809 /// Read a Ping from a byte array, created by Ping_write
10810 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
10811         let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10812         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() };
10813         local_res
10814 }
10815 #[no_mangle]
10816 /// Serialize the Pong object into a byte array which can be read by Pong_read
10817 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
10818         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10819 }
10820 #[allow(unused)]
10821 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10822         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
10823 }
10824 #[no_mangle]
10825 /// Read a Pong from a byte array, created by Pong_write
10826 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
10827         let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10828         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() };
10829         local_res
10830 }
10831 #[no_mangle]
10832 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
10833 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10834         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10835 }
10836 #[allow(unused)]
10837 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10838         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
10839 }
10840 #[no_mangle]
10841 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
10842 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
10843         let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10844         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() };
10845         local_res
10846 }
10847 #[no_mangle]
10848 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
10849 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10850         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10851 }
10852 #[allow(unused)]
10853 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10854         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
10855 }
10856 #[no_mangle]
10857 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
10858 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
10859         let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10860         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() };
10861         local_res
10862 }
10863 #[no_mangle]
10864 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
10865 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10866         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10867 }
10868 #[allow(unused)]
10869 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10870         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
10871 }
10872 #[no_mangle]
10873 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
10874 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
10875         let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10876         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() };
10877         local_res
10878 }
10879 #[no_mangle]
10880 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
10881 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10882         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10883 }
10884 #[allow(unused)]
10885 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10886         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
10887 }
10888 #[no_mangle]
10889 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
10890 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
10891         let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10892         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() };
10893         local_res
10894 }
10895 #[no_mangle]
10896 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
10897 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
10898         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10899 }
10900 #[allow(unused)]
10901 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10902         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
10903 }
10904 #[no_mangle]
10905 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
10906 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
10907         let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10908         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() };
10909         local_res
10910 }
10911 #[no_mangle]
10912 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
10913 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
10914         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10915 }
10916 #[allow(unused)]
10917 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10918         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
10919 }
10920 #[no_mangle]
10921 /// Read a WarningMessage from a byte array, created by WarningMessage_write
10922 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
10923         let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10924         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() };
10925         local_res
10926 }
10927 #[no_mangle]
10928 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
10929 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10930         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10931 }
10932 #[allow(unused)]
10933 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10934         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
10935 }
10936 #[no_mangle]
10937 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
10938 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
10939         let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10940         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() };
10941         local_res
10942 }
10943 #[no_mangle]
10944 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
10945 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10946         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10947 }
10948 #[allow(unused)]
10949 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10950         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
10951 }
10952 #[no_mangle]
10953 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
10954 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
10955         let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10956         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() };
10957         local_res
10958 }
10959 #[no_mangle]
10960 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
10961 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
10962         let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10963         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() };
10964         local_res
10965 }
10966 #[no_mangle]
10967 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
10968 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
10969         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10970 }
10971 #[allow(unused)]
10972 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10973         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
10974 }
10975 #[no_mangle]
10976 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
10977 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
10978         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10979 }
10980 #[allow(unused)]
10981 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10982         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
10983 }
10984 #[no_mangle]
10985 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
10986 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
10987         let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10988         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() };
10989         local_res
10990 }
10991 /// Calculates the overflow safe ending block height for the query.
10992 ///
10993 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
10994 #[must_use]
10995 #[no_mangle]
10996 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
10997         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
10998         ret
10999 }
11000
11001 #[no_mangle]
11002 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
11003 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
11004         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
11005 }
11006 #[allow(unused)]
11007 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
11008         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
11009 }
11010 #[no_mangle]
11011 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
11012 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
11013         let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11014         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() };
11015         local_res
11016 }
11017 #[no_mangle]
11018 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
11019 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
11020         let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11021         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() };
11022         local_res
11023 }
11024 #[no_mangle]
11025 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
11026 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
11027         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
11028 }
11029 #[allow(unused)]
11030 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
11031         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
11032 }
11033 #[no_mangle]
11034 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
11035 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
11036         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
11037 }
11038 #[allow(unused)]
11039 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
11040         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
11041 }
11042 #[no_mangle]
11043 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
11044 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
11045         let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11046         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() };
11047         local_res
11048 }