Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / ln / msgs.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Wire messages, traits representing wire message handlers, and a few error types live here.
10 //!
11 //! For a normal node you probably don't need to use anything here, however, if you wish to split a
12 //! node into an internet-facing route/message socket handling daemon and a separate daemon (or
13 //! server entirely) which handles only channel-related messages you may wish to implement
14 //! [`ChannelMessageHandler`] yourself and use it to re-serialize messages and pass them across
15 //! daemons/servers.
16 //!
17 //! Note that if you go with such an architecture (instead of passing raw socket events to a
18 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
19 //! source `node_id` of the message, however this does allow you to significantly reduce bandwidth
20 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
21 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
22 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
23 //! raw socket events into your non-internet-facing system and then send routing events back to
24 //! track the network on the less-secure system.
25
26 use alloc::str::FromStr;
27 use alloc::string::String;
28 use core::ffi::c_void;
29 use core::convert::Infallible;
30 use bitcoin::hashes::Hash;
31 use crate::c_types::*;
32 #[cfg(feature="no-std")]
33 use alloc::{vec::Vec, boxed::Box};
34
35 /// An error in decoding a message or struct.
36 #[derive(Clone)]
37 #[must_use]
38 #[repr(C)]
39 pub enum DecodeError {
40         /// A version byte specified something we don't know how to handle.
41         ///
42         /// Includes unknown realm byte in an onion hop data packet.
43         UnknownVersion,
44         /// Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type)
45         UnknownRequiredFeature,
46         /// Value was invalid.
47         ///
48         /// For example, a byte which was supposed to be a bool was something other than a 0
49         /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
50         /// syntactically incorrect, etc.
51         InvalidValue,
52         /// The buffer to be read was too short.
53         ShortRead,
54         /// A length descriptor in the packet didn't describe the later data correctly.
55         BadLengthDescriptor,
56         /// Error from [`std::io`].
57         Io(
58                 crate::c_types::IOError),
59         /// The message included zlib-compressed values, which we don't support.
60         UnsupportedCompression,
61 }
62 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
63 pub(crate) type nativeDecodeError = DecodeErrorImport;
64
65 impl DecodeError {
66         #[allow(unused)]
67         pub(crate) fn to_native(&self) -> nativeDecodeError {
68                 match self {
69                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
70                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
71                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
72                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
73                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
74                         DecodeError::Io (ref a, ) => {
75                                 let mut a_nonref = Clone::clone(a);
76                                 nativeDecodeError::Io (
77                                         a_nonref.to_rust_kind(),
78                                 )
79                         },
80                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
81                 }
82         }
83         #[allow(unused)]
84         pub(crate) fn into_native(self) -> nativeDecodeError {
85                 match self {
86                         DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
87                         DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
88                         DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
89                         DecodeError::ShortRead => nativeDecodeError::ShortRead,
90                         DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
91                         DecodeError::Io (mut a, ) => {
92                                 nativeDecodeError::Io (
93                                         a.to_rust_kind(),
94                                 )
95                         },
96                         DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
97                 }
98         }
99         #[allow(unused)]
100         pub(crate) fn from_native(native: &nativeDecodeError) -> Self {
101                 match native {
102                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
103                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
104                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
105                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
106                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
107                         nativeDecodeError::Io (ref a, ) => {
108                                 let mut a_nonref = Clone::clone(a);
109                                 DecodeError::Io (
110                                         crate::c_types::IOError::from_rust_kind(a_nonref),
111                                 )
112                         },
113                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
114                 }
115         }
116         #[allow(unused)]
117         pub(crate) fn native_into(native: nativeDecodeError) -> Self {
118                 match native {
119                         nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
120                         nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
121                         nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
122                         nativeDecodeError::ShortRead => DecodeError::ShortRead,
123                         nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
124                         nativeDecodeError::Io (mut a, ) => {
125                                 DecodeError::Io (
126                                         crate::c_types::IOError::from_rust_kind(a),
127                                 )
128                         },
129                         nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
130                 }
131         }
132 }
133 /// Frees any resources used by the DecodeError
134 #[no_mangle]
135 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
136 /// Creates a copy of the DecodeError
137 #[no_mangle]
138 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
139         orig.clone()
140 }
141 #[no_mangle]
142 /// Utility method to constructs a new UnknownVersion-variant DecodeError
143 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
144         DecodeError::UnknownVersion}
145 #[no_mangle]
146 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
147 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
148         DecodeError::UnknownRequiredFeature}
149 #[no_mangle]
150 /// Utility method to constructs a new InvalidValue-variant DecodeError
151 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
152         DecodeError::InvalidValue}
153 #[no_mangle]
154 /// Utility method to constructs a new ShortRead-variant DecodeError
155 pub extern "C" fn DecodeError_short_read() -> DecodeError {
156         DecodeError::ShortRead}
157 #[no_mangle]
158 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
159 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
160         DecodeError::BadLengthDescriptor}
161 #[no_mangle]
162 /// Utility method to constructs a new Io-variant DecodeError
163 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
164         DecodeError::Io(a, )
165 }
166 #[no_mangle]
167 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
168 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
169         DecodeError::UnsupportedCompression}
170 /// Checks if two DecodeErrors contain equal inner contents.
171 /// This ignores pointers and is_owned flags and looks at the values in fields.
172 #[no_mangle]
173 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
174         if &a.to_native() == &b.to_native() { true } else { false }
175 }
176
177 use lightning::ln::msgs::Init as nativeInitImport;
178 pub(crate) type nativeInit = nativeInitImport;
179
180 /// An [`init`] message to be sent to or received from a peer.
181 ///
182 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
183 #[must_use]
184 #[repr(C)]
185 pub struct Init {
186         /// A pointer to the opaque Rust object.
187
188         /// Nearly everywhere, inner must be non-null, however in places where
189         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
190         pub inner: *mut nativeInit,
191         /// Indicates that this is the only struct which contains the same pointer.
192
193         /// Rust functions which take ownership of an object provided via an argument require
194         /// this to be true and invalidate the object pointed to by inner.
195         pub is_owned: bool,
196 }
197
198 impl Drop for Init {
199         fn drop(&mut self) {
200                 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
201                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
202                 }
203         }
204 }
205 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
206 #[no_mangle]
207 pub extern "C" fn Init_free(this_obj: Init) { }
208 #[allow(unused)]
209 /// Used only if an object of this type is returned as a trait impl by a method
210 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
211         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
212 }
213 #[allow(unused)]
214 impl Init {
215         pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
216                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
217         }
218         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
219                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
220         }
221         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
222         pub(crate) fn take_inner(mut self) -> *mut nativeInit {
223                 assert!(self.is_owned);
224                 let ret = ObjOps::untweak_ptr(self.inner);
225                 self.inner = core::ptr::null_mut();
226                 ret
227         }
228 }
229 /// The relevant features which the sender supports.
230 #[no_mangle]
231 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
232         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
233         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 }
234 }
235 /// The relevant features which the sender supports.
236 #[no_mangle]
237 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
238         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
239 }
240 /// Indicates chains the sender is interested in.
241 ///
242 /// If there are no common chains, the connection will be closed.
243 ///
244 /// Returns a copy of the field.
245 #[no_mangle]
246 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
247         let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
248         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_inner_val_0.into() }) };
249         local_inner_val
250 }
251 /// Indicates chains the sender is interested in.
252 ///
253 /// If there are no common chains, the connection will be closed.
254 #[no_mangle]
255 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ) {
256         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 }})} };
257         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
258 }
259 /// The receipient's network address.
260 ///
261 /// This adds the option to report a remote IP address back to a connecting peer using the init
262 /// message. A node can decide to use that information to discover a potential update to its
263 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
264 /// the new address.
265 #[no_mangle]
266 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_SocketAddressZ {
267         let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
268         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()) }) };
269         local_inner_val
270 }
271 /// The receipient's network address.
272 ///
273 /// This adds the option to report a remote IP address back to a connecting peer using the init
274 /// message. A node can decide to use that information to discover a potential update to its
275 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
276 /// the new address.
277 #[no_mangle]
278 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_SocketAddressZ) {
279         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
280         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
281 }
282 /// Constructs a new Init given each field
283 #[must_use]
284 #[no_mangle]
285 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 {
286         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 }})} };
287         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() }})} };
288         Init { inner: ObjOps::heap_alloc(nativeInit {
289                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
290                 networks: local_networks_arg,
291                 remote_network_address: local_remote_network_address_arg,
292         }), is_owned: true }
293 }
294 impl Clone for Init {
295         fn clone(&self) -> Self {
296                 Self {
297                         inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
298                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
299                         is_owned: true,
300                 }
301         }
302 }
303 #[allow(unused)]
304 /// Used only if an object of this type is returned as a trait impl by a method
305 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
306         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
307 }
308 #[no_mangle]
309 /// Creates a copy of the Init
310 pub extern "C" fn Init_clone(orig: &Init) -> Init {
311         orig.clone()
312 }
313 /// Checks if two Inits contain equal inner contents.
314 /// This ignores pointers and is_owned flags and looks at the values in fields.
315 /// Two objects with NULL inner values will be considered "equal" here.
316 #[no_mangle]
317 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
318         if a.inner == b.inner { return true; }
319         if a.inner.is_null() || b.inner.is_null() { return false; }
320         if a.get_native_ref() == b.get_native_ref() { true } else { false }
321 }
322
323 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
324 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
325
326 /// An [`error`] message to be sent to or received from a peer.
327 ///
328 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
329 #[must_use]
330 #[repr(C)]
331 pub struct ErrorMessage {
332         /// A pointer to the opaque Rust object.
333
334         /// Nearly everywhere, inner must be non-null, however in places where
335         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
336         pub inner: *mut nativeErrorMessage,
337         /// Indicates that this is the only struct which contains the same pointer.
338
339         /// Rust functions which take ownership of an object provided via an argument require
340         /// this to be true and invalidate the object pointed to by inner.
341         pub is_owned: bool,
342 }
343
344 impl Drop for ErrorMessage {
345         fn drop(&mut self) {
346                 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
347                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
348                 }
349         }
350 }
351 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
352 #[no_mangle]
353 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
354 #[allow(unused)]
355 /// Used only if an object of this type is returned as a trait impl by a method
356 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
357         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
358 }
359 #[allow(unused)]
360 impl ErrorMessage {
361         pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
362                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
363         }
364         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
365                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
366         }
367         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
368         pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
369                 assert!(self.is_owned);
370                 let ret = ObjOps::untweak_ptr(self.inner);
371                 self.inner = core::ptr::null_mut();
372                 ret
373         }
374 }
375 /// The channel ID involved in the error.
376 ///
377 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
378 /// with the sending peer should be closed.
379 #[no_mangle]
380 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
381         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
382         &inner_val.0
383 }
384 /// The channel ID involved in the error.
385 ///
386 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
387 /// with the sending peer should be closed.
388 #[no_mangle]
389 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
390         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
391 }
392 /// A possibly human-readable error description.
393 ///
394 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
395 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
396 /// the terminal emulator or the logging subsystem.
397 #[no_mangle]
398 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
399         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
400         inner_val.as_str().into()
401 }
402 /// A possibly human-readable error description.
403 ///
404 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
405 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
406 /// the terminal emulator or the logging subsystem.
407 #[no_mangle]
408 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
409         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
410 }
411 /// Constructs a new ErrorMessage given each field
412 #[must_use]
413 #[no_mangle]
414 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
415         ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
416                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
417                 data: data_arg.into_string(),
418         }), is_owned: true }
419 }
420 impl Clone for ErrorMessage {
421         fn clone(&self) -> Self {
422                 Self {
423                         inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
424                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
425                         is_owned: true,
426                 }
427         }
428 }
429 #[allow(unused)]
430 /// Used only if an object of this type is returned as a trait impl by a method
431 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
432         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
433 }
434 #[no_mangle]
435 /// Creates a copy of the ErrorMessage
436 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
437         orig.clone()
438 }
439 /// Checks if two ErrorMessages contain equal inner contents.
440 /// This ignores pointers and is_owned flags and looks at the values in fields.
441 /// Two objects with NULL inner values will be considered "equal" here.
442 #[no_mangle]
443 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
444         if a.inner == b.inner { return true; }
445         if a.inner.is_null() || b.inner.is_null() { return false; }
446         if a.get_native_ref() == b.get_native_ref() { true } else { false }
447 }
448
449 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
450 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
451
452 /// A [`warning`] message to be sent to or received from a peer.
453 ///
454 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
455 #[must_use]
456 #[repr(C)]
457 pub struct WarningMessage {
458         /// A pointer to the opaque Rust object.
459
460         /// Nearly everywhere, inner must be non-null, however in places where
461         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
462         pub inner: *mut nativeWarningMessage,
463         /// Indicates that this is the only struct which contains the same pointer.
464
465         /// Rust functions which take ownership of an object provided via an argument require
466         /// this to be true and invalidate the object pointed to by inner.
467         pub is_owned: bool,
468 }
469
470 impl Drop for WarningMessage {
471         fn drop(&mut self) {
472                 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
473                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
474                 }
475         }
476 }
477 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
478 #[no_mangle]
479 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
480 #[allow(unused)]
481 /// Used only if an object of this type is returned as a trait impl by a method
482 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
483         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
484 }
485 #[allow(unused)]
486 impl WarningMessage {
487         pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
488                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
489         }
490         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
491                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
492         }
493         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
494         pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
495                 assert!(self.is_owned);
496                 let ret = ObjOps::untweak_ptr(self.inner);
497                 self.inner = core::ptr::null_mut();
498                 ret
499         }
500 }
501 /// The channel ID involved in the warning.
502 ///
503 /// All-0s indicates a warning unrelated to a specific channel.
504 #[no_mangle]
505 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
506         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
507         &inner_val.0
508 }
509 /// The channel ID involved in the warning.
510 ///
511 /// All-0s indicates a warning unrelated to a specific channel.
512 #[no_mangle]
513 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
514         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
515 }
516 /// A possibly human-readable warning description.
517 ///
518 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
519 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
520 /// the terminal emulator or the logging subsystem.
521 #[no_mangle]
522 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
523         let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
524         inner_val.as_str().into()
525 }
526 /// A possibly human-readable warning description.
527 ///
528 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
529 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
530 /// the terminal emulator or the logging subsystem.
531 #[no_mangle]
532 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
533         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
534 }
535 /// Constructs a new WarningMessage given each field
536 #[must_use]
537 #[no_mangle]
538 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
539         WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
540                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
541                 data: data_arg.into_string(),
542         }), is_owned: true }
543 }
544 impl Clone for WarningMessage {
545         fn clone(&self) -> Self {
546                 Self {
547                         inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
548                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
549                         is_owned: true,
550                 }
551         }
552 }
553 #[allow(unused)]
554 /// Used only if an object of this type is returned as a trait impl by a method
555 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
556         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void
557 }
558 #[no_mangle]
559 /// Creates a copy of the WarningMessage
560 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
561         orig.clone()
562 }
563 /// Checks if two WarningMessages contain equal inner contents.
564 /// This ignores pointers and is_owned flags and looks at the values in fields.
565 /// Two objects with NULL inner values will be considered "equal" here.
566 #[no_mangle]
567 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
568         if a.inner == b.inner { return true; }
569         if a.inner.is_null() || b.inner.is_null() { return false; }
570         if a.get_native_ref() == b.get_native_ref() { true } else { false }
571 }
572
573 use lightning::ln::msgs::Ping as nativePingImport;
574 pub(crate) type nativePing = nativePingImport;
575
576 /// A [`ping`] message to be sent to or received from a peer.
577 ///
578 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
579 #[must_use]
580 #[repr(C)]
581 pub struct Ping {
582         /// A pointer to the opaque Rust object.
583
584         /// Nearly everywhere, inner must be non-null, however in places where
585         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
586         pub inner: *mut nativePing,
587         /// Indicates that this is the only struct which contains the same pointer.
588
589         /// Rust functions which take ownership of an object provided via an argument require
590         /// this to be true and invalidate the object pointed to by inner.
591         pub is_owned: bool,
592 }
593
594 impl Drop for Ping {
595         fn drop(&mut self) {
596                 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
597                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
598                 }
599         }
600 }
601 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
602 #[no_mangle]
603 pub extern "C" fn Ping_free(this_obj: Ping) { }
604 #[allow(unused)]
605 /// Used only if an object of this type is returned as a trait impl by a method
606 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
607         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
608 }
609 #[allow(unused)]
610 impl Ping {
611         pub(crate) fn get_native_ref(&self) -> &'static nativePing {
612                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
613         }
614         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
615                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
616         }
617         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
618         pub(crate) fn take_inner(mut self) -> *mut nativePing {
619                 assert!(self.is_owned);
620                 let ret = ObjOps::untweak_ptr(self.inner);
621                 self.inner = core::ptr::null_mut();
622                 ret
623         }
624 }
625 /// The desired response length.
626 #[no_mangle]
627 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
628         let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
629         *inner_val
630 }
631 /// The desired response length.
632 #[no_mangle]
633 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
634         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
635 }
636 /// The ping packet size.
637 ///
638 /// This field is not sent on the wire. byteslen zeros are sent.
639 #[no_mangle]
640 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
641         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
642         *inner_val
643 }
644 /// The ping packet size.
645 ///
646 /// This field is not sent on the wire. byteslen zeros are sent.
647 #[no_mangle]
648 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
649         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
650 }
651 /// Constructs a new Ping given each field
652 #[must_use]
653 #[no_mangle]
654 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
655         Ping { inner: ObjOps::heap_alloc(nativePing {
656                 ponglen: ponglen_arg,
657                 byteslen: byteslen_arg,
658         }), is_owned: true }
659 }
660 impl Clone for Ping {
661         fn clone(&self) -> Self {
662                 Self {
663                         inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
664                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
665                         is_owned: true,
666                 }
667         }
668 }
669 #[allow(unused)]
670 /// Used only if an object of this type is returned as a trait impl by a method
671 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
672         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
673 }
674 #[no_mangle]
675 /// Creates a copy of the Ping
676 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
677         orig.clone()
678 }
679 /// Checks if two Pings contain equal inner contents.
680 /// This ignores pointers and is_owned flags and looks at the values in fields.
681 /// Two objects with NULL inner values will be considered "equal" here.
682 #[no_mangle]
683 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
684         if a.inner == b.inner { return true; }
685         if a.inner.is_null() || b.inner.is_null() { return false; }
686         if a.get_native_ref() == b.get_native_ref() { true } else { false }
687 }
688
689 use lightning::ln::msgs::Pong as nativePongImport;
690 pub(crate) type nativePong = nativePongImport;
691
692 /// A [`pong`] message to be sent to or received from a peer.
693 ///
694 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
695 #[must_use]
696 #[repr(C)]
697 pub struct Pong {
698         /// A pointer to the opaque Rust object.
699
700         /// Nearly everywhere, inner must be non-null, however in places where
701         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
702         pub inner: *mut nativePong,
703         /// Indicates that this is the only struct which contains the same pointer.
704
705         /// Rust functions which take ownership of an object provided via an argument require
706         /// this to be true and invalidate the object pointed to by inner.
707         pub is_owned: bool,
708 }
709
710 impl Drop for Pong {
711         fn drop(&mut self) {
712                 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
713                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
714                 }
715         }
716 }
717 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
718 #[no_mangle]
719 pub extern "C" fn Pong_free(this_obj: Pong) { }
720 #[allow(unused)]
721 /// Used only if an object of this type is returned as a trait impl by a method
722 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
723         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
724 }
725 #[allow(unused)]
726 impl Pong {
727         pub(crate) fn get_native_ref(&self) -> &'static nativePong {
728                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
729         }
730         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
731                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
732         }
733         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
734         pub(crate) fn take_inner(mut self) -> *mut nativePong {
735                 assert!(self.is_owned);
736                 let ret = ObjOps::untweak_ptr(self.inner);
737                 self.inner = core::ptr::null_mut();
738                 ret
739         }
740 }
741 /// The pong packet size.
742 ///
743 /// This field is not sent on the wire. byteslen zeros are sent.
744 #[no_mangle]
745 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
746         let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
747         *inner_val
748 }
749 /// The pong packet size.
750 ///
751 /// This field is not sent on the wire. byteslen zeros are sent.
752 #[no_mangle]
753 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
754         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
755 }
756 /// Constructs a new Pong given each field
757 #[must_use]
758 #[no_mangle]
759 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
760         Pong { inner: ObjOps::heap_alloc(nativePong {
761                 byteslen: byteslen_arg,
762         }), is_owned: true }
763 }
764 impl Clone for Pong {
765         fn clone(&self) -> Self {
766                 Self {
767                         inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
768                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
769                         is_owned: true,
770                 }
771         }
772 }
773 #[allow(unused)]
774 /// Used only if an object of this type is returned as a trait impl by a method
775 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
776         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
777 }
778 #[no_mangle]
779 /// Creates a copy of the Pong
780 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
781         orig.clone()
782 }
783 /// Checks if two Pongs contain equal inner contents.
784 /// This ignores pointers and is_owned flags and looks at the values in fields.
785 /// Two objects with NULL inner values will be considered "equal" here.
786 #[no_mangle]
787 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
788         if a.inner == b.inner { return true; }
789         if a.inner.is_null() || b.inner.is_null() { return false; }
790         if a.get_native_ref() == b.get_native_ref() { true } else { false }
791 }
792
793 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
794 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
795
796 /// An [`open_channel`] message to be sent to or received from a peer.
797 ///
798 /// Used in V1 channel establishment
799 ///
800 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
801 #[must_use]
802 #[repr(C)]
803 pub struct OpenChannel {
804         /// A pointer to the opaque Rust object.
805
806         /// Nearly everywhere, inner must be non-null, however in places where
807         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
808         pub inner: *mut nativeOpenChannel,
809         /// Indicates that this is the only struct which contains the same pointer.
810
811         /// Rust functions which take ownership of an object provided via an argument require
812         /// this to be true and invalidate the object pointed to by inner.
813         pub is_owned: bool,
814 }
815
816 impl Drop for OpenChannel {
817         fn drop(&mut self) {
818                 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
819                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
820                 }
821         }
822 }
823 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
824 #[no_mangle]
825 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
826 #[allow(unused)]
827 /// Used only if an object of this type is returned as a trait impl by a method
828 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
829         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
830 }
831 #[allow(unused)]
832 impl OpenChannel {
833         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
834                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
835         }
836         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
837                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
838         }
839         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
840         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
841                 assert!(self.is_owned);
842                 let ret = ObjOps::untweak_ptr(self.inner);
843                 self.inner = core::ptr::null_mut();
844                 ret
845         }
846 }
847 /// The genesis hash of the blockchain where the channel is to be opened
848 #[no_mangle]
849 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
850         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
851         inner_val.as_inner()
852 }
853 /// The genesis hash of the blockchain where the channel is to be opened
854 #[no_mangle]
855 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
856         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
857 }
858 /// A temporary channel ID, until the funding outpoint is announced
859 #[no_mangle]
860 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
861         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
862         &inner_val.0
863 }
864 /// A temporary channel ID, until the funding outpoint is announced
865 #[no_mangle]
866 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
867         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
868 }
869 /// The channel value
870 #[no_mangle]
871 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
872         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
873         *inner_val
874 }
875 /// The channel value
876 #[no_mangle]
877 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
878         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
879 }
880 /// The amount to push to the counterparty as part of the open, in milli-satoshi
881 #[no_mangle]
882 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
883         let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
884         *inner_val
885 }
886 /// The amount to push to the counterparty as part of the open, in milli-satoshi
887 #[no_mangle]
888 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
889         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
890 }
891 /// The threshold below which outputs on transactions broadcast by sender will be omitted
892 #[no_mangle]
893 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
894         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
895         *inner_val
896 }
897 /// The threshold below which outputs on transactions broadcast by sender will be omitted
898 #[no_mangle]
899 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
900         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
901 }
902 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
903 #[no_mangle]
904 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
905         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
906         *inner_val
907 }
908 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
909 #[no_mangle]
910 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
911         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
912 }
913 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
914 #[no_mangle]
915 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
916         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
917         *inner_val
918 }
919 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
920 #[no_mangle]
921 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
922         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
923 }
924 /// The minimum HTLC size incoming to sender, in milli-satoshi
925 #[no_mangle]
926 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
927         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
928         *inner_val
929 }
930 /// The minimum HTLC size incoming to sender, in milli-satoshi
931 #[no_mangle]
932 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
933         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
934 }
935 /// The feerate per 1000-weight of sender generated transactions, until updated by
936 /// [`UpdateFee`]
937 #[no_mangle]
938 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
939         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
940         *inner_val
941 }
942 /// The feerate per 1000-weight of sender generated transactions, until updated by
943 /// [`UpdateFee`]
944 #[no_mangle]
945 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
946         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
947 }
948 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
949 /// they broadcast a commitment transaction
950 #[no_mangle]
951 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
952         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
953         *inner_val
954 }
955 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
956 /// they broadcast a commitment transaction
957 #[no_mangle]
958 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
959         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
960 }
961 /// The maximum number of inbound HTLCs towards sender
962 #[no_mangle]
963 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
964         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
965         *inner_val
966 }
967 /// The maximum number of inbound HTLCs towards sender
968 #[no_mangle]
969 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
970         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
971 }
972 /// The sender's key controlling the funding transaction
973 #[no_mangle]
974 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
975         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
976         crate::c_types::PublicKey::from_rust(&inner_val)
977 }
978 /// The sender's key controlling the funding transaction
979 #[no_mangle]
980 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
981         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
982 }
983 /// Used to derive a revocation key for transactions broadcast by counterparty
984 #[no_mangle]
985 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
986         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
987         crate::c_types::PublicKey::from_rust(&inner_val)
988 }
989 /// Used to derive a revocation key for transactions broadcast by counterparty
990 #[no_mangle]
991 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
992         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
993 }
994 /// A payment key to sender for transactions broadcast by counterparty
995 #[no_mangle]
996 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
997         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
998         crate::c_types::PublicKey::from_rust(&inner_val)
999 }
1000 /// A payment key to sender for transactions broadcast by counterparty
1001 #[no_mangle]
1002 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1003         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1004 }
1005 /// Used to derive a payment key to sender for transactions broadcast by sender
1006 #[no_mangle]
1007 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1008         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1009         crate::c_types::PublicKey::from_rust(&inner_val)
1010 }
1011 /// Used to derive a payment key to sender for transactions broadcast by sender
1012 #[no_mangle]
1013 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1014         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1015 }
1016 /// Used to derive an HTLC payment key to sender
1017 #[no_mangle]
1018 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1019         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1020         crate::c_types::PublicKey::from_rust(&inner_val)
1021 }
1022 /// Used to derive an HTLC payment key to sender
1023 #[no_mangle]
1024 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1025         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1026 }
1027 /// The first to-be-broadcast-by-sender transaction's per commitment point
1028 #[no_mangle]
1029 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1030         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1031         crate::c_types::PublicKey::from_rust(&inner_val)
1032 }
1033 /// The first to-be-broadcast-by-sender transaction's per commitment point
1034 #[no_mangle]
1035 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1036         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1037 }
1038 /// The channel flags to be used
1039 #[no_mangle]
1040 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
1041         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1042         *inner_val
1043 }
1044 /// The channel flags to be used
1045 #[no_mangle]
1046 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
1047         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1048 }
1049 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1050 #[no_mangle]
1051 pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1052         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1053         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1054         local_inner_val
1055 }
1056 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1057 #[no_mangle]
1058 pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1059         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1060         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1061 }
1062 /// The channel type that this channel will represent
1063 ///
1064 /// If this is `None`, we derive the channel type from the intersection of our
1065 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1066 ///
1067 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1068 #[no_mangle]
1069 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1070         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1071         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 };
1072         local_inner_val
1073 }
1074 /// The channel type that this channel will represent
1075 ///
1076 /// If this is `None`, we derive the channel type from the intersection of our
1077 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1078 ///
1079 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1080 #[no_mangle]
1081 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1082         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1083         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1084 }
1085 /// Constructs a new OpenChannel given each field
1086 ///
1087 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1088 #[must_use]
1089 #[no_mangle]
1090 pub extern "C" fn OpenChannel_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut push_msat_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut feerate_per_kw_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> OpenChannel {
1091         let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1092         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()) } }) };
1093         OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1094                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
1095                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1096                 funding_satoshis: funding_satoshis_arg,
1097                 push_msat: push_msat_arg,
1098                 dust_limit_satoshis: dust_limit_satoshis_arg,
1099                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1100                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1101                 htlc_minimum_msat: htlc_minimum_msat_arg,
1102                 feerate_per_kw: feerate_per_kw_arg,
1103                 to_self_delay: to_self_delay_arg,
1104                 max_accepted_htlcs: max_accepted_htlcs_arg,
1105                 funding_pubkey: funding_pubkey_arg.into_rust(),
1106                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1107                 payment_point: payment_point_arg.into_rust(),
1108                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1109                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1110                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1111                 channel_flags: channel_flags_arg,
1112                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1113                 channel_type: local_channel_type_arg,
1114         }), is_owned: true }
1115 }
1116 impl Clone for OpenChannel {
1117         fn clone(&self) -> Self {
1118                 Self {
1119                         inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1120                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1121                         is_owned: true,
1122                 }
1123         }
1124 }
1125 #[allow(unused)]
1126 /// Used only if an object of this type is returned as a trait impl by a method
1127 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1128         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
1129 }
1130 #[no_mangle]
1131 /// Creates a copy of the OpenChannel
1132 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1133         orig.clone()
1134 }
1135 /// Checks if two OpenChannels contain equal inner contents.
1136 /// This ignores pointers and is_owned flags and looks at the values in fields.
1137 /// Two objects with NULL inner values will be considered "equal" here.
1138 #[no_mangle]
1139 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1140         if a.inner == b.inner { return true; }
1141         if a.inner.is_null() || b.inner.is_null() { return false; }
1142         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1143 }
1144
1145 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1146 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1147
1148 /// An open_channel2 message to be sent by or received from the channel initiator.
1149 ///
1150 /// Used in V2 channel establishment
1151 ///
1152 #[must_use]
1153 #[repr(C)]
1154 pub struct OpenChannelV2 {
1155         /// A pointer to the opaque Rust object.
1156
1157         /// Nearly everywhere, inner must be non-null, however in places where
1158         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1159         pub inner: *mut nativeOpenChannelV2,
1160         /// Indicates that this is the only struct which contains the same pointer.
1161
1162         /// Rust functions which take ownership of an object provided via an argument require
1163         /// this to be true and invalidate the object pointed to by inner.
1164         pub is_owned: bool,
1165 }
1166
1167 impl Drop for OpenChannelV2 {
1168         fn drop(&mut self) {
1169                 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1170                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1171                 }
1172         }
1173 }
1174 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1175 #[no_mangle]
1176 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1177 #[allow(unused)]
1178 /// Used only if an object of this type is returned as a trait impl by a method
1179 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1180         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1181 }
1182 #[allow(unused)]
1183 impl OpenChannelV2 {
1184         pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1185                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1186         }
1187         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1188                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1189         }
1190         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1191         pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1192                 assert!(self.is_owned);
1193                 let ret = ObjOps::untweak_ptr(self.inner);
1194                 self.inner = core::ptr::null_mut();
1195                 ret
1196         }
1197 }
1198 /// The genesis hash of the blockchain where the channel is to be opened
1199 #[no_mangle]
1200 pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1201         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
1202         inner_val.as_inner()
1203 }
1204 /// The genesis hash of the blockchain where the channel is to be opened
1205 #[no_mangle]
1206 pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1207         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
1208 }
1209 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1210 #[no_mangle]
1211 pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1212         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1213         &inner_val.0
1214 }
1215 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1216 #[no_mangle]
1217 pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1218         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1219 }
1220 /// The feerate for the funding transaction set by the channel initiator
1221 #[no_mangle]
1222 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1223         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1224         *inner_val
1225 }
1226 /// The feerate for the funding transaction set by the channel initiator
1227 #[no_mangle]
1228 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1229         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1230 }
1231 /// The feerate for the commitment transaction set by the channel initiator
1232 #[no_mangle]
1233 pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1234         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1235         *inner_val
1236 }
1237 /// The feerate for the commitment transaction set by the channel initiator
1238 #[no_mangle]
1239 pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1240         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1241 }
1242 /// Part of the channel value contributed by the channel initiator
1243 #[no_mangle]
1244 pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1245         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1246         *inner_val
1247 }
1248 /// Part of the channel value contributed by the channel initiator
1249 #[no_mangle]
1250 pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1251         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1252 }
1253 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1254 /// omitted
1255 #[no_mangle]
1256 pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1257         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1258         *inner_val
1259 }
1260 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1261 /// omitted
1262 #[no_mangle]
1263 pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1264         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1265 }
1266 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1267 #[no_mangle]
1268 pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 {
1269         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1270         *inner_val
1271 }
1272 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1273 #[no_mangle]
1274 pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1275         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1276 }
1277 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1278 #[no_mangle]
1279 pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 {
1280         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1281         *inner_val
1282 }
1283 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1284 #[no_mangle]
1285 pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1286         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1287 }
1288 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1289 /// broadcast a commitment transaction
1290 #[no_mangle]
1291 pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 {
1292         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1293         *inner_val
1294 }
1295 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1296 /// broadcast a commitment transaction
1297 #[no_mangle]
1298 pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) {
1299         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1300 }
1301 /// The maximum number of inbound HTLCs towards channel initiator
1302 #[no_mangle]
1303 pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 {
1304         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1305         *inner_val
1306 }
1307 /// The maximum number of inbound HTLCs towards channel initiator
1308 #[no_mangle]
1309 pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) {
1310         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1311 }
1312 /// The locktime for the funding transaction
1313 #[no_mangle]
1314 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1315         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1316         *inner_val
1317 }
1318 /// The locktime for the funding transaction
1319 #[no_mangle]
1320 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1321         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1322 }
1323 /// The channel initiator's key controlling the funding transaction
1324 #[no_mangle]
1325 pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1326         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1327         crate::c_types::PublicKey::from_rust(&inner_val)
1328 }
1329 /// The channel initiator's key controlling the funding transaction
1330 #[no_mangle]
1331 pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1332         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1333 }
1334 /// Used to derive a revocation key for transactions broadcast by counterparty
1335 #[no_mangle]
1336 pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1337         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1338         crate::c_types::PublicKey::from_rust(&inner_val)
1339 }
1340 /// Used to derive a revocation key for transactions broadcast by counterparty
1341 #[no_mangle]
1342 pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1343         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1344 }
1345 /// A payment key to channel initiator for transactions broadcast by counterparty
1346 #[no_mangle]
1347 pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1348         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1349         crate::c_types::PublicKey::from_rust(&inner_val)
1350 }
1351 /// A payment key to channel initiator for transactions broadcast by counterparty
1352 #[no_mangle]
1353 pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1354         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1355 }
1356 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1357 /// initiator
1358 #[no_mangle]
1359 pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1360         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1361         crate::c_types::PublicKey::from_rust(&inner_val)
1362 }
1363 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1364 /// initiator
1365 #[no_mangle]
1366 pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1367         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1368 }
1369 /// Used to derive an HTLC payment key to channel initiator
1370 #[no_mangle]
1371 pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1372         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1373         crate::c_types::PublicKey::from_rust(&inner_val)
1374 }
1375 /// Used to derive an HTLC payment key to channel initiator
1376 #[no_mangle]
1377 pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1378         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1379 }
1380 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1381 #[no_mangle]
1382 pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1383         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1384         crate::c_types::PublicKey::from_rust(&inner_val)
1385 }
1386 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1387 #[no_mangle]
1388 pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1389         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1390 }
1391 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1392 #[no_mangle]
1393 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1394         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1395         crate::c_types::PublicKey::from_rust(&inner_val)
1396 }
1397 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1398 #[no_mangle]
1399 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1400         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1401 }
1402 /// Channel flags
1403 #[no_mangle]
1404 pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 {
1405         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1406         *inner_val
1407 }
1408 /// Channel flags
1409 #[no_mangle]
1410 pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) {
1411         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1412 }
1413 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1414 /// collaboratively close
1415 #[no_mangle]
1416 pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
1417         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1418         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1419         local_inner_val
1420 }
1421 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1422 /// collaboratively close
1423 #[no_mangle]
1424 pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1425         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1426         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1427 }
1428 /// The channel type that this channel will represent. If none is set, we derive the channel
1429 /// type from the intersection of our feature bits with our counterparty's feature bits from
1430 /// the Init message.
1431 ///
1432 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1433 #[no_mangle]
1434 pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
1435         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1436         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 };
1437         local_inner_val
1438 }
1439 /// The channel type that this channel will represent. If none is set, we derive the channel
1440 /// type from the intersection of our feature bits with our counterparty's feature bits from
1441 /// the Init message.
1442 ///
1443 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1444 #[no_mangle]
1445 pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1446         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1447         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1448 }
1449 /// Optionally, a requirement that only confirmed inputs can be added
1450 #[no_mangle]
1451 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1452         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1453         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 /*  { () /**/ } */ };
1454         local_inner_val
1455 }
1456 /// Optionally, a requirement that only confirmed inputs can be added
1457 #[no_mangle]
1458 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1459         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1460         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1461 }
1462 /// Constructs a new OpenChannelV2 given each field
1463 ///
1464 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1465 #[must_use]
1466 #[no_mangle]
1467 pub extern "C" fn OpenChannelV2_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_feerate_sat_per_1000_weight_arg: u32, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 {
1468         let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1469         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()) } }) };
1470         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1471         OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1472                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
1473                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1474                 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1475                 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1476                 funding_satoshis: funding_satoshis_arg,
1477                 dust_limit_satoshis: dust_limit_satoshis_arg,
1478                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1479                 htlc_minimum_msat: htlc_minimum_msat_arg,
1480                 to_self_delay: to_self_delay_arg,
1481                 max_accepted_htlcs: max_accepted_htlcs_arg,
1482                 locktime: locktime_arg,
1483                 funding_pubkey: funding_pubkey_arg.into_rust(),
1484                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1485                 payment_basepoint: payment_basepoint_arg.into_rust(),
1486                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1487                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1488                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1489                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1490                 channel_flags: channel_flags_arg,
1491                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1492                 channel_type: local_channel_type_arg,
1493                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1494         }), is_owned: true }
1495 }
1496 impl Clone for OpenChannelV2 {
1497         fn clone(&self) -> Self {
1498                 Self {
1499                         inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1500                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1501                         is_owned: true,
1502                 }
1503         }
1504 }
1505 #[allow(unused)]
1506 /// Used only if an object of this type is returned as a trait impl by a method
1507 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1508         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannelV2)).clone() })) as *mut c_void
1509 }
1510 #[no_mangle]
1511 /// Creates a copy of the OpenChannelV2
1512 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1513         orig.clone()
1514 }
1515 /// Checks if two OpenChannelV2s contain equal inner contents.
1516 /// This ignores pointers and is_owned flags and looks at the values in fields.
1517 /// Two objects with NULL inner values will be considered "equal" here.
1518 #[no_mangle]
1519 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1520         if a.inner == b.inner { return true; }
1521         if a.inner.is_null() || b.inner.is_null() { return false; }
1522         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1523 }
1524
1525 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1526 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1527
1528 /// An [`accept_channel`] message to be sent to or received from a peer.
1529 ///
1530 /// Used in V1 channel establishment
1531 ///
1532 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1533 #[must_use]
1534 #[repr(C)]
1535 pub struct AcceptChannel {
1536         /// A pointer to the opaque Rust object.
1537
1538         /// Nearly everywhere, inner must be non-null, however in places where
1539         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1540         pub inner: *mut nativeAcceptChannel,
1541         /// Indicates that this is the only struct which contains the same pointer.
1542
1543         /// Rust functions which take ownership of an object provided via an argument require
1544         /// this to be true and invalidate the object pointed to by inner.
1545         pub is_owned: bool,
1546 }
1547
1548 impl Drop for AcceptChannel {
1549         fn drop(&mut self) {
1550                 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1551                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1552                 }
1553         }
1554 }
1555 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1556 #[no_mangle]
1557 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1558 #[allow(unused)]
1559 /// Used only if an object of this type is returned as a trait impl by a method
1560 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1561         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1562 }
1563 #[allow(unused)]
1564 impl AcceptChannel {
1565         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1566                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1567         }
1568         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1569                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1570         }
1571         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1572         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1573                 assert!(self.is_owned);
1574                 let ret = ObjOps::untweak_ptr(self.inner);
1575                 self.inner = core::ptr::null_mut();
1576                 ret
1577         }
1578 }
1579 /// A temporary channel ID, until the funding outpoint is announced
1580 #[no_mangle]
1581 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1582         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1583         &inner_val.0
1584 }
1585 /// A temporary channel ID, until the funding outpoint is announced
1586 #[no_mangle]
1587 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1588         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1589 }
1590 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1591 #[no_mangle]
1592 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1593         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1594         *inner_val
1595 }
1596 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1597 #[no_mangle]
1598 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1599         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1600 }
1601 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1602 #[no_mangle]
1603 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1604         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1605         *inner_val
1606 }
1607 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1608 #[no_mangle]
1609 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1610         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1611 }
1612 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1613 #[no_mangle]
1614 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1615         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1616         *inner_val
1617 }
1618 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1619 #[no_mangle]
1620 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1621         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1622 }
1623 /// The minimum HTLC size incoming to sender, in milli-satoshi
1624 #[no_mangle]
1625 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1626         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1627         *inner_val
1628 }
1629 /// The minimum HTLC size incoming to sender, in milli-satoshi
1630 #[no_mangle]
1631 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1632         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1633 }
1634 /// Minimum depth of the funding transaction before the channel is considered open
1635 #[no_mangle]
1636 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1637         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1638         *inner_val
1639 }
1640 /// Minimum depth of the funding transaction before the channel is considered open
1641 #[no_mangle]
1642 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1643         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1644 }
1645 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1646 #[no_mangle]
1647 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1648         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1649         *inner_val
1650 }
1651 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1652 #[no_mangle]
1653 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1654         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1655 }
1656 /// The maximum number of inbound HTLCs towards sender
1657 #[no_mangle]
1658 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1659         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1660         *inner_val
1661 }
1662 /// The maximum number of inbound HTLCs towards sender
1663 #[no_mangle]
1664 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1665         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1666 }
1667 /// The sender's key controlling the funding transaction
1668 #[no_mangle]
1669 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1670         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1671         crate::c_types::PublicKey::from_rust(&inner_val)
1672 }
1673 /// The sender's key controlling the funding transaction
1674 #[no_mangle]
1675 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1676         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1677 }
1678 /// Used to derive a revocation key for transactions broadcast by counterparty
1679 #[no_mangle]
1680 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1681         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1682         crate::c_types::PublicKey::from_rust(&inner_val)
1683 }
1684 /// Used to derive a revocation key for transactions broadcast by counterparty
1685 #[no_mangle]
1686 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1687         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1688 }
1689 /// A payment key to sender for transactions broadcast by counterparty
1690 #[no_mangle]
1691 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1692         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1693         crate::c_types::PublicKey::from_rust(&inner_val)
1694 }
1695 /// A payment key to sender for transactions broadcast by counterparty
1696 #[no_mangle]
1697 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1698         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1699 }
1700 /// Used to derive a payment key to sender for transactions broadcast by sender
1701 #[no_mangle]
1702 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1703         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1704         crate::c_types::PublicKey::from_rust(&inner_val)
1705 }
1706 /// Used to derive a payment key to sender for transactions broadcast by sender
1707 #[no_mangle]
1708 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1709         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1710 }
1711 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1712 #[no_mangle]
1713 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1714         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1715         crate::c_types::PublicKey::from_rust(&inner_val)
1716 }
1717 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1718 #[no_mangle]
1719 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1720         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1721 }
1722 /// The first to-be-broadcast-by-sender transaction's per commitment point
1723 #[no_mangle]
1724 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1725         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1726         crate::c_types::PublicKey::from_rust(&inner_val)
1727 }
1728 /// The first to-be-broadcast-by-sender transaction's per commitment point
1729 #[no_mangle]
1730 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1731         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1732 }
1733 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1734 #[no_mangle]
1735 pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1736         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1737         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1738         local_inner_val
1739 }
1740 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1741 #[no_mangle]
1742 pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1743         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1744         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1745 }
1746 /// The channel type that this channel will represent.
1747 ///
1748 /// If this is `None`, we derive the channel type from the intersection of
1749 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1750 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1751 ///
1752 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1753 #[no_mangle]
1754 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1755         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1756         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 };
1757         local_inner_val
1758 }
1759 /// The channel type that this channel will represent.
1760 ///
1761 /// If this is `None`, we derive the channel type from the intersection of
1762 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1763 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1764 ///
1765 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1766 #[no_mangle]
1767 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1768         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1769         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1770 }
1771 /// Constructs a new AcceptChannel given each field
1772 ///
1773 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1774 #[must_use]
1775 #[no_mangle]
1776 pub extern "C" fn AcceptChannel_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> AcceptChannel {
1777         let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1778         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()) } }) };
1779         AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1780                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1781                 dust_limit_satoshis: dust_limit_satoshis_arg,
1782                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1783                 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1784                 htlc_minimum_msat: htlc_minimum_msat_arg,
1785                 minimum_depth: minimum_depth_arg,
1786                 to_self_delay: to_self_delay_arg,
1787                 max_accepted_htlcs: max_accepted_htlcs_arg,
1788                 funding_pubkey: funding_pubkey_arg.into_rust(),
1789                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1790                 payment_point: payment_point_arg.into_rust(),
1791                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1792                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1793                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1794                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1795                 channel_type: local_channel_type_arg,
1796         }), is_owned: true }
1797 }
1798 impl Clone for AcceptChannel {
1799         fn clone(&self) -> Self {
1800                 Self {
1801                         inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1802                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1803                         is_owned: true,
1804                 }
1805         }
1806 }
1807 #[allow(unused)]
1808 /// Used only if an object of this type is returned as a trait impl by a method
1809 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1810         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1811 }
1812 #[no_mangle]
1813 /// Creates a copy of the AcceptChannel
1814 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1815         orig.clone()
1816 }
1817 /// Checks if two AcceptChannels contain equal inner contents.
1818 /// This ignores pointers and is_owned flags and looks at the values in fields.
1819 /// Two objects with NULL inner values will be considered "equal" here.
1820 #[no_mangle]
1821 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1822         if a.inner == b.inner { return true; }
1823         if a.inner.is_null() || b.inner.is_null() { return false; }
1824         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1825 }
1826
1827 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1828 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1829
1830 /// An accept_channel2 message to be sent by or received from the channel accepter.
1831 ///
1832 /// Used in V2 channel establishment
1833 ///
1834 #[must_use]
1835 #[repr(C)]
1836 pub struct AcceptChannelV2 {
1837         /// A pointer to the opaque Rust object.
1838
1839         /// Nearly everywhere, inner must be non-null, however in places where
1840         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1841         pub inner: *mut nativeAcceptChannelV2,
1842         /// Indicates that this is the only struct which contains the same pointer.
1843
1844         /// Rust functions which take ownership of an object provided via an argument require
1845         /// this to be true and invalidate the object pointed to by inner.
1846         pub is_owned: bool,
1847 }
1848
1849 impl Drop for AcceptChannelV2 {
1850         fn drop(&mut self) {
1851                 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
1852                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1853                 }
1854         }
1855 }
1856 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
1857 #[no_mangle]
1858 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
1859 #[allow(unused)]
1860 /// Used only if an object of this type is returned as a trait impl by a method
1861 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
1862         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
1863 }
1864 #[allow(unused)]
1865 impl AcceptChannelV2 {
1866         pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
1867                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1868         }
1869         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
1870                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1871         }
1872         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1873         pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
1874                 assert!(self.is_owned);
1875                 let ret = ObjOps::untweak_ptr(self.inner);
1876                 self.inner = core::ptr::null_mut();
1877                 ret
1878         }
1879 }
1880 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1881 #[no_mangle]
1882 pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] {
1883         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1884         &inner_val.0
1885 }
1886 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1887 #[no_mangle]
1888 pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1889         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1890 }
1891 /// Part of the channel value contributed by the channel acceptor
1892 #[no_mangle]
1893 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1894         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1895         *inner_val
1896 }
1897 /// Part of the channel value contributed by the channel acceptor
1898 #[no_mangle]
1899 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1900         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1901 }
1902 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1903 /// omitted
1904 #[no_mangle]
1905 pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1906         let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1907         *inner_val
1908 }
1909 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1910 /// omitted
1911 #[no_mangle]
1912 pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1913         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1914 }
1915 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1916 #[no_mangle]
1917 pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 {
1918         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1919         *inner_val
1920 }
1921 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1922 #[no_mangle]
1923 pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1924         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1925 }
1926 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1927 #[no_mangle]
1928 pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 {
1929         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1930         *inner_val
1931 }
1932 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1933 #[no_mangle]
1934 pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1935         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1936 }
1937 /// Minimum depth of the funding transaction before the channel is considered open
1938 #[no_mangle]
1939 pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 {
1940         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1941         *inner_val
1942 }
1943 /// Minimum depth of the funding transaction before the channel is considered open
1944 #[no_mangle]
1945 pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) {
1946         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1947 }
1948 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1949 /// broadcast a commitment transaction
1950 #[no_mangle]
1951 pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 {
1952         let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1953         *inner_val
1954 }
1955 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1956 /// broadcast a commitment transaction
1957 #[no_mangle]
1958 pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1959         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1960 }
1961 /// The maximum number of inbound HTLCs towards channel acceptor
1962 #[no_mangle]
1963 pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 {
1964         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1965         *inner_val
1966 }
1967 /// The maximum number of inbound HTLCs towards channel acceptor
1968 #[no_mangle]
1969 pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1970         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1971 }
1972 /// The channel acceptor's key controlling the funding transaction
1973 #[no_mangle]
1974 pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1975         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1976         crate::c_types::PublicKey::from_rust(&inner_val)
1977 }
1978 /// The channel acceptor's key controlling the funding transaction
1979 #[no_mangle]
1980 pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1981         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1982 }
1983 /// Used to derive a revocation key for transactions broadcast by counterparty
1984 #[no_mangle]
1985 pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1986         let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1987         crate::c_types::PublicKey::from_rust(&inner_val)
1988 }
1989 /// Used to derive a revocation key for transactions broadcast by counterparty
1990 #[no_mangle]
1991 pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1992         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1993 }
1994 /// A payment key to channel acceptor for transactions broadcast by counterparty
1995 #[no_mangle]
1996 pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1997         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1998         crate::c_types::PublicKey::from_rust(&inner_val)
1999 }
2000 /// A payment key to channel acceptor for transactions broadcast by counterparty
2001 #[no_mangle]
2002 pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2003         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
2004 }
2005 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2006 /// acceptor
2007 #[no_mangle]
2008 pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2009         let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
2010         crate::c_types::PublicKey::from_rust(&inner_val)
2011 }
2012 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2013 /// acceptor
2014 #[no_mangle]
2015 pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2016         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
2017 }
2018 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2019 #[no_mangle]
2020 pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2021         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
2022         crate::c_types::PublicKey::from_rust(&inner_val)
2023 }
2024 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2025 #[no_mangle]
2026 pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2027         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
2028 }
2029 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2030 #[no_mangle]
2031 pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2032         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
2033         crate::c_types::PublicKey::from_rust(&inner_val)
2034 }
2035 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2036 #[no_mangle]
2037 pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2038         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
2039 }
2040 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2041 #[no_mangle]
2042 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2043         let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2044         crate::c_types::PublicKey::from_rust(&inner_val)
2045 }
2046 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2047 #[no_mangle]
2048 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2049         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2050 }
2051 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2052 /// collaboratively close
2053 #[no_mangle]
2054 pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
2055         let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
2056         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
2057         local_inner_val
2058 }
2059 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2060 /// collaboratively close
2061 #[no_mangle]
2062 pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
2063         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
2064         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
2065 }
2066 /// The channel type that this channel will represent. If none is set, we derive the channel
2067 /// type from the intersection of our feature bits with our counterparty's feature bits from
2068 /// the Init message.
2069 ///
2070 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2071 ///
2072 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2073 #[no_mangle]
2074 pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
2075         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
2076         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 };
2077         local_inner_val
2078 }
2079 /// The channel type that this channel will represent. If none is set, we derive the channel
2080 /// type from the intersection of our feature bits with our counterparty's feature bits from
2081 /// the Init message.
2082 ///
2083 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2084 ///
2085 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
2086 #[no_mangle]
2087 pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
2088         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2089         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
2090 }
2091 /// Optionally, a requirement that only confirmed inputs can be added
2092 #[no_mangle]
2093 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2094         let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2095         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 /*  { () /**/ } */ };
2096         local_inner_val
2097 }
2098 /// Optionally, a requirement that only confirmed inputs can be added
2099 #[no_mangle]
2100 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2101         let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2102         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2103 }
2104 /// Constructs a new AcceptChannelV2 given each field
2105 ///
2106 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
2107 #[must_use]
2108 #[no_mangle]
2109 pub extern "C" fn AcceptChannelV2_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 {
2110         let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
2111         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()) } }) };
2112         let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2113         AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2114                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2115                 funding_satoshis: funding_satoshis_arg,
2116                 dust_limit_satoshis: dust_limit_satoshis_arg,
2117                 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
2118                 htlc_minimum_msat: htlc_minimum_msat_arg,
2119                 minimum_depth: minimum_depth_arg,
2120                 to_self_delay: to_self_delay_arg,
2121                 max_accepted_htlcs: max_accepted_htlcs_arg,
2122                 funding_pubkey: funding_pubkey_arg.into_rust(),
2123                 revocation_basepoint: revocation_basepoint_arg.into_rust(),
2124                 payment_basepoint: payment_basepoint_arg.into_rust(),
2125                 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
2126                 htlc_basepoint: htlc_basepoint_arg.into_rust(),
2127                 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
2128                 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2129                 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
2130                 channel_type: local_channel_type_arg,
2131                 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2132         }), is_owned: true }
2133 }
2134 impl Clone for AcceptChannelV2 {
2135         fn clone(&self) -> Self {
2136                 Self {
2137                         inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2138                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2139                         is_owned: true,
2140                 }
2141         }
2142 }
2143 #[allow(unused)]
2144 /// Used only if an object of this type is returned as a trait impl by a method
2145 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2146         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannelV2)).clone() })) as *mut c_void
2147 }
2148 #[no_mangle]
2149 /// Creates a copy of the AcceptChannelV2
2150 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2151         orig.clone()
2152 }
2153 /// Checks if two AcceptChannelV2s contain equal inner contents.
2154 /// This ignores pointers and is_owned flags and looks at the values in fields.
2155 /// Two objects with NULL inner values will be considered "equal" here.
2156 #[no_mangle]
2157 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2158         if a.inner == b.inner { return true; }
2159         if a.inner.is_null() || b.inner.is_null() { return false; }
2160         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2161 }
2162
2163 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2164 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2165
2166 /// A [`funding_created`] message to be sent to or received from a peer.
2167 ///
2168 /// Used in V1 channel establishment
2169 ///
2170 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2171 #[must_use]
2172 #[repr(C)]
2173 pub struct FundingCreated {
2174         /// A pointer to the opaque Rust object.
2175
2176         /// Nearly everywhere, inner must be non-null, however in places where
2177         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2178         pub inner: *mut nativeFundingCreated,
2179         /// Indicates that this is the only struct which contains the same pointer.
2180
2181         /// Rust functions which take ownership of an object provided via an argument require
2182         /// this to be true and invalidate the object pointed to by inner.
2183         pub is_owned: bool,
2184 }
2185
2186 impl Drop for FundingCreated {
2187         fn drop(&mut self) {
2188                 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2189                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2190                 }
2191         }
2192 }
2193 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2194 #[no_mangle]
2195 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2196 #[allow(unused)]
2197 /// Used only if an object of this type is returned as a trait impl by a method
2198 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2199         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2200 }
2201 #[allow(unused)]
2202 impl FundingCreated {
2203         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2204                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2205         }
2206         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2207                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2208         }
2209         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2210         pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2211                 assert!(self.is_owned);
2212                 let ret = ObjOps::untweak_ptr(self.inner);
2213                 self.inner = core::ptr::null_mut();
2214                 ret
2215         }
2216 }
2217 /// A temporary channel ID, until the funding is established
2218 #[no_mangle]
2219 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
2220         let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2221         &inner_val.0
2222 }
2223 /// A temporary channel ID, until the funding is established
2224 #[no_mangle]
2225 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2226         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
2227 }
2228 /// The funding transaction ID
2229 #[no_mangle]
2230 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2231         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2232         inner_val.as_inner()
2233 }
2234 /// The funding transaction ID
2235 #[no_mangle]
2236 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2237         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2238 }
2239 /// The specific output index funding this channel
2240 #[no_mangle]
2241 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2242         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2243         *inner_val
2244 }
2245 /// The specific output index funding this channel
2246 #[no_mangle]
2247 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2248         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2249 }
2250 /// The signature of the channel initiator (funder) on the initial commitment transaction
2251 #[no_mangle]
2252 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::ECDSASignature {
2253         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2254         crate::c_types::ECDSASignature::from_rust(&inner_val)
2255 }
2256 /// The signature of the channel initiator (funder) on the initial commitment transaction
2257 #[no_mangle]
2258 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::ECDSASignature) {
2259         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2260 }
2261 /// Constructs a new FundingCreated given each field
2262 #[must_use]
2263 #[no_mangle]
2264 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::ECDSASignature) -> FundingCreated {
2265         FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2266                 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2267                 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2268                 funding_output_index: funding_output_index_arg,
2269                 signature: signature_arg.into_rust(),
2270         }), is_owned: true }
2271 }
2272 impl Clone for FundingCreated {
2273         fn clone(&self) -> Self {
2274                 Self {
2275                         inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2276                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2277                         is_owned: true,
2278                 }
2279         }
2280 }
2281 #[allow(unused)]
2282 /// Used only if an object of this type is returned as a trait impl by a method
2283 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2284         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
2285 }
2286 #[no_mangle]
2287 /// Creates a copy of the FundingCreated
2288 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2289         orig.clone()
2290 }
2291 /// Checks if two FundingCreateds contain equal inner contents.
2292 /// This ignores pointers and is_owned flags and looks at the values in fields.
2293 /// Two objects with NULL inner values will be considered "equal" here.
2294 #[no_mangle]
2295 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2296         if a.inner == b.inner { return true; }
2297         if a.inner.is_null() || b.inner.is_null() { return false; }
2298         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2299 }
2300
2301 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2302 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2303
2304 /// A [`funding_signed`] message to be sent to or received from a peer.
2305 ///
2306 /// Used in V1 channel establishment
2307 ///
2308 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2309 #[must_use]
2310 #[repr(C)]
2311 pub struct FundingSigned {
2312         /// A pointer to the opaque Rust object.
2313
2314         /// Nearly everywhere, inner must be non-null, however in places where
2315         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2316         pub inner: *mut nativeFundingSigned,
2317         /// Indicates that this is the only struct which contains the same pointer.
2318
2319         /// Rust functions which take ownership of an object provided via an argument require
2320         /// this to be true and invalidate the object pointed to by inner.
2321         pub is_owned: bool,
2322 }
2323
2324 impl Drop for FundingSigned {
2325         fn drop(&mut self) {
2326                 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2327                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2328                 }
2329         }
2330 }
2331 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2332 #[no_mangle]
2333 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2334 #[allow(unused)]
2335 /// Used only if an object of this type is returned as a trait impl by a method
2336 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2337         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2338 }
2339 #[allow(unused)]
2340 impl FundingSigned {
2341         pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2342                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2343         }
2344         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2345                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2346         }
2347         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2348         pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2349                 assert!(self.is_owned);
2350                 let ret = ObjOps::untweak_ptr(self.inner);
2351                 self.inner = core::ptr::null_mut();
2352                 ret
2353         }
2354 }
2355 /// The channel ID
2356 #[no_mangle]
2357 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
2358         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2359         &inner_val.0
2360 }
2361 /// The channel ID
2362 #[no_mangle]
2363 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2364         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2365 }
2366 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2367 #[no_mangle]
2368 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::ECDSASignature {
2369         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2370         crate::c_types::ECDSASignature::from_rust(&inner_val)
2371 }
2372 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2373 #[no_mangle]
2374 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::ECDSASignature) {
2375         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2376 }
2377 /// Constructs a new FundingSigned given each field
2378 #[must_use]
2379 #[no_mangle]
2380 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned {
2381         FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2382                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2383                 signature: signature_arg.into_rust(),
2384         }), is_owned: true }
2385 }
2386 impl Clone for FundingSigned {
2387         fn clone(&self) -> Self {
2388                 Self {
2389                         inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2390                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2391                         is_owned: true,
2392                 }
2393         }
2394 }
2395 #[allow(unused)]
2396 /// Used only if an object of this type is returned as a trait impl by a method
2397 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2398         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
2399 }
2400 #[no_mangle]
2401 /// Creates a copy of the FundingSigned
2402 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2403         orig.clone()
2404 }
2405 /// Checks if two FundingSigneds contain equal inner contents.
2406 /// This ignores pointers and is_owned flags and looks at the values in fields.
2407 /// Two objects with NULL inner values will be considered "equal" here.
2408 #[no_mangle]
2409 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2410         if a.inner == b.inner { return true; }
2411         if a.inner.is_null() || b.inner.is_null() { return false; }
2412         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2413 }
2414
2415 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2416 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2417
2418 /// A [`channel_ready`] message to be sent to or received from a peer.
2419 ///
2420 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2421 #[must_use]
2422 #[repr(C)]
2423 pub struct ChannelReady {
2424         /// A pointer to the opaque Rust object.
2425
2426         /// Nearly everywhere, inner must be non-null, however in places where
2427         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2428         pub inner: *mut nativeChannelReady,
2429         /// Indicates that this is the only struct which contains the same pointer.
2430
2431         /// Rust functions which take ownership of an object provided via an argument require
2432         /// this to be true and invalidate the object pointed to by inner.
2433         pub is_owned: bool,
2434 }
2435
2436 impl Drop for ChannelReady {
2437         fn drop(&mut self) {
2438                 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2439                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2440                 }
2441         }
2442 }
2443 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2444 #[no_mangle]
2445 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2446 #[allow(unused)]
2447 /// Used only if an object of this type is returned as a trait impl by a method
2448 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2449         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2450 }
2451 #[allow(unused)]
2452 impl ChannelReady {
2453         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2454                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2455         }
2456         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2457                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2458         }
2459         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2460         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2461                 assert!(self.is_owned);
2462                 let ret = ObjOps::untweak_ptr(self.inner);
2463                 self.inner = core::ptr::null_mut();
2464                 ret
2465         }
2466 }
2467 /// The channel ID
2468 #[no_mangle]
2469 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
2470         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2471         &inner_val.0
2472 }
2473 /// The channel ID
2474 #[no_mangle]
2475 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
2476         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2477 }
2478 /// The per-commitment point of the second commitment transaction
2479 #[no_mangle]
2480 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2481         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2482         crate::c_types::PublicKey::from_rust(&inner_val)
2483 }
2484 /// The per-commitment point of the second commitment transaction
2485 #[no_mangle]
2486 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2487         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2488 }
2489 /// If set, provides a `short_channel_id` alias for this channel.
2490 ///
2491 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2492 /// messages' recipient.
2493 #[no_mangle]
2494 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2495         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2496         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() }) };
2497         local_inner_val
2498 }
2499 /// If set, provides a `short_channel_id` alias for this channel.
2500 ///
2501 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2502 /// messages' recipient.
2503 #[no_mangle]
2504 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2505         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2506         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2507 }
2508 /// Constructs a new ChannelReady given each field
2509 #[must_use]
2510 #[no_mangle]
2511 pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady {
2512         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 };
2513         ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2514                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2515                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2516                 short_channel_id_alias: local_short_channel_id_alias_arg,
2517         }), is_owned: true }
2518 }
2519 impl Clone for ChannelReady {
2520         fn clone(&self) -> Self {
2521                 Self {
2522                         inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2523                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2524                         is_owned: true,
2525                 }
2526         }
2527 }
2528 #[allow(unused)]
2529 /// Used only if an object of this type is returned as a trait impl by a method
2530 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2531         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void
2532 }
2533 #[no_mangle]
2534 /// Creates a copy of the ChannelReady
2535 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2536         orig.clone()
2537 }
2538 /// Checks if two ChannelReadys contain equal inner contents.
2539 /// This ignores pointers and is_owned flags and looks at the values in fields.
2540 /// Two objects with NULL inner values will be considered "equal" here.
2541 #[no_mangle]
2542 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2543         if a.inner == b.inner { return true; }
2544         if a.inner.is_null() || b.inner.is_null() { return false; }
2545         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2546 }
2547
2548 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
2549 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
2550
2551 /// A tx_add_input message for adding an input during interactive transaction construction
2552 ///
2553 #[must_use]
2554 #[repr(C)]
2555 pub struct TxAddInput {
2556         /// A pointer to the opaque Rust object.
2557
2558         /// Nearly everywhere, inner must be non-null, however in places where
2559         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2560         pub inner: *mut nativeTxAddInput,
2561         /// Indicates that this is the only struct which contains the same pointer.
2562
2563         /// Rust functions which take ownership of an object provided via an argument require
2564         /// this to be true and invalidate the object pointed to by inner.
2565         pub is_owned: bool,
2566 }
2567
2568 impl Drop for TxAddInput {
2569         fn drop(&mut self) {
2570                 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
2571                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2572                 }
2573         }
2574 }
2575 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
2576 #[no_mangle]
2577 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
2578 #[allow(unused)]
2579 /// Used only if an object of this type is returned as a trait impl by a method
2580 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
2581         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
2582 }
2583 #[allow(unused)]
2584 impl TxAddInput {
2585         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
2586                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2587         }
2588         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
2589                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2590         }
2591         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2592         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
2593                 assert!(self.is_owned);
2594                 let ret = ObjOps::untweak_ptr(self.inner);
2595                 self.inner = core::ptr::null_mut();
2596                 ret
2597         }
2598 }
2599 /// The channel ID
2600 #[no_mangle]
2601 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] {
2602         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2603         &inner_val.0
2604 }
2605 /// The channel ID
2606 #[no_mangle]
2607 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) {
2608         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2609 }
2610 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2611 /// non-initiators.
2612 #[no_mangle]
2613 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
2614         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2615         *inner_val
2616 }
2617 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2618 /// non-initiators.
2619 #[no_mangle]
2620 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
2621         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2622 }
2623 /// Serialized transaction that contains the output this input spends to verify that it is non
2624 /// malleable.
2625 #[no_mangle]
2626 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
2627         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
2628         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 }
2629 }
2630 /// Serialized transaction that contains the output this input spends to verify that it is non
2631 /// malleable.
2632 #[no_mangle]
2633 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
2634         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
2635 }
2636 /// The index of the output being spent
2637 #[no_mangle]
2638 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
2639         let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
2640         *inner_val
2641 }
2642 /// The index of the output being spent
2643 #[no_mangle]
2644 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
2645         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
2646 }
2647 /// The sequence number of this input
2648 #[no_mangle]
2649 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
2650         let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
2651         *inner_val
2652 }
2653 /// The sequence number of this input
2654 #[no_mangle]
2655 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
2656         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
2657 }
2658 /// Constructs a new TxAddInput given each field
2659 #[must_use]
2660 #[no_mangle]
2661 pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput {
2662         TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
2663                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2664                 serial_id: serial_id_arg,
2665                 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
2666                 prevtx_out: prevtx_out_arg,
2667                 sequence: sequence_arg,
2668         }), is_owned: true }
2669 }
2670 impl Clone for TxAddInput {
2671         fn clone(&self) -> Self {
2672                 Self {
2673                         inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2674                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2675                         is_owned: true,
2676                 }
2677         }
2678 }
2679 #[allow(unused)]
2680 /// Used only if an object of this type is returned as a trait impl by a method
2681 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2682         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddInput)).clone() })) as *mut c_void
2683 }
2684 #[no_mangle]
2685 /// Creates a copy of the TxAddInput
2686 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
2687         orig.clone()
2688 }
2689 /// Checks if two TxAddInputs contain equal inner contents.
2690 /// This ignores pointers and is_owned flags and looks at the values in fields.
2691 /// Two objects with NULL inner values will be considered "equal" here.
2692 #[no_mangle]
2693 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
2694         if a.inner == b.inner { return true; }
2695         if a.inner.is_null() || b.inner.is_null() { return false; }
2696         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2697 }
2698
2699 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
2700 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
2701
2702 /// A tx_add_output message for adding an output during interactive transaction construction.
2703 ///
2704 #[must_use]
2705 #[repr(C)]
2706 pub struct TxAddOutput {
2707         /// A pointer to the opaque Rust object.
2708
2709         /// Nearly everywhere, inner must be non-null, however in places where
2710         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2711         pub inner: *mut nativeTxAddOutput,
2712         /// Indicates that this is the only struct which contains the same pointer.
2713
2714         /// Rust functions which take ownership of an object provided via an argument require
2715         /// this to be true and invalidate the object pointed to by inner.
2716         pub is_owned: bool,
2717 }
2718
2719 impl Drop for TxAddOutput {
2720         fn drop(&mut self) {
2721                 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
2722                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2723                 }
2724         }
2725 }
2726 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
2727 #[no_mangle]
2728 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
2729 #[allow(unused)]
2730 /// Used only if an object of this type is returned as a trait impl by a method
2731 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
2732         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
2733 }
2734 #[allow(unused)]
2735 impl TxAddOutput {
2736         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
2737                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2738         }
2739         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
2740                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2741         }
2742         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2743         pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
2744                 assert!(self.is_owned);
2745                 let ret = ObjOps::untweak_ptr(self.inner);
2746                 self.inner = core::ptr::null_mut();
2747                 ret
2748         }
2749 }
2750 /// The channel ID
2751 #[no_mangle]
2752 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] {
2753         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2754         &inner_val.0
2755 }
2756 /// The channel ID
2757 #[no_mangle]
2758 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) {
2759         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2760 }
2761 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2762 /// non-initiators.
2763 #[no_mangle]
2764 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
2765         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2766         *inner_val
2767 }
2768 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2769 /// non-initiators.
2770 #[no_mangle]
2771 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
2772         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2773 }
2774 /// The satoshi value of the output
2775 #[no_mangle]
2776 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
2777         let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
2778         *inner_val
2779 }
2780 /// The satoshi value of the output
2781 #[no_mangle]
2782 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
2783         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
2784 }
2785 /// The scriptPubKey for the output
2786 #[no_mangle]
2787 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::u8slice {
2788         let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
2789         crate::c_types::u8slice::from_slice(&inner_val[..])
2790 }
2791 /// The scriptPubKey for the output
2792 #[no_mangle]
2793 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
2794         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::Script::from(val.into_rust());
2795 }
2796 /// Constructs a new TxAddOutput given each field
2797 #[must_use]
2798 #[no_mangle]
2799 pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput {
2800         TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
2801                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2802                 serial_id: serial_id_arg,
2803                 sats: sats_arg,
2804                 script: ::bitcoin::blockdata::script::Script::from(script_arg.into_rust()),
2805         }), is_owned: true }
2806 }
2807 impl Clone for TxAddOutput {
2808         fn clone(&self) -> Self {
2809                 Self {
2810                         inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
2811                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2812                         is_owned: true,
2813                 }
2814         }
2815 }
2816 #[allow(unused)]
2817 /// Used only if an object of this type is returned as a trait impl by a method
2818 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2819         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddOutput)).clone() })) as *mut c_void
2820 }
2821 #[no_mangle]
2822 /// Creates a copy of the TxAddOutput
2823 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
2824         orig.clone()
2825 }
2826 /// Checks if two TxAddOutputs contain equal inner contents.
2827 /// This ignores pointers and is_owned flags and looks at the values in fields.
2828 /// Two objects with NULL inner values will be considered "equal" here.
2829 #[no_mangle]
2830 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
2831         if a.inner == b.inner { return true; }
2832         if a.inner.is_null() || b.inner.is_null() { return false; }
2833         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2834 }
2835
2836 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
2837 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
2838
2839 /// A tx_remove_input message for removing an input during interactive transaction construction.
2840 ///
2841 #[must_use]
2842 #[repr(C)]
2843 pub struct TxRemoveInput {
2844         /// A pointer to the opaque Rust object.
2845
2846         /// Nearly everywhere, inner must be non-null, however in places where
2847         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2848         pub inner: *mut nativeTxRemoveInput,
2849         /// Indicates that this is the only struct which contains the same pointer.
2850
2851         /// Rust functions which take ownership of an object provided via an argument require
2852         /// this to be true and invalidate the object pointed to by inner.
2853         pub is_owned: bool,
2854 }
2855
2856 impl Drop for TxRemoveInput {
2857         fn drop(&mut self) {
2858                 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
2859                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2860                 }
2861         }
2862 }
2863 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
2864 #[no_mangle]
2865 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
2866 #[allow(unused)]
2867 /// Used only if an object of this type is returned as a trait impl by a method
2868 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
2869         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
2870 }
2871 #[allow(unused)]
2872 impl TxRemoveInput {
2873         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
2874                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2875         }
2876         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
2877                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2878         }
2879         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2880         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
2881                 assert!(self.is_owned);
2882                 let ret = ObjOps::untweak_ptr(self.inner);
2883                 self.inner = core::ptr::null_mut();
2884                 ret
2885         }
2886 }
2887 /// The channel ID
2888 #[no_mangle]
2889 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] {
2890         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2891         &inner_val.0
2892 }
2893 /// The channel ID
2894 #[no_mangle]
2895 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) {
2896         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2897 }
2898 /// The serial ID of the input to be removed
2899 #[no_mangle]
2900 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
2901         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2902         *inner_val
2903 }
2904 /// The serial ID of the input to be removed
2905 #[no_mangle]
2906 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
2907         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2908 }
2909 /// Constructs a new TxRemoveInput given each field
2910 #[must_use]
2911 #[no_mangle]
2912 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput {
2913         TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
2914                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2915                 serial_id: serial_id_arg,
2916         }), is_owned: true }
2917 }
2918 impl Clone for TxRemoveInput {
2919         fn clone(&self) -> Self {
2920                 Self {
2921                         inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2922                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2923                         is_owned: true,
2924                 }
2925         }
2926 }
2927 #[allow(unused)]
2928 /// Used only if an object of this type is returned as a trait impl by a method
2929 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2930         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveInput)).clone() })) as *mut c_void
2931 }
2932 #[no_mangle]
2933 /// Creates a copy of the TxRemoveInput
2934 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
2935         orig.clone()
2936 }
2937 /// Checks if two TxRemoveInputs contain equal inner contents.
2938 /// This ignores pointers and is_owned flags and looks at the values in fields.
2939 /// Two objects with NULL inner values will be considered "equal" here.
2940 #[no_mangle]
2941 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
2942         if a.inner == b.inner { return true; }
2943         if a.inner.is_null() || b.inner.is_null() { return false; }
2944         if a.get_native_ref() == b.get_native_ref() { true } else { false }
2945 }
2946
2947 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
2948 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
2949
2950 /// A tx_remove_output message for removing an output during interactive transaction construction.
2951 ///
2952 #[must_use]
2953 #[repr(C)]
2954 pub struct TxRemoveOutput {
2955         /// A pointer to the opaque Rust object.
2956
2957         /// Nearly everywhere, inner must be non-null, however in places where
2958         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2959         pub inner: *mut nativeTxRemoveOutput,
2960         /// Indicates that this is the only struct which contains the same pointer.
2961
2962         /// Rust functions which take ownership of an object provided via an argument require
2963         /// this to be true and invalidate the object pointed to by inner.
2964         pub is_owned: bool,
2965 }
2966
2967 impl Drop for TxRemoveOutput {
2968         fn drop(&mut self) {
2969                 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
2970                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2971                 }
2972         }
2973 }
2974 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
2975 #[no_mangle]
2976 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
2977 #[allow(unused)]
2978 /// Used only if an object of this type is returned as a trait impl by a method
2979 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
2980         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
2981 }
2982 #[allow(unused)]
2983 impl TxRemoveOutput {
2984         pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
2985                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2986         }
2987         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
2988                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2989         }
2990         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2991         pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
2992                 assert!(self.is_owned);
2993                 let ret = ObjOps::untweak_ptr(self.inner);
2994                 self.inner = core::ptr::null_mut();
2995                 ret
2996         }
2997 }
2998 /// The channel ID
2999 #[no_mangle]
3000 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] {
3001         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3002         &inner_val.0
3003 }
3004 /// The channel ID
3005 #[no_mangle]
3006 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) {
3007         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3008 }
3009 /// The serial ID of the output to be removed
3010 #[no_mangle]
3011 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3012         let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3013         *inner_val
3014 }
3015 /// The serial ID of the output to be removed
3016 #[no_mangle]
3017 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3018         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3019 }
3020 /// Constructs a new TxRemoveOutput given each field
3021 #[must_use]
3022 #[no_mangle]
3023 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput {
3024         TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3025                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3026                 serial_id: serial_id_arg,
3027         }), is_owned: true }
3028 }
3029 impl Clone for TxRemoveOutput {
3030         fn clone(&self) -> Self {
3031                 Self {
3032                         inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3033                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3034                         is_owned: true,
3035                 }
3036         }
3037 }
3038 #[allow(unused)]
3039 /// Used only if an object of this type is returned as a trait impl by a method
3040 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3041         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveOutput)).clone() })) as *mut c_void
3042 }
3043 #[no_mangle]
3044 /// Creates a copy of the TxRemoveOutput
3045 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3046         orig.clone()
3047 }
3048 /// Checks if two TxRemoveOutputs contain equal inner contents.
3049 /// This ignores pointers and is_owned flags and looks at the values in fields.
3050 /// Two objects with NULL inner values will be considered "equal" here.
3051 #[no_mangle]
3052 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3053         if a.inner == b.inner { return true; }
3054         if a.inner.is_null() || b.inner.is_null() { return false; }
3055         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3056 }
3057
3058 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3059 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3060
3061 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3062 /// interactive transaction construction.
3063 ///
3064 #[must_use]
3065 #[repr(C)]
3066 pub struct TxComplete {
3067         /// A pointer to the opaque Rust object.
3068
3069         /// Nearly everywhere, inner must be non-null, however in places where
3070         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3071         pub inner: *mut nativeTxComplete,
3072         /// Indicates that this is the only struct which contains the same pointer.
3073
3074         /// Rust functions which take ownership of an object provided via an argument require
3075         /// this to be true and invalidate the object pointed to by inner.
3076         pub is_owned: bool,
3077 }
3078
3079 impl Drop for TxComplete {
3080         fn drop(&mut self) {
3081                 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3082                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3083                 }
3084         }
3085 }
3086 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3087 #[no_mangle]
3088 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3089 #[allow(unused)]
3090 /// Used only if an object of this type is returned as a trait impl by a method
3091 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3092         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3093 }
3094 #[allow(unused)]
3095 impl TxComplete {
3096         pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3097                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3098         }
3099         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3100                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3101         }
3102         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3103         pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3104                 assert!(self.is_owned);
3105                 let ret = ObjOps::untweak_ptr(self.inner);
3106                 self.inner = core::ptr::null_mut();
3107                 ret
3108         }
3109 }
3110 /// The channel ID
3111 #[no_mangle]
3112 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] {
3113         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3114         &inner_val.0
3115 }
3116 /// The channel ID
3117 #[no_mangle]
3118 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) {
3119         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3120 }
3121 /// Constructs a new TxComplete given each field
3122 #[must_use]
3123 #[no_mangle]
3124 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete {
3125         TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3126                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3127         }), is_owned: true }
3128 }
3129 impl Clone for TxComplete {
3130         fn clone(&self) -> Self {
3131                 Self {
3132                         inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3133                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3134                         is_owned: true,
3135                 }
3136         }
3137 }
3138 #[allow(unused)]
3139 /// Used only if an object of this type is returned as a trait impl by a method
3140 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3141         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxComplete)).clone() })) as *mut c_void
3142 }
3143 #[no_mangle]
3144 /// Creates a copy of the TxComplete
3145 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3146         orig.clone()
3147 }
3148 /// Checks if two TxCompletes contain equal inner contents.
3149 /// This ignores pointers and is_owned flags and looks at the values in fields.
3150 /// Two objects with NULL inner values will be considered "equal" here.
3151 #[no_mangle]
3152 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3153         if a.inner == b.inner { return true; }
3154         if a.inner.is_null() || b.inner.is_null() { return false; }
3155         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3156 }
3157
3158 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3159 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3160
3161 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3162 /// interactive transaction construction.
3163 ///
3164 #[must_use]
3165 #[repr(C)]
3166 pub struct TxSignatures {
3167         /// A pointer to the opaque Rust object.
3168
3169         /// Nearly everywhere, inner must be non-null, however in places where
3170         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3171         pub inner: *mut nativeTxSignatures,
3172         /// Indicates that this is the only struct which contains the same pointer.
3173
3174         /// Rust functions which take ownership of an object provided via an argument require
3175         /// this to be true and invalidate the object pointed to by inner.
3176         pub is_owned: bool,
3177 }
3178
3179 impl Drop for TxSignatures {
3180         fn drop(&mut self) {
3181                 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3182                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3183                 }
3184         }
3185 }
3186 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3187 #[no_mangle]
3188 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3189 #[allow(unused)]
3190 /// Used only if an object of this type is returned as a trait impl by a method
3191 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3192         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3193 }
3194 #[allow(unused)]
3195 impl TxSignatures {
3196         pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3197                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3198         }
3199         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3200                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3201         }
3202         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3203         pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3204                 assert!(self.is_owned);
3205                 let ret = ObjOps::untweak_ptr(self.inner);
3206                 self.inner = core::ptr::null_mut();
3207                 ret
3208         }
3209 }
3210 /// The channel ID
3211 #[no_mangle]
3212 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] {
3213         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3214         &inner_val.0
3215 }
3216 /// The channel ID
3217 #[no_mangle]
3218 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3219         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3220 }
3221 /// The TXID
3222 #[no_mangle]
3223 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3224         let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3225         inner_val.as_inner()
3226 }
3227 /// The TXID
3228 #[no_mangle]
3229 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3230         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3231 }
3232 /// The list of witnesses
3233 ///
3234 /// Returns a copy of the field.
3235 #[no_mangle]
3236 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3237         let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
3238         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) }); };
3239         local_inner_val.into()
3240 }
3241 /// The list of witnesses
3242 #[no_mangle]
3243 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
3244         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
3245         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
3246 }
3247 /// Constructs a new TxSignatures given each field
3248 #[must_use]
3249 #[no_mangle]
3250 pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ) -> TxSignatures {
3251         let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
3252         TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
3253                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3254                 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
3255                 witnesses: local_witnesses_arg,
3256         }), is_owned: true }
3257 }
3258 impl Clone for TxSignatures {
3259         fn clone(&self) -> Self {
3260                 Self {
3261                         inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3262                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3263                         is_owned: true,
3264                 }
3265         }
3266 }
3267 #[allow(unused)]
3268 /// Used only if an object of this type is returned as a trait impl by a method
3269 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3270         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxSignatures)).clone() })) as *mut c_void
3271 }
3272 #[no_mangle]
3273 /// Creates a copy of the TxSignatures
3274 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
3275         orig.clone()
3276 }
3277 /// Checks if two TxSignaturess contain equal inner contents.
3278 /// This ignores pointers and is_owned flags and looks at the values in fields.
3279 /// Two objects with NULL inner values will be considered "equal" here.
3280 #[no_mangle]
3281 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
3282         if a.inner == b.inner { return true; }
3283         if a.inner.is_null() || b.inner.is_null() { return false; }
3284         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3285 }
3286
3287 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
3288 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
3289
3290 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
3291 /// completed.
3292 ///
3293 #[must_use]
3294 #[repr(C)]
3295 pub struct TxInitRbf {
3296         /// A pointer to the opaque Rust object.
3297
3298         /// Nearly everywhere, inner must be non-null, however in places where
3299         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3300         pub inner: *mut nativeTxInitRbf,
3301         /// Indicates that this is the only struct which contains the same pointer.
3302
3303         /// Rust functions which take ownership of an object provided via an argument require
3304         /// this to be true and invalidate the object pointed to by inner.
3305         pub is_owned: bool,
3306 }
3307
3308 impl Drop for TxInitRbf {
3309         fn drop(&mut self) {
3310                 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
3311                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3312                 }
3313         }
3314 }
3315 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
3316 #[no_mangle]
3317 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
3318 #[allow(unused)]
3319 /// Used only if an object of this type is returned as a trait impl by a method
3320 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
3321         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
3322 }
3323 #[allow(unused)]
3324 impl TxInitRbf {
3325         pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
3326                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3327         }
3328         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
3329                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3330         }
3331         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3332         pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
3333                 assert!(self.is_owned);
3334                 let ret = ObjOps::untweak_ptr(self.inner);
3335                 self.inner = core::ptr::null_mut();
3336                 ret
3337         }
3338 }
3339 /// The channel ID
3340 #[no_mangle]
3341 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] {
3342         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3343         &inner_val.0
3344 }
3345 /// The channel ID
3346 #[no_mangle]
3347 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3348         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3349 }
3350 /// The locktime of the transaction
3351 #[no_mangle]
3352 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
3353         let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
3354         *inner_val
3355 }
3356 /// The locktime of the transaction
3357 #[no_mangle]
3358 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
3359         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
3360 }
3361 /// The feerate of the transaction
3362 #[no_mangle]
3363 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
3364         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
3365         *inner_val
3366 }
3367 /// The feerate of the transaction
3368 #[no_mangle]
3369 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
3370         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
3371 }
3372 /// The number of satoshis the sender will contribute to or, if negative, remove from
3373 /// (e.g. splice-out) the funding output of the transaction
3374 #[no_mangle]
3375 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
3376         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3377         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() }) };
3378         local_inner_val
3379 }
3380 /// The number of satoshis the sender will contribute to or, if negative, remove from
3381 /// (e.g. splice-out) the funding output of the transaction
3382 #[no_mangle]
3383 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
3384         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3385         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3386 }
3387 /// Constructs a new TxInitRbf given each field
3388 #[must_use]
3389 #[no_mangle]
3390 pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf {
3391         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3392         TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
3393                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3394                 locktime: locktime_arg,
3395                 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
3396                 funding_output_contribution: local_funding_output_contribution_arg,
3397         }), is_owned: true }
3398 }
3399 impl Clone for TxInitRbf {
3400         fn clone(&self) -> Self {
3401                 Self {
3402                         inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3403                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3404                         is_owned: true,
3405                 }
3406         }
3407 }
3408 #[allow(unused)]
3409 /// Used only if an object of this type is returned as a trait impl by a method
3410 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3411         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxInitRbf)).clone() })) as *mut c_void
3412 }
3413 #[no_mangle]
3414 /// Creates a copy of the TxInitRbf
3415 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
3416         orig.clone()
3417 }
3418 /// Checks if two TxInitRbfs contain equal inner contents.
3419 /// This ignores pointers and is_owned flags and looks at the values in fields.
3420 /// Two objects with NULL inner values will be considered "equal" here.
3421 #[no_mangle]
3422 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
3423         if a.inner == b.inner { return true; }
3424         if a.inner.is_null() || b.inner.is_null() { return false; }
3425         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3426 }
3427
3428 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
3429 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
3430
3431 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
3432 /// completed.
3433 ///
3434 #[must_use]
3435 #[repr(C)]
3436 pub struct TxAckRbf {
3437         /// A pointer to the opaque Rust object.
3438
3439         /// Nearly everywhere, inner must be non-null, however in places where
3440         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3441         pub inner: *mut nativeTxAckRbf,
3442         /// Indicates that this is the only struct which contains the same pointer.
3443
3444         /// Rust functions which take ownership of an object provided via an argument require
3445         /// this to be true and invalidate the object pointed to by inner.
3446         pub is_owned: bool,
3447 }
3448
3449 impl Drop for TxAckRbf {
3450         fn drop(&mut self) {
3451                 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
3452                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3453                 }
3454         }
3455 }
3456 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
3457 #[no_mangle]
3458 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
3459 #[allow(unused)]
3460 /// Used only if an object of this type is returned as a trait impl by a method
3461 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
3462         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
3463 }
3464 #[allow(unused)]
3465 impl TxAckRbf {
3466         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
3467                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3468         }
3469         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
3470                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3471         }
3472         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3473         pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
3474                 assert!(self.is_owned);
3475                 let ret = ObjOps::untweak_ptr(self.inner);
3476                 self.inner = core::ptr::null_mut();
3477                 ret
3478         }
3479 }
3480 /// The channel ID
3481 #[no_mangle]
3482 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] {
3483         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3484         &inner_val.0
3485 }
3486 /// The channel ID
3487 #[no_mangle]
3488 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3489         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3490 }
3491 /// The number of satoshis the sender will contribute to or, if negative, remove from
3492 /// (e.g. splice-out) the funding output of the transaction
3493 #[no_mangle]
3494 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
3495         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3496         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() }) };
3497         local_inner_val
3498 }
3499 /// The number of satoshis the sender will contribute to or, if negative, remove from
3500 /// (e.g. splice-out) the funding output of the transaction
3501 #[no_mangle]
3502 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
3503         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3504         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3505 }
3506 /// Constructs a new TxAckRbf given each field
3507 #[must_use]
3508 #[no_mangle]
3509 pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf {
3510         let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3511         TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
3512                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3513                 funding_output_contribution: local_funding_output_contribution_arg,
3514         }), is_owned: true }
3515 }
3516 impl Clone for TxAckRbf {
3517         fn clone(&self) -> Self {
3518                 Self {
3519                         inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3520                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3521                         is_owned: true,
3522                 }
3523         }
3524 }
3525 #[allow(unused)]
3526 /// Used only if an object of this type is returned as a trait impl by a method
3527 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3528         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAckRbf)).clone() })) as *mut c_void
3529 }
3530 #[no_mangle]
3531 /// Creates a copy of the TxAckRbf
3532 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
3533         orig.clone()
3534 }
3535 /// Checks if two TxAckRbfs contain equal inner contents.
3536 /// This ignores pointers and is_owned flags and looks at the values in fields.
3537 /// Two objects with NULL inner values will be considered "equal" here.
3538 #[no_mangle]
3539 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
3540         if a.inner == b.inner { return true; }
3541         if a.inner.is_null() || b.inner.is_null() { return false; }
3542         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3543 }
3544
3545 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
3546 pub(crate) type nativeTxAbort = nativeTxAbortImport;
3547
3548 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
3549 ///
3550 #[must_use]
3551 #[repr(C)]
3552 pub struct TxAbort {
3553         /// A pointer to the opaque Rust object.
3554
3555         /// Nearly everywhere, inner must be non-null, however in places where
3556         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3557         pub inner: *mut nativeTxAbort,
3558         /// Indicates that this is the only struct which contains the same pointer.
3559
3560         /// Rust functions which take ownership of an object provided via an argument require
3561         /// this to be true and invalidate the object pointed to by inner.
3562         pub is_owned: bool,
3563 }
3564
3565 impl Drop for TxAbort {
3566         fn drop(&mut self) {
3567                 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
3568                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3569                 }
3570         }
3571 }
3572 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
3573 #[no_mangle]
3574 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
3575 #[allow(unused)]
3576 /// Used only if an object of this type is returned as a trait impl by a method
3577 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
3578         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
3579 }
3580 #[allow(unused)]
3581 impl TxAbort {
3582         pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
3583                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3584         }
3585         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
3586                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3587         }
3588         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3589         pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
3590                 assert!(self.is_owned);
3591                 let ret = ObjOps::untweak_ptr(self.inner);
3592                 self.inner = core::ptr::null_mut();
3593                 ret
3594         }
3595 }
3596 /// The channel ID
3597 #[no_mangle]
3598 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] {
3599         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3600         &inner_val.0
3601 }
3602 /// The channel ID
3603 #[no_mangle]
3604 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) {
3605         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3606 }
3607 /// Message data
3608 ///
3609 /// Returns a copy of the field.
3610 #[no_mangle]
3611 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
3612         let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
3613         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
3614         local_inner_val.into()
3615 }
3616 /// Message data
3617 #[no_mangle]
3618 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
3619         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3620         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
3621 }
3622 /// Constructs a new TxAbort given each field
3623 #[must_use]
3624 #[no_mangle]
3625 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
3626         let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
3627         TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
3628                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3629                 data: local_data_arg,
3630         }), is_owned: true }
3631 }
3632 impl Clone for TxAbort {
3633         fn clone(&self) -> Self {
3634                 Self {
3635                         inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
3636                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3637                         is_owned: true,
3638                 }
3639         }
3640 }
3641 #[allow(unused)]
3642 /// Used only if an object of this type is returned as a trait impl by a method
3643 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
3644         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAbort)).clone() })) as *mut c_void
3645 }
3646 #[no_mangle]
3647 /// Creates a copy of the TxAbort
3648 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
3649         orig.clone()
3650 }
3651 /// Checks if two TxAborts contain equal inner contents.
3652 /// This ignores pointers and is_owned flags and looks at the values in fields.
3653 /// Two objects with NULL inner values will be considered "equal" here.
3654 #[no_mangle]
3655 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
3656         if a.inner == b.inner { return true; }
3657         if a.inner.is_null() || b.inner.is_null() { return false; }
3658         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3659 }
3660
3661 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
3662 pub(crate) type nativeShutdown = nativeShutdownImport;
3663
3664 /// A [`shutdown`] message to be sent to or received from a peer.
3665 ///
3666 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
3667 #[must_use]
3668 #[repr(C)]
3669 pub struct Shutdown {
3670         /// A pointer to the opaque Rust object.
3671
3672         /// Nearly everywhere, inner must be non-null, however in places where
3673         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3674         pub inner: *mut nativeShutdown,
3675         /// Indicates that this is the only struct which contains the same pointer.
3676
3677         /// Rust functions which take ownership of an object provided via an argument require
3678         /// this to be true and invalidate the object pointed to by inner.
3679         pub is_owned: bool,
3680 }
3681
3682 impl Drop for Shutdown {
3683         fn drop(&mut self) {
3684                 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
3685                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3686                 }
3687         }
3688 }
3689 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
3690 #[no_mangle]
3691 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
3692 #[allow(unused)]
3693 /// Used only if an object of this type is returned as a trait impl by a method
3694 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
3695         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
3696 }
3697 #[allow(unused)]
3698 impl Shutdown {
3699         pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
3700                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3701         }
3702         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
3703                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3704         }
3705         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3706         pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
3707                 assert!(self.is_owned);
3708                 let ret = ObjOps::untweak_ptr(self.inner);
3709                 self.inner = core::ptr::null_mut();
3710                 ret
3711         }
3712 }
3713 /// The channel ID
3714 #[no_mangle]
3715 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
3716         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3717         &inner_val.0
3718 }
3719 /// The channel ID
3720 #[no_mangle]
3721 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
3722         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3723 }
3724 /// The destination of this peer's funds on closing.
3725 ///
3726 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3727 #[no_mangle]
3728 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
3729         let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
3730         crate::c_types::u8slice::from_slice(&inner_val[..])
3731 }
3732 /// The destination of this peer's funds on closing.
3733 ///
3734 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3735 #[no_mangle]
3736 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
3737         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
3738 }
3739 /// Constructs a new Shutdown given each field
3740 #[must_use]
3741 #[no_mangle]
3742 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
3743         Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
3744                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3745                 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
3746         }), is_owned: true }
3747 }
3748 impl Clone for Shutdown {
3749         fn clone(&self) -> Self {
3750                 Self {
3751                         inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
3752                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3753                         is_owned: true,
3754                 }
3755         }
3756 }
3757 #[allow(unused)]
3758 /// Used only if an object of this type is returned as a trait impl by a method
3759 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
3760         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
3761 }
3762 #[no_mangle]
3763 /// Creates a copy of the Shutdown
3764 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
3765         orig.clone()
3766 }
3767 /// Checks if two Shutdowns contain equal inner contents.
3768 /// This ignores pointers and is_owned flags and looks at the values in fields.
3769 /// Two objects with NULL inner values will be considered "equal" here.
3770 #[no_mangle]
3771 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
3772         if a.inner == b.inner { return true; }
3773         if a.inner.is_null() || b.inner.is_null() { return false; }
3774         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3775 }
3776
3777 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
3778 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
3779
3780 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
3781 ///
3782 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
3783 /// to use.
3784 #[must_use]
3785 #[repr(C)]
3786 pub struct ClosingSignedFeeRange {
3787         /// A pointer to the opaque Rust object.
3788
3789         /// Nearly everywhere, inner must be non-null, however in places where
3790         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3791         pub inner: *mut nativeClosingSignedFeeRange,
3792         /// Indicates that this is the only struct which contains the same pointer.
3793
3794         /// Rust functions which take ownership of an object provided via an argument require
3795         /// this to be true and invalidate the object pointed to by inner.
3796         pub is_owned: bool,
3797 }
3798
3799 impl Drop for ClosingSignedFeeRange {
3800         fn drop(&mut self) {
3801                 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
3802                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3803                 }
3804         }
3805 }
3806 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
3807 #[no_mangle]
3808 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
3809 #[allow(unused)]
3810 /// Used only if an object of this type is returned as a trait impl by a method
3811 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
3812         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
3813 }
3814 #[allow(unused)]
3815 impl ClosingSignedFeeRange {
3816         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
3817                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3818         }
3819         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
3820                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3821         }
3822         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3823         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
3824                 assert!(self.is_owned);
3825                 let ret = ObjOps::untweak_ptr(self.inner);
3826                 self.inner = core::ptr::null_mut();
3827                 ret
3828         }
3829 }
3830 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3831 /// transaction.
3832 #[no_mangle]
3833 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3834         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
3835         *inner_val
3836 }
3837 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3838 /// transaction.
3839 #[no_mangle]
3840 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3841         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
3842 }
3843 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3844 /// transaction.
3845 #[no_mangle]
3846 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3847         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
3848         *inner_val
3849 }
3850 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3851 /// transaction.
3852 #[no_mangle]
3853 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3854         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
3855 }
3856 /// Constructs a new ClosingSignedFeeRange given each field
3857 #[must_use]
3858 #[no_mangle]
3859 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
3860         ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
3861                 min_fee_satoshis: min_fee_satoshis_arg,
3862                 max_fee_satoshis: max_fee_satoshis_arg,
3863         }), is_owned: true }
3864 }
3865 impl Clone for ClosingSignedFeeRange {
3866         fn clone(&self) -> Self {
3867                 Self {
3868                         inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
3869                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3870                         is_owned: true,
3871                 }
3872         }
3873 }
3874 #[allow(unused)]
3875 /// Used only if an object of this type is returned as a trait impl by a method
3876 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3877         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
3878 }
3879 #[no_mangle]
3880 /// Creates a copy of the ClosingSignedFeeRange
3881 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
3882         orig.clone()
3883 }
3884 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
3885 /// This ignores pointers and is_owned flags and looks at the values in fields.
3886 /// Two objects with NULL inner values will be considered "equal" here.
3887 #[no_mangle]
3888 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
3889         if a.inner == b.inner { return true; }
3890         if a.inner.is_null() || b.inner.is_null() { return false; }
3891         if a.get_native_ref() == b.get_native_ref() { true } else { false }
3892 }
3893
3894 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
3895 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
3896
3897 /// A [`closing_signed`] message to be sent to or received from a peer.
3898 ///
3899 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
3900 #[must_use]
3901 #[repr(C)]
3902 pub struct ClosingSigned {
3903         /// A pointer to the opaque Rust object.
3904
3905         /// Nearly everywhere, inner must be non-null, however in places where
3906         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3907         pub inner: *mut nativeClosingSigned,
3908         /// Indicates that this is the only struct which contains the same pointer.
3909
3910         /// Rust functions which take ownership of an object provided via an argument require
3911         /// this to be true and invalidate the object pointed to by inner.
3912         pub is_owned: bool,
3913 }
3914
3915 impl Drop for ClosingSigned {
3916         fn drop(&mut self) {
3917                 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
3918                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3919                 }
3920         }
3921 }
3922 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
3923 #[no_mangle]
3924 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
3925 #[allow(unused)]
3926 /// Used only if an object of this type is returned as a trait impl by a method
3927 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
3928         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
3929 }
3930 #[allow(unused)]
3931 impl ClosingSigned {
3932         pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
3933                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3934         }
3935         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
3936                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3937         }
3938         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3939         pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
3940                 assert!(self.is_owned);
3941                 let ret = ObjOps::untweak_ptr(self.inner);
3942                 self.inner = core::ptr::null_mut();
3943                 ret
3944         }
3945 }
3946 /// The channel ID
3947 #[no_mangle]
3948 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
3949         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3950         &inner_val.0
3951 }
3952 /// The channel ID
3953 #[no_mangle]
3954 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
3955         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3956 }
3957 /// The proposed total fee for the closing transaction
3958 #[no_mangle]
3959 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
3960         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
3961         *inner_val
3962 }
3963 /// The proposed total fee for the closing transaction
3964 #[no_mangle]
3965 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
3966         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
3967 }
3968 /// A signature on the closing transaction
3969 #[no_mangle]
3970 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::ECDSASignature {
3971         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3972         crate::c_types::ECDSASignature::from_rust(&inner_val)
3973 }
3974 /// A signature on the closing transaction
3975 #[no_mangle]
3976 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ECDSASignature) {
3977         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3978 }
3979 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
3980 /// nodes.
3981 ///
3982 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
3983 #[no_mangle]
3984 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
3985         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
3986         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 };
3987         local_inner_val
3988 }
3989 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
3990 /// nodes.
3991 ///
3992 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
3993 #[no_mangle]
3994 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
3995         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
3996         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
3997 }
3998 /// Constructs a new ClosingSigned given each field
3999 ///
4000 /// Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4001 #[must_use]
4002 #[no_mangle]
4003 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::ECDSASignature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
4004         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()) } }) };
4005         ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
4006                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4007                 fee_satoshis: fee_satoshis_arg,
4008                 signature: signature_arg.into_rust(),
4009                 fee_range: local_fee_range_arg,
4010         }), is_owned: true }
4011 }
4012 impl Clone for ClosingSigned {
4013         fn clone(&self) -> Self {
4014                 Self {
4015                         inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4016                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4017                         is_owned: true,
4018                 }
4019         }
4020 }
4021 #[allow(unused)]
4022 /// Used only if an object of this type is returned as a trait impl by a method
4023 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4024         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
4025 }
4026 #[no_mangle]
4027 /// Creates a copy of the ClosingSigned
4028 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4029         orig.clone()
4030 }
4031 /// Checks if two ClosingSigneds contain equal inner contents.
4032 /// This ignores pointers and is_owned flags and looks at the values in fields.
4033 /// Two objects with NULL inner values will be considered "equal" here.
4034 #[no_mangle]
4035 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4036         if a.inner == b.inner { return true; }
4037         if a.inner.is_null() || b.inner.is_null() { return false; }
4038         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4039 }
4040
4041 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4042 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4043
4044 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4045 ///
4046 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4047 #[must_use]
4048 #[repr(C)]
4049 pub struct UpdateAddHTLC {
4050         /// A pointer to the opaque Rust object.
4051
4052         /// Nearly everywhere, inner must be non-null, however in places where
4053         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4054         pub inner: *mut nativeUpdateAddHTLC,
4055         /// Indicates that this is the only struct which contains the same pointer.
4056
4057         /// Rust functions which take ownership of an object provided via an argument require
4058         /// this to be true and invalidate the object pointed to by inner.
4059         pub is_owned: bool,
4060 }
4061
4062 impl Drop for UpdateAddHTLC {
4063         fn drop(&mut self) {
4064                 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4065                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4066                 }
4067         }
4068 }
4069 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4070 #[no_mangle]
4071 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4072 #[allow(unused)]
4073 /// Used only if an object of this type is returned as a trait impl by a method
4074 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4075         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4076 }
4077 #[allow(unused)]
4078 impl UpdateAddHTLC {
4079         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4080                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4081         }
4082         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4083                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4084         }
4085         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4086         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4087                 assert!(self.is_owned);
4088                 let ret = ObjOps::untweak_ptr(self.inner);
4089                 self.inner = core::ptr::null_mut();
4090                 ret
4091         }
4092 }
4093 /// The channel ID
4094 #[no_mangle]
4095 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4096         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4097         &inner_val.0
4098 }
4099 /// The channel ID
4100 #[no_mangle]
4101 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4102         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4103 }
4104 /// The HTLC ID
4105 #[no_mangle]
4106 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4107         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4108         *inner_val
4109 }
4110 /// The HTLC ID
4111 #[no_mangle]
4112 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4113         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4114 }
4115 /// The HTLC value in milli-satoshi
4116 #[no_mangle]
4117 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4118         let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4119         *inner_val
4120 }
4121 /// The HTLC value in milli-satoshi
4122 #[no_mangle]
4123 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4124         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4125 }
4126 /// The payment hash, the pre-image of which controls HTLC redemption
4127 #[no_mangle]
4128 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4129         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4130         &inner_val.0
4131 }
4132 /// The payment hash, the pre-image of which controls HTLC redemption
4133 #[no_mangle]
4134 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4135         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
4136 }
4137 /// The expiry height of the HTLC
4138 #[no_mangle]
4139 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4140         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4141         *inner_val
4142 }
4143 /// The expiry height of the HTLC
4144 #[no_mangle]
4145 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4146         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
4147 }
4148 /// The extra fee skimmed by the sender of this message. See
4149 /// [`ChannelConfig::accept_underpaying_htlcs`].
4150 ///
4151 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4152 #[no_mangle]
4153 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
4154         let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
4155         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() }) };
4156         local_inner_val
4157 }
4158 /// The extra fee skimmed by the sender of this message. See
4159 /// [`ChannelConfig::accept_underpaying_htlcs`].
4160 ///
4161 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4162 #[no_mangle]
4163 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
4164         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4165         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
4166 }
4167 impl Clone for UpdateAddHTLC {
4168         fn clone(&self) -> Self {
4169                 Self {
4170                         inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4171                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4172                         is_owned: true,
4173                 }
4174         }
4175 }
4176 #[allow(unused)]
4177 /// Used only if an object of this type is returned as a trait impl by a method
4178 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4179         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
4180 }
4181 #[no_mangle]
4182 /// Creates a copy of the UpdateAddHTLC
4183 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
4184         orig.clone()
4185 }
4186 /// Checks if two UpdateAddHTLCs contain equal inner contents.
4187 /// This ignores pointers and is_owned flags and looks at the values in fields.
4188 /// Two objects with NULL inner values will be considered "equal" here.
4189 #[no_mangle]
4190 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
4191         if a.inner == b.inner { return true; }
4192         if a.inner.is_null() || b.inner.is_null() { return false; }
4193         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4194 }
4195
4196 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
4197 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
4198
4199 /// An onion message to be sent to or received from a peer.
4200 ///
4201 #[must_use]
4202 #[repr(C)]
4203 pub struct OnionMessage {
4204         /// A pointer to the opaque Rust object.
4205
4206         /// Nearly everywhere, inner must be non-null, however in places where
4207         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4208         pub inner: *mut nativeOnionMessage,
4209         /// Indicates that this is the only struct which contains the same pointer.
4210
4211         /// Rust functions which take ownership of an object provided via an argument require
4212         /// this to be true and invalidate the object pointed to by inner.
4213         pub is_owned: bool,
4214 }
4215
4216 impl Drop for OnionMessage {
4217         fn drop(&mut self) {
4218                 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
4219                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4220                 }
4221         }
4222 }
4223 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
4224 #[no_mangle]
4225 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
4226 #[allow(unused)]
4227 /// Used only if an object of this type is returned as a trait impl by a method
4228 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
4229         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
4230 }
4231 #[allow(unused)]
4232 impl OnionMessage {
4233         pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
4234                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4235         }
4236         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
4237                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4238         }
4239         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4240         pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
4241                 assert!(self.is_owned);
4242                 let ret = ObjOps::untweak_ptr(self.inner);
4243                 self.inner = core::ptr::null_mut();
4244                 ret
4245         }
4246 }
4247 /// Used in decrypting the onion packet's payload.
4248 #[no_mangle]
4249 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
4250         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
4251         crate::c_types::PublicKey::from_rust(&inner_val)
4252 }
4253 /// Used in decrypting the onion packet's payload.
4254 #[no_mangle]
4255 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
4256         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
4257 }
4258 /// The full onion packet including hop data, pubkey, and hmac
4259 #[no_mangle]
4260 pub extern "C" fn OnionMessage_get_onion_routing_packet(this_ptr: &OnionMessage) -> crate::lightning::onion_message::packet::Packet {
4261         let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
4262         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 }
4263 }
4264 /// The full onion packet including hop data, pubkey, and hmac
4265 #[no_mangle]
4266 pub extern "C" fn OnionMessage_set_onion_routing_packet(this_ptr: &mut OnionMessage, mut val: crate::lightning::onion_message::packet::Packet) {
4267         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
4268 }
4269 /// Constructs a new OnionMessage given each field
4270 #[must_use]
4271 #[no_mangle]
4272 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 {
4273         OnionMessage { inner: ObjOps::heap_alloc(nativeOnionMessage {
4274                 blinding_point: blinding_point_arg.into_rust(),
4275                 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
4276         }), is_owned: true }
4277 }
4278 impl Clone for OnionMessage {
4279         fn clone(&self) -> Self {
4280                 Self {
4281                         inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
4282                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4283                         is_owned: true,
4284                 }
4285         }
4286 }
4287 #[allow(unused)]
4288 /// Used only if an object of this type is returned as a trait impl by a method
4289 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
4290         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessage)).clone() })) as *mut c_void
4291 }
4292 #[no_mangle]
4293 /// Creates a copy of the OnionMessage
4294 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
4295         orig.clone()
4296 }
4297 /// Checks if two OnionMessages contain equal inner contents.
4298 /// This ignores pointers and is_owned flags and looks at the values in fields.
4299 /// Two objects with NULL inner values will be considered "equal" here.
4300 #[no_mangle]
4301 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
4302         if a.inner == b.inner { return true; }
4303         if a.inner.is_null() || b.inner.is_null() { return false; }
4304         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4305 }
4306
4307 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
4308 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
4309
4310 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
4311 ///
4312 /// [`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
4313 #[must_use]
4314 #[repr(C)]
4315 pub struct UpdateFulfillHTLC {
4316         /// A pointer to the opaque Rust object.
4317
4318         /// Nearly everywhere, inner must be non-null, however in places where
4319         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4320         pub inner: *mut nativeUpdateFulfillHTLC,
4321         /// Indicates that this is the only struct which contains the same pointer.
4322
4323         /// Rust functions which take ownership of an object provided via an argument require
4324         /// this to be true and invalidate the object pointed to by inner.
4325         pub is_owned: bool,
4326 }
4327
4328 impl Drop for UpdateFulfillHTLC {
4329         fn drop(&mut self) {
4330                 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
4331                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4332                 }
4333         }
4334 }
4335 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
4336 #[no_mangle]
4337 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
4338 #[allow(unused)]
4339 /// Used only if an object of this type is returned as a trait impl by a method
4340 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
4341         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
4342 }
4343 #[allow(unused)]
4344 impl UpdateFulfillHTLC {
4345         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
4346                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4347         }
4348         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
4349                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4350         }
4351         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4352         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
4353                 assert!(self.is_owned);
4354                 let ret = ObjOps::untweak_ptr(self.inner);
4355                 self.inner = core::ptr::null_mut();
4356                 ret
4357         }
4358 }
4359 /// The channel ID
4360 #[no_mangle]
4361 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4362         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4363         &inner_val.0
4364 }
4365 /// The channel ID
4366 #[no_mangle]
4367 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4368         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4369 }
4370 /// The HTLC ID
4371 #[no_mangle]
4372 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
4373         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4374         *inner_val
4375 }
4376 /// The HTLC ID
4377 #[no_mangle]
4378 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
4379         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4380 }
4381 /// The pre-image of the payment hash, allowing HTLC redemption
4382 #[no_mangle]
4383 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4384         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
4385         &inner_val.0
4386 }
4387 /// The pre-image of the payment hash, allowing HTLC redemption
4388 #[no_mangle]
4389 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4390         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
4391 }
4392 /// Constructs a new UpdateFulfillHTLC given each field
4393 #[must_use]
4394 #[no_mangle]
4395 pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC {
4396         UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
4397                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4398                 htlc_id: htlc_id_arg,
4399                 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
4400         }), is_owned: true }
4401 }
4402 impl Clone for UpdateFulfillHTLC {
4403         fn clone(&self) -> Self {
4404                 Self {
4405                         inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4406                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4407                         is_owned: true,
4408                 }
4409         }
4410 }
4411 #[allow(unused)]
4412 /// Used only if an object of this type is returned as a trait impl by a method
4413 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4414         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
4415 }
4416 #[no_mangle]
4417 /// Creates a copy of the UpdateFulfillHTLC
4418 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
4419         orig.clone()
4420 }
4421 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
4422 /// This ignores pointers and is_owned flags and looks at the values in fields.
4423 /// Two objects with NULL inner values will be considered "equal" here.
4424 #[no_mangle]
4425 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
4426         if a.inner == b.inner { return true; }
4427         if a.inner.is_null() || b.inner.is_null() { return false; }
4428         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4429 }
4430
4431 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
4432 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
4433
4434 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
4435 ///
4436 /// [`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
4437 #[must_use]
4438 #[repr(C)]
4439 pub struct UpdateFailHTLC {
4440         /// A pointer to the opaque Rust object.
4441
4442         /// Nearly everywhere, inner must be non-null, however in places where
4443         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4444         pub inner: *mut nativeUpdateFailHTLC,
4445         /// Indicates that this is the only struct which contains the same pointer.
4446
4447         /// Rust functions which take ownership of an object provided via an argument require
4448         /// this to be true and invalidate the object pointed to by inner.
4449         pub is_owned: bool,
4450 }
4451
4452 impl Drop for UpdateFailHTLC {
4453         fn drop(&mut self) {
4454                 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
4455                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4456                 }
4457         }
4458 }
4459 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
4460 #[no_mangle]
4461 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
4462 #[allow(unused)]
4463 /// Used only if an object of this type is returned as a trait impl by a method
4464 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
4465         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
4466 }
4467 #[allow(unused)]
4468 impl UpdateFailHTLC {
4469         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
4470                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4471         }
4472         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
4473                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4474         }
4475         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4476         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
4477                 assert!(self.is_owned);
4478                 let ret = ObjOps::untweak_ptr(self.inner);
4479                 self.inner = core::ptr::null_mut();
4480                 ret
4481         }
4482 }
4483 /// The channel ID
4484 #[no_mangle]
4485 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
4486         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4487         &inner_val.0
4488 }
4489 /// The channel ID
4490 #[no_mangle]
4491 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4492         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4493 }
4494 /// The HTLC ID
4495 #[no_mangle]
4496 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
4497         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4498         *inner_val
4499 }
4500 /// The HTLC ID
4501 #[no_mangle]
4502 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
4503         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4504 }
4505 impl Clone for UpdateFailHTLC {
4506         fn clone(&self) -> Self {
4507                 Self {
4508                         inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4509                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4510                         is_owned: true,
4511                 }
4512         }
4513 }
4514 #[allow(unused)]
4515 /// Used only if an object of this type is returned as a trait impl by a method
4516 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4517         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
4518 }
4519 #[no_mangle]
4520 /// Creates a copy of the UpdateFailHTLC
4521 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
4522         orig.clone()
4523 }
4524 /// Checks if two UpdateFailHTLCs contain equal inner contents.
4525 /// This ignores pointers and is_owned flags and looks at the values in fields.
4526 /// Two objects with NULL inner values will be considered "equal" here.
4527 #[no_mangle]
4528 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
4529         if a.inner == b.inner { return true; }
4530         if a.inner.is_null() || b.inner.is_null() { return false; }
4531         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4532 }
4533
4534 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
4535 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
4536
4537 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
4538 ///
4539 /// [`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
4540 #[must_use]
4541 #[repr(C)]
4542 pub struct UpdateFailMalformedHTLC {
4543         /// A pointer to the opaque Rust object.
4544
4545         /// Nearly everywhere, inner must be non-null, however in places where
4546         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4547         pub inner: *mut nativeUpdateFailMalformedHTLC,
4548         /// Indicates that this is the only struct which contains the same pointer.
4549
4550         /// Rust functions which take ownership of an object provided via an argument require
4551         /// this to be true and invalidate the object pointed to by inner.
4552         pub is_owned: bool,
4553 }
4554
4555 impl Drop for UpdateFailMalformedHTLC {
4556         fn drop(&mut self) {
4557                 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
4558                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4559                 }
4560         }
4561 }
4562 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
4563 #[no_mangle]
4564 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
4565 #[allow(unused)]
4566 /// Used only if an object of this type is returned as a trait impl by a method
4567 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
4568         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
4569 }
4570 #[allow(unused)]
4571 impl UpdateFailMalformedHTLC {
4572         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
4573                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4574         }
4575         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
4576                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4577         }
4578         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4579         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
4580                 assert!(self.is_owned);
4581                 let ret = ObjOps::untweak_ptr(self.inner);
4582                 self.inner = core::ptr::null_mut();
4583                 ret
4584         }
4585 }
4586 /// The channel ID
4587 #[no_mangle]
4588 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
4589         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4590         &inner_val.0
4591 }
4592 /// The channel ID
4593 #[no_mangle]
4594 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4595         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4596 }
4597 /// The HTLC ID
4598 #[no_mangle]
4599 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
4600         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4601         *inner_val
4602 }
4603 /// The HTLC ID
4604 #[no_mangle]
4605 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
4606         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4607 }
4608 /// The failure code
4609 #[no_mangle]
4610 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
4611         let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
4612         *inner_val
4613 }
4614 /// The failure code
4615 #[no_mangle]
4616 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
4617         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
4618 }
4619 impl Clone for UpdateFailMalformedHTLC {
4620         fn clone(&self) -> Self {
4621                 Self {
4622                         inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4623                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4624                         is_owned: true,
4625                 }
4626         }
4627 }
4628 #[allow(unused)]
4629 /// Used only if an object of this type is returned as a trait impl by a method
4630 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4631         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
4632 }
4633 #[no_mangle]
4634 /// Creates a copy of the UpdateFailMalformedHTLC
4635 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
4636         orig.clone()
4637 }
4638 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
4639 /// This ignores pointers and is_owned flags and looks at the values in fields.
4640 /// Two objects with NULL inner values will be considered "equal" here.
4641 #[no_mangle]
4642 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
4643         if a.inner == b.inner { return true; }
4644         if a.inner.is_null() || b.inner.is_null() { return false; }
4645         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4646 }
4647
4648 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
4649 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
4650
4651 /// A [`commitment_signed`] message to be sent to or received from a peer.
4652 ///
4653 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
4654 #[must_use]
4655 #[repr(C)]
4656 pub struct CommitmentSigned {
4657         /// A pointer to the opaque Rust object.
4658
4659         /// Nearly everywhere, inner must be non-null, however in places where
4660         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4661         pub inner: *mut nativeCommitmentSigned,
4662         /// Indicates that this is the only struct which contains the same pointer.
4663
4664         /// Rust functions which take ownership of an object provided via an argument require
4665         /// this to be true and invalidate the object pointed to by inner.
4666         pub is_owned: bool,
4667 }
4668
4669 impl Drop for CommitmentSigned {
4670         fn drop(&mut self) {
4671                 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
4672                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4673                 }
4674         }
4675 }
4676 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
4677 #[no_mangle]
4678 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
4679 #[allow(unused)]
4680 /// Used only if an object of this type is returned as a trait impl by a method
4681 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
4682         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
4683 }
4684 #[allow(unused)]
4685 impl CommitmentSigned {
4686         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
4687                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4688         }
4689         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
4690                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4691         }
4692         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4693         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
4694                 assert!(self.is_owned);
4695                 let ret = ObjOps::untweak_ptr(self.inner);
4696                 self.inner = core::ptr::null_mut();
4697                 ret
4698         }
4699 }
4700 /// The channel ID
4701 #[no_mangle]
4702 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
4703         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4704         &inner_val.0
4705 }
4706 /// The channel ID
4707 #[no_mangle]
4708 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
4709         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4710 }
4711 /// A signature on the commitment transaction
4712 #[no_mangle]
4713 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::ECDSASignature {
4714         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4715         crate::c_types::ECDSASignature::from_rust(&inner_val)
4716 }
4717 /// A signature on the commitment transaction
4718 #[no_mangle]
4719 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ECDSASignature) {
4720         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4721 }
4722 /// Signatures on the HTLC transactions
4723 ///
4724 /// Returns a copy of the field.
4725 #[no_mangle]
4726 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_ECDSASignatureZ {
4727         let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
4728         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) }); };
4729         local_inner_val.into()
4730 }
4731 /// Signatures on the HTLC transactions
4732 #[no_mangle]
4733 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_ECDSASignatureZ) {
4734         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
4735         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
4736 }
4737 /// Constructs a new CommitmentSigned given each field
4738 #[must_use]
4739 #[no_mangle]
4740 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ) -> CommitmentSigned {
4741         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() }); };
4742         CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
4743                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4744                 signature: signature_arg.into_rust(),
4745                 htlc_signatures: local_htlc_signatures_arg,
4746         }), is_owned: true }
4747 }
4748 impl Clone for CommitmentSigned {
4749         fn clone(&self) -> Self {
4750                 Self {
4751                         inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4752                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4753                         is_owned: true,
4754                 }
4755         }
4756 }
4757 #[allow(unused)]
4758 /// Used only if an object of this type is returned as a trait impl by a method
4759 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4760         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
4761 }
4762 #[no_mangle]
4763 /// Creates a copy of the CommitmentSigned
4764 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
4765         orig.clone()
4766 }
4767 /// Checks if two CommitmentSigneds contain equal inner contents.
4768 /// This ignores pointers and is_owned flags and looks at the values in fields.
4769 /// Two objects with NULL inner values will be considered "equal" here.
4770 #[no_mangle]
4771 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
4772         if a.inner == b.inner { return true; }
4773         if a.inner.is_null() || b.inner.is_null() { return false; }
4774         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4775 }
4776
4777 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
4778 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
4779
4780 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
4781 ///
4782 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
4783 #[must_use]
4784 #[repr(C)]
4785 pub struct RevokeAndACK {
4786         /// A pointer to the opaque Rust object.
4787
4788         /// Nearly everywhere, inner must be non-null, however in places where
4789         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4790         pub inner: *mut nativeRevokeAndACK,
4791         /// Indicates that this is the only struct which contains the same pointer.
4792
4793         /// Rust functions which take ownership of an object provided via an argument require
4794         /// this to be true and invalidate the object pointed to by inner.
4795         pub is_owned: bool,
4796 }
4797
4798 impl Drop for RevokeAndACK {
4799         fn drop(&mut self) {
4800                 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
4801                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4802                 }
4803         }
4804 }
4805 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
4806 #[no_mangle]
4807 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
4808 #[allow(unused)]
4809 /// Used only if an object of this type is returned as a trait impl by a method
4810 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
4811         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
4812 }
4813 #[allow(unused)]
4814 impl RevokeAndACK {
4815         pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
4816                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4817         }
4818         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
4819                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4820         }
4821         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4822         pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
4823                 assert!(self.is_owned);
4824                 let ret = ObjOps::untweak_ptr(self.inner);
4825                 self.inner = core::ptr::null_mut();
4826                 ret
4827         }
4828 }
4829 /// The channel ID
4830 #[no_mangle]
4831 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4832         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4833         &inner_val.0
4834 }
4835 /// The channel ID
4836 #[no_mangle]
4837 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4838         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4839 }
4840 /// The secret corresponding to the per-commitment point
4841 #[no_mangle]
4842 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4843         let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
4844         inner_val
4845 }
4846 /// The secret corresponding to the per-commitment point
4847 #[no_mangle]
4848 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4849         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
4850 }
4851 /// The next sender-broadcast commitment transaction's per-commitment point
4852 #[no_mangle]
4853 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
4854         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
4855         crate::c_types::PublicKey::from_rust(&inner_val)
4856 }
4857 /// The next sender-broadcast commitment transaction's per-commitment point
4858 #[no_mangle]
4859 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
4860         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
4861 }
4862 /// Constructs a new RevokeAndACK given each field
4863 #[must_use]
4864 #[no_mangle]
4865 pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK {
4866         RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
4867                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4868                 per_commitment_secret: per_commitment_secret_arg.data,
4869                 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
4870         }), is_owned: true }
4871 }
4872 impl Clone for RevokeAndACK {
4873         fn clone(&self) -> Self {
4874                 Self {
4875                         inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
4876                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4877                         is_owned: true,
4878                 }
4879         }
4880 }
4881 #[allow(unused)]
4882 /// Used only if an object of this type is returned as a trait impl by a method
4883 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
4884         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
4885 }
4886 #[no_mangle]
4887 /// Creates a copy of the RevokeAndACK
4888 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
4889         orig.clone()
4890 }
4891 /// Checks if two RevokeAndACKs contain equal inner contents.
4892 /// This ignores pointers and is_owned flags and looks at the values in fields.
4893 /// Two objects with NULL inner values will be considered "equal" here.
4894 #[no_mangle]
4895 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
4896         if a.inner == b.inner { return true; }
4897         if a.inner.is_null() || b.inner.is_null() { return false; }
4898         if a.get_native_ref() == b.get_native_ref() { true } else { false }
4899 }
4900
4901 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
4902 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
4903
4904 /// An [`update_fee`] message to be sent to or received from a peer
4905 ///
4906 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
4907 #[must_use]
4908 #[repr(C)]
4909 pub struct UpdateFee {
4910         /// A pointer to the opaque Rust object.
4911
4912         /// Nearly everywhere, inner must be non-null, however in places where
4913         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4914         pub inner: *mut nativeUpdateFee,
4915         /// Indicates that this is the only struct which contains the same pointer.
4916
4917         /// Rust functions which take ownership of an object provided via an argument require
4918         /// this to be true and invalidate the object pointed to by inner.
4919         pub is_owned: bool,
4920 }
4921
4922 impl Drop for UpdateFee {
4923         fn drop(&mut self) {
4924                 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
4925                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4926                 }
4927         }
4928 }
4929 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
4930 #[no_mangle]
4931 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
4932 #[allow(unused)]
4933 /// Used only if an object of this type is returned as a trait impl by a method
4934 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
4935         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
4936 }
4937 #[allow(unused)]
4938 impl UpdateFee {
4939         pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
4940                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4941         }
4942         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
4943                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4944         }
4945         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4946         pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
4947                 assert!(self.is_owned);
4948                 let ret = ObjOps::untweak_ptr(self.inner);
4949                 self.inner = core::ptr::null_mut();
4950                 ret
4951         }
4952 }
4953 /// The channel ID
4954 #[no_mangle]
4955 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
4956         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4957         &inner_val.0
4958 }
4959 /// The channel ID
4960 #[no_mangle]
4961 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
4962         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4963 }
4964 /// Fee rate per 1000-weight of the transaction
4965 #[no_mangle]
4966 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
4967         let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
4968         *inner_val
4969 }
4970 /// Fee rate per 1000-weight of the transaction
4971 #[no_mangle]
4972 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
4973         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
4974 }
4975 /// Constructs a new UpdateFee given each field
4976 #[must_use]
4977 #[no_mangle]
4978 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
4979         UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
4980                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4981                 feerate_per_kw: feerate_per_kw_arg,
4982         }), is_owned: true }
4983 }
4984 impl Clone for UpdateFee {
4985         fn clone(&self) -> Self {
4986                 Self {
4987                         inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
4988                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4989                         is_owned: true,
4990                 }
4991         }
4992 }
4993 #[allow(unused)]
4994 /// Used only if an object of this type is returned as a trait impl by a method
4995 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
4996         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
4997 }
4998 #[no_mangle]
4999 /// Creates a copy of the UpdateFee
5000 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
5001         orig.clone()
5002 }
5003 /// Checks if two UpdateFees contain equal inner contents.
5004 /// This ignores pointers and is_owned flags and looks at the values in fields.
5005 /// Two objects with NULL inner values will be considered "equal" here.
5006 #[no_mangle]
5007 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
5008         if a.inner == b.inner { return true; }
5009         if a.inner.is_null() || b.inner.is_null() { return false; }
5010         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5011 }
5012
5013 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
5014 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
5015
5016 /// A [`channel_reestablish`] message to be sent to or received from a peer.
5017 ///
5018 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
5019 #[must_use]
5020 #[repr(C)]
5021 pub struct ChannelReestablish {
5022         /// A pointer to the opaque Rust object.
5023
5024         /// Nearly everywhere, inner must be non-null, however in places where
5025         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5026         pub inner: *mut nativeChannelReestablish,
5027         /// Indicates that this is the only struct which contains the same pointer.
5028
5029         /// Rust functions which take ownership of an object provided via an argument require
5030         /// this to be true and invalidate the object pointed to by inner.
5031         pub is_owned: bool,
5032 }
5033
5034 impl Drop for ChannelReestablish {
5035         fn drop(&mut self) {
5036                 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
5037                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5038                 }
5039         }
5040 }
5041 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
5042 #[no_mangle]
5043 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
5044 #[allow(unused)]
5045 /// Used only if an object of this type is returned as a trait impl by a method
5046 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
5047         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
5048 }
5049 #[allow(unused)]
5050 impl ChannelReestablish {
5051         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
5052                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5053         }
5054         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
5055                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5056         }
5057         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5058         pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
5059                 assert!(self.is_owned);
5060                 let ret = ObjOps::untweak_ptr(self.inner);
5061                 self.inner = core::ptr::null_mut();
5062                 ret
5063         }
5064 }
5065 /// The channel ID
5066 #[no_mangle]
5067 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5068         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5069         &inner_val.0
5070 }
5071 /// The channel ID
5072 #[no_mangle]
5073 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5074         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5075 }
5076 /// The next commitment number for the sender
5077 #[no_mangle]
5078 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5079         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
5080         *inner_val
5081 }
5082 /// The next commitment number for the sender
5083 #[no_mangle]
5084 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5085         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
5086 }
5087 /// The next commitment number for the recipient
5088 #[no_mangle]
5089 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5090         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
5091         *inner_val
5092 }
5093 /// The next commitment number for the recipient
5094 #[no_mangle]
5095 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5096         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
5097 }
5098 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5099 /// belonging to the recipient
5100 #[no_mangle]
5101 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5102         let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
5103         inner_val
5104 }
5105 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5106 /// belonging to the recipient
5107 #[no_mangle]
5108 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5109         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
5110 }
5111 /// The sender's per-commitment point for their current commitment transaction
5112 #[no_mangle]
5113 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
5114         let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
5115         crate::c_types::PublicKey::from_rust(&inner_val)
5116 }
5117 /// The sender's per-commitment point for their current commitment transaction
5118 #[no_mangle]
5119 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
5120         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
5121 }
5122 /// The next funding transaction ID
5123 #[no_mangle]
5124 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
5125         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
5126         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().into_inner() } }) };
5127         local_inner_val
5128 }
5129 /// The next funding transaction ID
5130 #[no_mangle]
5131 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
5132         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() }})} };
5133         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
5134 }
5135 /// Constructs a new ChannelReestablish given each field
5136 #[must_use]
5137 #[no_mangle]
5138 pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> ChannelReestablish {
5139         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() }})} };
5140         ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
5141                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5142                 next_local_commitment_number: next_local_commitment_number_arg,
5143                 next_remote_commitment_number: next_remote_commitment_number_arg,
5144                 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
5145                 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
5146                 next_funding_txid: local_next_funding_txid_arg,
5147         }), is_owned: true }
5148 }
5149 impl Clone for ChannelReestablish {
5150         fn clone(&self) -> Self {
5151                 Self {
5152                         inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
5153                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5154                         is_owned: true,
5155                 }
5156         }
5157 }
5158 #[allow(unused)]
5159 /// Used only if an object of this type is returned as a trait impl by a method
5160 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
5161         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
5162 }
5163 #[no_mangle]
5164 /// Creates a copy of the ChannelReestablish
5165 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
5166         orig.clone()
5167 }
5168 /// Checks if two ChannelReestablishs contain equal inner contents.
5169 /// This ignores pointers and is_owned flags and looks at the values in fields.
5170 /// Two objects with NULL inner values will be considered "equal" here.
5171 #[no_mangle]
5172 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
5173         if a.inner == b.inner { return true; }
5174         if a.inner.is_null() || b.inner.is_null() { return false; }
5175         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5176 }
5177
5178 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
5179 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
5180
5181 /// An [`announcement_signatures`] message to be sent to or received from a peer.
5182 ///
5183 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
5184 #[must_use]
5185 #[repr(C)]
5186 pub struct AnnouncementSignatures {
5187         /// A pointer to the opaque Rust object.
5188
5189         /// Nearly everywhere, inner must be non-null, however in places where
5190         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5191         pub inner: *mut nativeAnnouncementSignatures,
5192         /// Indicates that this is the only struct which contains the same pointer.
5193
5194         /// Rust functions which take ownership of an object provided via an argument require
5195         /// this to be true and invalidate the object pointed to by inner.
5196         pub is_owned: bool,
5197 }
5198
5199 impl Drop for AnnouncementSignatures {
5200         fn drop(&mut self) {
5201                 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
5202                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5203                 }
5204         }
5205 }
5206 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
5207 #[no_mangle]
5208 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
5209 #[allow(unused)]
5210 /// Used only if an object of this type is returned as a trait impl by a method
5211 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
5212         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
5213 }
5214 #[allow(unused)]
5215 impl AnnouncementSignatures {
5216         pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
5217                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5218         }
5219         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
5220                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5221         }
5222         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5223         pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
5224                 assert!(self.is_owned);
5225                 let ret = ObjOps::untweak_ptr(self.inner);
5226                 self.inner = core::ptr::null_mut();
5227                 ret
5228         }
5229 }
5230 /// The channel ID
5231 #[no_mangle]
5232 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
5233         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5234         &inner_val.0
5235 }
5236 /// The channel ID
5237 #[no_mangle]
5238 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
5239         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5240 }
5241 /// The short channel ID
5242 #[no_mangle]
5243 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
5244         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
5245         *inner_val
5246 }
5247 /// The short channel ID
5248 #[no_mangle]
5249 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
5250         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
5251 }
5252 /// A signature by the node key
5253 #[no_mangle]
5254 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
5255         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
5256         crate::c_types::ECDSASignature::from_rust(&inner_val)
5257 }
5258 /// A signature by the node key
5259 #[no_mangle]
5260 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
5261         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
5262 }
5263 /// A signature by the funding key
5264 #[no_mangle]
5265 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
5266         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
5267         crate::c_types::ECDSASignature::from_rust(&inner_val)
5268 }
5269 /// A signature by the funding key
5270 #[no_mangle]
5271 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
5272         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
5273 }
5274 /// Constructs a new AnnouncementSignatures given each field
5275 #[must_use]
5276 #[no_mangle]
5277 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_arg: crate::c_types::ECDSASignature) -> AnnouncementSignatures {
5278         AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
5279                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5280                 short_channel_id: short_channel_id_arg,
5281                 node_signature: node_signature_arg.into_rust(),
5282                 bitcoin_signature: bitcoin_signature_arg.into_rust(),
5283         }), is_owned: true }
5284 }
5285 impl Clone for AnnouncementSignatures {
5286         fn clone(&self) -> Self {
5287                 Self {
5288                         inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
5289                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5290                         is_owned: true,
5291                 }
5292         }
5293 }
5294 #[allow(unused)]
5295 /// Used only if an object of this type is returned as a trait impl by a method
5296 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
5297         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
5298 }
5299 #[no_mangle]
5300 /// Creates a copy of the AnnouncementSignatures
5301 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
5302         orig.clone()
5303 }
5304 /// Checks if two AnnouncementSignaturess contain equal inner contents.
5305 /// This ignores pointers and is_owned flags and looks at the values in fields.
5306 /// Two objects with NULL inner values will be considered "equal" here.
5307 #[no_mangle]
5308 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
5309         if a.inner == b.inner { return true; }
5310         if a.inner.is_null() || b.inner.is_null() { return false; }
5311         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5312 }
5313 /// An address which can be used to connect to a remote peer.
5314 #[derive(Clone)]
5315 #[must_use]
5316 #[repr(C)]
5317 pub enum SocketAddress {
5318         /// An IPv4 address and port on which the peer is listening.
5319         TcpIpV4 {
5320                 /// The 4-byte IPv4 address
5321                 addr: crate::c_types::FourBytes,
5322                 /// The port on which the node is listening
5323                 port: u16,
5324         },
5325         /// An IPv6 address and port on which the peer is listening.
5326         TcpIpV6 {
5327                 /// The 16-byte IPv6 address
5328                 addr: crate::c_types::SixteenBytes,
5329                 /// The port on which the node is listening
5330                 port: u16,
5331         },
5332         /// An old-style Tor onion address/port on which the peer is listening.
5333         ///
5334         /// This field is deprecated and the Tor network generally no longer supports V2 Onion
5335         /// addresses. Thus, the details are not parsed here.
5336         OnionV2(
5337                 crate::c_types::TwelveBytes),
5338         /// A new-style Tor onion address/port on which the peer is listening.
5339         ///
5340         /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
5341         /// wrap as base32 and append \".onion\".
5342         OnionV3 {
5343                 /// The ed25519 long-term public key of the peer
5344                 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
5345                 /// The checksum of the pubkey and version, as included in the onion address
5346                 checksum: u16,
5347                 /// The version byte, as defined by the Tor Onion v3 spec.
5348                 version: u8,
5349                 /// The port on which the node is listening
5350                 port: u16,
5351         },
5352         /// A hostname/port on which the peer is listening.
5353         Hostname {
5354                 /// The hostname on which the node is listening.
5355                 hostname: crate::lightning::util::ser::Hostname,
5356                 /// The port on which the node is listening.
5357                 port: u16,
5358         },
5359 }
5360 use lightning::ln::msgs::SocketAddress as SocketAddressImport;
5361 pub(crate) type nativeSocketAddress = SocketAddressImport;
5362
5363 impl SocketAddress {
5364         #[allow(unused)]
5365         pub(crate) fn to_native(&self) -> nativeSocketAddress {
5366                 match self {
5367                         SocketAddress::TcpIpV4 {ref addr, ref port, } => {
5368                                 let mut addr_nonref = Clone::clone(addr);
5369                                 let mut port_nonref = Clone::clone(port);
5370                                 nativeSocketAddress::TcpIpV4 {
5371                                         addr: addr_nonref.data,
5372                                         port: port_nonref,
5373                                 }
5374                         },
5375                         SocketAddress::TcpIpV6 {ref addr, ref port, } => {
5376                                 let mut addr_nonref = Clone::clone(addr);
5377                                 let mut port_nonref = Clone::clone(port);
5378                                 nativeSocketAddress::TcpIpV6 {
5379                                         addr: addr_nonref.data,
5380                                         port: port_nonref,
5381                                 }
5382                         },
5383                         SocketAddress::OnionV2 (ref a, ) => {
5384                                 let mut a_nonref = Clone::clone(a);
5385                                 nativeSocketAddress::OnionV2 (
5386                                         a_nonref.data,
5387                                 )
5388                         },
5389                         SocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5390                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5391                                 let mut checksum_nonref = Clone::clone(checksum);
5392                                 let mut version_nonref = Clone::clone(version);
5393                                 let mut port_nonref = Clone::clone(port);
5394                                 nativeSocketAddress::OnionV3 {
5395                                         ed25519_pubkey: ed25519_pubkey_nonref.data,
5396                                         checksum: checksum_nonref,
5397                                         version: version_nonref,
5398                                         port: port_nonref,
5399                                 }
5400                         },
5401                         SocketAddress::Hostname {ref hostname, ref port, } => {
5402                                 let mut hostname_nonref = Clone::clone(hostname);
5403                                 let mut port_nonref = Clone::clone(port);
5404                                 nativeSocketAddress::Hostname {
5405                                         hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
5406                                         port: port_nonref,
5407                                 }
5408                         },
5409                 }
5410         }
5411         #[allow(unused)]
5412         pub(crate) fn into_native(self) -> nativeSocketAddress {
5413                 match self {
5414                         SocketAddress::TcpIpV4 {mut addr, mut port, } => {
5415                                 nativeSocketAddress::TcpIpV4 {
5416                                         addr: addr.data,
5417                                         port: port,
5418                                 }
5419                         },
5420                         SocketAddress::TcpIpV6 {mut addr, mut port, } => {
5421                                 nativeSocketAddress::TcpIpV6 {
5422                                         addr: addr.data,
5423                                         port: port,
5424                                 }
5425                         },
5426                         SocketAddress::OnionV2 (mut a, ) => {
5427                                 nativeSocketAddress::OnionV2 (
5428                                         a.data,
5429                                 )
5430                         },
5431                         SocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5432                                 nativeSocketAddress::OnionV3 {
5433                                         ed25519_pubkey: ed25519_pubkey.data,
5434                                         checksum: checksum,
5435                                         version: version,
5436                                         port: port,
5437                                 }
5438                         },
5439                         SocketAddress::Hostname {mut hostname, mut port, } => {
5440                                 nativeSocketAddress::Hostname {
5441                                         hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
5442                                         port: port,
5443                                 }
5444                         },
5445                 }
5446         }
5447         #[allow(unused)]
5448         pub(crate) fn from_native(native: &nativeSocketAddress) -> Self {
5449                 match native {
5450                         nativeSocketAddress::TcpIpV4 {ref addr, ref port, } => {
5451                                 let mut addr_nonref = Clone::clone(addr);
5452                                 let mut port_nonref = Clone::clone(port);
5453                                 SocketAddress::TcpIpV4 {
5454                                         addr: crate::c_types::FourBytes { data: addr_nonref },
5455                                         port: port_nonref,
5456                                 }
5457                         },
5458                         nativeSocketAddress::TcpIpV6 {ref addr, ref port, } => {
5459                                 let mut addr_nonref = Clone::clone(addr);
5460                                 let mut port_nonref = Clone::clone(port);
5461                                 SocketAddress::TcpIpV6 {
5462                                         addr: crate::c_types::SixteenBytes { data: addr_nonref },
5463                                         port: port_nonref,
5464                                 }
5465                         },
5466                         nativeSocketAddress::OnionV2 (ref a, ) => {
5467                                 let mut a_nonref = Clone::clone(a);
5468                                 SocketAddress::OnionV2 (
5469                                         crate::c_types::TwelveBytes { data: a_nonref },
5470                                 )
5471                         },
5472                         nativeSocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5473                                 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5474                                 let mut checksum_nonref = Clone::clone(checksum);
5475                                 let mut version_nonref = Clone::clone(version);
5476                                 let mut port_nonref = Clone::clone(port);
5477                                 SocketAddress::OnionV3 {
5478                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
5479                                         checksum: checksum_nonref,
5480                                         version: version_nonref,
5481                                         port: port_nonref,
5482                                 }
5483                         },
5484                         nativeSocketAddress::Hostname {ref hostname, ref port, } => {
5485                                 let mut hostname_nonref = Clone::clone(hostname);
5486                                 let mut port_nonref = Clone::clone(port);
5487                                 SocketAddress::Hostname {
5488                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
5489                                         port: port_nonref,
5490                                 }
5491                         },
5492                 }
5493         }
5494         #[allow(unused)]
5495         pub(crate) fn native_into(native: nativeSocketAddress) -> Self {
5496                 match native {
5497                         nativeSocketAddress::TcpIpV4 {mut addr, mut port, } => {
5498                                 SocketAddress::TcpIpV4 {
5499                                         addr: crate::c_types::FourBytes { data: addr },
5500                                         port: port,
5501                                 }
5502                         },
5503                         nativeSocketAddress::TcpIpV6 {mut addr, mut port, } => {
5504                                 SocketAddress::TcpIpV6 {
5505                                         addr: crate::c_types::SixteenBytes { data: addr },
5506                                         port: port,
5507                                 }
5508                         },
5509                         nativeSocketAddress::OnionV2 (mut a, ) => {
5510                                 SocketAddress::OnionV2 (
5511                                         crate::c_types::TwelveBytes { data: a },
5512                                 )
5513                         },
5514                         nativeSocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5515                                 SocketAddress::OnionV3 {
5516                                         ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
5517                                         checksum: checksum,
5518                                         version: version,
5519                                         port: port,
5520                                 }
5521                         },
5522                         nativeSocketAddress::Hostname {mut hostname, mut port, } => {
5523                                 SocketAddress::Hostname {
5524                                         hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
5525                                         port: port,
5526                                 }
5527                         },
5528                 }
5529         }
5530 }
5531 /// Frees any resources used by the SocketAddress
5532 #[no_mangle]
5533 pub extern "C" fn SocketAddress_free(this_ptr: SocketAddress) { }
5534 /// Creates a copy of the SocketAddress
5535 #[no_mangle]
5536 pub extern "C" fn SocketAddress_clone(orig: &SocketAddress) -> SocketAddress {
5537         orig.clone()
5538 }
5539 #[no_mangle]
5540 /// Utility method to constructs a new TcpIpV4-variant SocketAddress
5541 pub extern "C" fn SocketAddress_tcp_ip_v4(addr: crate::c_types::FourBytes, port: u16) -> SocketAddress {
5542         SocketAddress::TcpIpV4 {
5543                 addr,
5544                 port,
5545         }
5546 }
5547 #[no_mangle]
5548 /// Utility method to constructs a new TcpIpV6-variant SocketAddress
5549 pub extern "C" fn SocketAddress_tcp_ip_v6(addr: crate::c_types::SixteenBytes, port: u16) -> SocketAddress {
5550         SocketAddress::TcpIpV6 {
5551                 addr,
5552                 port,
5553         }
5554 }
5555 #[no_mangle]
5556 /// Utility method to constructs a new OnionV2-variant SocketAddress
5557 pub extern "C" fn SocketAddress_onion_v2(a: crate::c_types::TwelveBytes) -> SocketAddress {
5558         SocketAddress::OnionV2(a, )
5559 }
5560 #[no_mangle]
5561 /// Utility method to constructs a new OnionV3-variant SocketAddress
5562 pub extern "C" fn SocketAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> SocketAddress {
5563         SocketAddress::OnionV3 {
5564                 ed25519_pubkey,
5565                 checksum,
5566                 version,
5567                 port,
5568         }
5569 }
5570 #[no_mangle]
5571 /// Utility method to constructs a new Hostname-variant SocketAddress
5572 pub extern "C" fn SocketAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> SocketAddress {
5573         SocketAddress::Hostname {
5574                 hostname,
5575                 port,
5576         }
5577 }
5578 /// Checks if two SocketAddresss contain equal inner contents.
5579 /// This ignores pointers and is_owned flags and looks at the values in fields.
5580 #[no_mangle]
5581 pub extern "C" fn SocketAddress_eq(a: &SocketAddress, b: &SocketAddress) -> bool {
5582         if &a.to_native() == &b.to_native() { true } else { false }
5583 }
5584 #[no_mangle]
5585 /// Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read
5586 pub extern "C" fn SocketAddress_write(obj: &crate::lightning::ln::msgs::SocketAddress) -> crate::c_types::derived::CVec_u8Z {
5587         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5588 }
5589 #[no_mangle]
5590 /// Read a SocketAddress from a byte array, created by SocketAddress_write
5591 pub extern "C" fn SocketAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SocketAddressDecodeErrorZ {
5592         let res: Result<lightning::ln::msgs::SocketAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5593         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() };
5594         local_res
5595 }
5596 /// [`SocketAddress`] error variants
5597 #[derive(Clone)]
5598 #[must_use]
5599 #[repr(C)]
5600 pub enum SocketAddressParseError {
5601         /// Socket address (IPv4/IPv6) parsing error
5602         SocketAddrParse,
5603         /// Invalid input format
5604         InvalidInput,
5605         /// Invalid port
5606         InvalidPort,
5607         /// Invalid onion v3 address
5608         InvalidOnionV3,
5609 }
5610 use lightning::ln::msgs::SocketAddressParseError as SocketAddressParseErrorImport;
5611 pub(crate) type nativeSocketAddressParseError = SocketAddressParseErrorImport;
5612
5613 impl SocketAddressParseError {
5614         #[allow(unused)]
5615         pub(crate) fn to_native(&self) -> nativeSocketAddressParseError {
5616                 match self {
5617                         SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
5618                         SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
5619                         SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
5620                         SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
5621                 }
5622         }
5623         #[allow(unused)]
5624         pub(crate) fn into_native(self) -> nativeSocketAddressParseError {
5625                 match self {
5626                         SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
5627                         SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
5628                         SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
5629                         SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
5630                 }
5631         }
5632         #[allow(unused)]
5633         pub(crate) fn from_native(native: &nativeSocketAddressParseError) -> Self {
5634                 match native {
5635                         nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
5636                         nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
5637                         nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
5638                         nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
5639                 }
5640         }
5641         #[allow(unused)]
5642         pub(crate) fn native_into(native: nativeSocketAddressParseError) -> Self {
5643                 match native {
5644                         nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
5645                         nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
5646                         nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
5647                         nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
5648                 }
5649         }
5650 }
5651 /// Creates a copy of the SocketAddressParseError
5652 #[no_mangle]
5653 pub extern "C" fn SocketAddressParseError_clone(orig: &SocketAddressParseError) -> SocketAddressParseError {
5654         orig.clone()
5655 }
5656 #[no_mangle]
5657 /// Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError
5658 pub extern "C" fn SocketAddressParseError_socket_addr_parse() -> SocketAddressParseError {
5659         SocketAddressParseError::SocketAddrParse}
5660 #[no_mangle]
5661 /// Utility method to constructs a new InvalidInput-variant SocketAddressParseError
5662 pub extern "C" fn SocketAddressParseError_invalid_input() -> SocketAddressParseError {
5663         SocketAddressParseError::InvalidInput}
5664 #[no_mangle]
5665 /// Utility method to constructs a new InvalidPort-variant SocketAddressParseError
5666 pub extern "C" fn SocketAddressParseError_invalid_port() -> SocketAddressParseError {
5667         SocketAddressParseError::InvalidPort}
5668 #[no_mangle]
5669 /// Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError
5670 pub extern "C" fn SocketAddressParseError_invalid_onion_v3() -> SocketAddressParseError {
5671         SocketAddressParseError::InvalidOnionV3}
5672 /// Checks if two SocketAddressParseErrors contain equal inner contents.
5673 /// This ignores pointers and is_owned flags and looks at the values in fields.
5674 #[no_mangle]
5675 pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool {
5676         if &a.to_native() == &b.to_native() { true } else { false }
5677 }
5678 /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
5679 ///
5680 /// The host part must end with \".onion\".
5681 #[no_mangle]
5682 pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
5683         let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
5684         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() };
5685         local_ret
5686 }
5687
5688 #[no_mangle]
5689 /// Read a SocketAddress object from a string
5690 pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
5691         match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
5692                 Ok(r) => {
5693                         crate::c_types::CResultTempl::ok(
5694                                 crate::lightning::ln::msgs::SocketAddress::native_into(r)
5695                         )
5696                 },
5697                 Err(e) => {
5698                         crate::c_types::CResultTempl::err(
5699                                 crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
5700                         )
5701                 },
5702         }.into()
5703 }
5704 /// Represents the set of gossip messages that require a signature from a node's identity key.
5705 #[derive(Clone)]
5706 #[must_use]
5707 #[repr(C)]
5708 pub enum UnsignedGossipMessage {
5709         /// An unsigned channel announcement.
5710         ChannelAnnouncement(
5711                 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
5712         /// An unsigned channel update.
5713         ChannelUpdate(
5714                 crate::lightning::ln::msgs::UnsignedChannelUpdate),
5715         /// An unsigned node announcement.
5716         NodeAnnouncement(
5717                 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
5718 }
5719 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
5720 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
5721
5722 impl UnsignedGossipMessage {
5723         #[allow(unused)]
5724         pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
5725                 match self {
5726                         UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5727                                 let mut a_nonref = Clone::clone(a);
5728                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
5729                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
5730                                 )
5731                         },
5732                         UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5733                                 let mut a_nonref = Clone::clone(a);
5734                                 nativeUnsignedGossipMessage::ChannelUpdate (
5735                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
5736                                 )
5737                         },
5738                         UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5739                                 let mut a_nonref = Clone::clone(a);
5740                                 nativeUnsignedGossipMessage::NodeAnnouncement (
5741                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
5742                                 )
5743                         },
5744                 }
5745         }
5746         #[allow(unused)]
5747         pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
5748                 match self {
5749                         UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5750                                 nativeUnsignedGossipMessage::ChannelAnnouncement (
5751                                         *unsafe { Box::from_raw(a.take_inner()) },
5752                                 )
5753                         },
5754                         UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5755                                 nativeUnsignedGossipMessage::ChannelUpdate (
5756                                         *unsafe { Box::from_raw(a.take_inner()) },
5757                                 )
5758                         },
5759                         UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5760                                 nativeUnsignedGossipMessage::NodeAnnouncement (
5761                                         *unsafe { Box::from_raw(a.take_inner()) },
5762                                 )
5763                         },
5764                 }
5765         }
5766         #[allow(unused)]
5767         pub(crate) fn from_native(native: &nativeUnsignedGossipMessage) -> Self {
5768                 match native {
5769                         nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5770                                 let mut a_nonref = Clone::clone(a);
5771                                 UnsignedGossipMessage::ChannelAnnouncement (
5772                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5773                                 )
5774                         },
5775                         nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5776                                 let mut a_nonref = Clone::clone(a);
5777                                 UnsignedGossipMessage::ChannelUpdate (
5778                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5779                                 )
5780                         },
5781                         nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5782                                 let mut a_nonref = Clone::clone(a);
5783                                 UnsignedGossipMessage::NodeAnnouncement (
5784                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5785                                 )
5786                         },
5787                 }
5788         }
5789         #[allow(unused)]
5790         pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
5791                 match native {
5792                         nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5793                                 UnsignedGossipMessage::ChannelAnnouncement (
5794                                         crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5795                                 )
5796                         },
5797                         nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5798                                 UnsignedGossipMessage::ChannelUpdate (
5799                                         crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
5800                                 )
5801                         },
5802                         nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5803                                 UnsignedGossipMessage::NodeAnnouncement (
5804                                         crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5805                                 )
5806                         },
5807                 }
5808         }
5809 }
5810 /// Frees any resources used by the UnsignedGossipMessage
5811 #[no_mangle]
5812 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
5813 /// Creates a copy of the UnsignedGossipMessage
5814 #[no_mangle]
5815 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
5816         orig.clone()
5817 }
5818 #[no_mangle]
5819 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
5820 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
5821         UnsignedGossipMessage::ChannelAnnouncement(a, )
5822 }
5823 #[no_mangle]
5824 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
5825 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
5826         UnsignedGossipMessage::ChannelUpdate(a, )
5827 }
5828 #[no_mangle]
5829 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
5830 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
5831         UnsignedGossipMessage::NodeAnnouncement(a, )
5832 }
5833 #[no_mangle]
5834 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
5835 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
5836         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5837 }
5838
5839 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
5840 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
5841
5842 /// The unsigned part of a [`node_announcement`] message.
5843 ///
5844 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
5845 #[must_use]
5846 #[repr(C)]
5847 pub struct UnsignedNodeAnnouncement {
5848         /// A pointer to the opaque Rust object.
5849
5850         /// Nearly everywhere, inner must be non-null, however in places where
5851         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5852         pub inner: *mut nativeUnsignedNodeAnnouncement,
5853         /// Indicates that this is the only struct which contains the same pointer.
5854
5855         /// Rust functions which take ownership of an object provided via an argument require
5856         /// this to be true and invalidate the object pointed to by inner.
5857         pub is_owned: bool,
5858 }
5859
5860 impl Drop for UnsignedNodeAnnouncement {
5861         fn drop(&mut self) {
5862                 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
5863                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5864                 }
5865         }
5866 }
5867 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
5868 #[no_mangle]
5869 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
5870 #[allow(unused)]
5871 /// Used only if an object of this type is returned as a trait impl by a method
5872 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
5873         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
5874 }
5875 #[allow(unused)]
5876 impl UnsignedNodeAnnouncement {
5877         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
5878                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5879         }
5880         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
5881                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5882         }
5883         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5884         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
5885                 assert!(self.is_owned);
5886                 let ret = ObjOps::untweak_ptr(self.inner);
5887                 self.inner = core::ptr::null_mut();
5888                 ret
5889         }
5890 }
5891 /// The advertised features
5892 #[no_mangle]
5893 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
5894         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
5895         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 }
5896 }
5897 /// The advertised features
5898 #[no_mangle]
5899 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
5900         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
5901 }
5902 /// A strictly monotonic announcement counter, with gaps allowed
5903 #[no_mangle]
5904 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
5905         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
5906         *inner_val
5907 }
5908 /// A strictly monotonic announcement counter, with gaps allowed
5909 #[no_mangle]
5910 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
5911         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
5912 }
5913 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5914 /// to this node).
5915 #[no_mangle]
5916 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
5917         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
5918         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 }
5919 }
5920 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5921 /// to this node).
5922 #[no_mangle]
5923 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
5924         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
5925 }
5926 /// An RGB color for UI purposes
5927 #[no_mangle]
5928 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
5929         let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
5930         inner_val
5931 }
5932 /// An RGB color for UI purposes
5933 #[no_mangle]
5934 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
5935         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
5936 }
5937 /// An alias, for UI purposes.
5938 ///
5939 /// This should be sanitized before use. There is no guarantee of uniqueness.
5940 #[no_mangle]
5941 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
5942         let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
5943         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 }
5944 }
5945 /// An alias, for UI purposes.
5946 ///
5947 /// This should be sanitized before use. There is no guarantee of uniqueness.
5948 #[no_mangle]
5949 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
5950         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
5951 }
5952 /// List of addresses on which this node is reachable
5953 ///
5954 /// Returns a copy of the field.
5955 #[no_mangle]
5956 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
5957         let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
5958         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) }); };
5959         local_inner_val.into()
5960 }
5961 /// List of addresses on which this node is reachable
5962 #[no_mangle]
5963 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
5964         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
5965         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
5966 }
5967 impl Clone for UnsignedNodeAnnouncement {
5968         fn clone(&self) -> Self {
5969                 Self {
5970                         inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
5971                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5972                         is_owned: true,
5973                 }
5974         }
5975 }
5976 #[allow(unused)]
5977 /// Used only if an object of this type is returned as a trait impl by a method
5978 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
5979         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
5980 }
5981 #[no_mangle]
5982 /// Creates a copy of the UnsignedNodeAnnouncement
5983 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
5984         orig.clone()
5985 }
5986 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
5987 /// This ignores pointers and is_owned flags and looks at the values in fields.
5988 /// Two objects with NULL inner values will be considered "equal" here.
5989 #[no_mangle]
5990 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
5991         if a.inner == b.inner { return true; }
5992         if a.inner.is_null() || b.inner.is_null() { return false; }
5993         if a.get_native_ref() == b.get_native_ref() { true } else { false }
5994 }
5995
5996 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
5997 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
5998
5999 /// A [`node_announcement`] message to be sent to or received from a peer.
6000 ///
6001 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
6002 #[must_use]
6003 #[repr(C)]
6004 pub struct NodeAnnouncement {
6005         /// A pointer to the opaque Rust object.
6006
6007         /// Nearly everywhere, inner must be non-null, however in places where
6008         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6009         pub inner: *mut nativeNodeAnnouncement,
6010         /// Indicates that this is the only struct which contains the same pointer.
6011
6012         /// Rust functions which take ownership of an object provided via an argument require
6013         /// this to be true and invalidate the object pointed to by inner.
6014         pub is_owned: bool,
6015 }
6016
6017 impl Drop for NodeAnnouncement {
6018         fn drop(&mut self) {
6019                 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
6020                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6021                 }
6022         }
6023 }
6024 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
6025 #[no_mangle]
6026 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
6027 #[allow(unused)]
6028 /// Used only if an object of this type is returned as a trait impl by a method
6029 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
6030         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
6031 }
6032 #[allow(unused)]
6033 impl NodeAnnouncement {
6034         pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
6035                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6036         }
6037         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
6038                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6039         }
6040         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6041         pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
6042                 assert!(self.is_owned);
6043                 let ret = ObjOps::untweak_ptr(self.inner);
6044                 self.inner = core::ptr::null_mut();
6045                 ret
6046         }
6047 }
6048 /// The signature by the node key
6049 #[no_mangle]
6050 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
6051         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
6052         crate::c_types::ECDSASignature::from_rust(&inner_val)
6053 }
6054 /// The signature by the node key
6055 #[no_mangle]
6056 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
6057         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
6058 }
6059 /// The actual content of the announcement
6060 #[no_mangle]
6061 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
6062         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6063         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 }
6064 }
6065 /// The actual content of the announcement
6066 #[no_mangle]
6067 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
6068         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6069 }
6070 /// Constructs a new NodeAnnouncement given each field
6071 #[must_use]
6072 #[no_mangle]
6073 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
6074         NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
6075                 signature: signature_arg.into_rust(),
6076                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6077         }), is_owned: true }
6078 }
6079 impl Clone for NodeAnnouncement {
6080         fn clone(&self) -> Self {
6081                 Self {
6082                         inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6083                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6084                         is_owned: true,
6085                 }
6086         }
6087 }
6088 #[allow(unused)]
6089 /// Used only if an object of this type is returned as a trait impl by a method
6090 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6091         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
6092 }
6093 #[no_mangle]
6094 /// Creates a copy of the NodeAnnouncement
6095 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
6096         orig.clone()
6097 }
6098 /// Checks if two NodeAnnouncements contain equal inner contents.
6099 /// This ignores pointers and is_owned flags and looks at the values in fields.
6100 /// Two objects with NULL inner values will be considered "equal" here.
6101 #[no_mangle]
6102 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
6103         if a.inner == b.inner { return true; }
6104         if a.inner.is_null() || b.inner.is_null() { return false; }
6105         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6106 }
6107
6108 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
6109 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
6110
6111 /// The unsigned part of a [`channel_announcement`] message.
6112 ///
6113 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
6114 #[must_use]
6115 #[repr(C)]
6116 pub struct UnsignedChannelAnnouncement {
6117         /// A pointer to the opaque Rust object.
6118
6119         /// Nearly everywhere, inner must be non-null, however in places where
6120         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6121         pub inner: *mut nativeUnsignedChannelAnnouncement,
6122         /// Indicates that this is the only struct which contains the same pointer.
6123
6124         /// Rust functions which take ownership of an object provided via an argument require
6125         /// this to be true and invalidate the object pointed to by inner.
6126         pub is_owned: bool,
6127 }
6128
6129 impl Drop for UnsignedChannelAnnouncement {
6130         fn drop(&mut self) {
6131                 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
6132                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6133                 }
6134         }
6135 }
6136 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
6137 #[no_mangle]
6138 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
6139 #[allow(unused)]
6140 /// Used only if an object of this type is returned as a trait impl by a method
6141 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6142         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
6143 }
6144 #[allow(unused)]
6145 impl UnsignedChannelAnnouncement {
6146         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
6147                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6148         }
6149         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
6150                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6151         }
6152         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6153         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
6154                 assert!(self.is_owned);
6155                 let ret = ObjOps::untweak_ptr(self.inner);
6156                 self.inner = core::ptr::null_mut();
6157                 ret
6158         }
6159 }
6160 /// The advertised channel features
6161 #[no_mangle]
6162 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
6163         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6164         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 }
6165 }
6166 /// The advertised channel features
6167 #[no_mangle]
6168 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
6169         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
6170 }
6171 /// The genesis hash of the blockchain where the channel is to be opened
6172 #[no_mangle]
6173 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
6174         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6175         inner_val.as_inner()
6176 }
6177 /// The genesis hash of the blockchain where the channel is to be opened
6178 #[no_mangle]
6179 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
6180         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6181 }
6182 /// The short channel ID
6183 #[no_mangle]
6184 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
6185         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6186         *inner_val
6187 }
6188 /// The short channel ID
6189 #[no_mangle]
6190 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
6191         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6192 }
6193 /// One of the two `node_id`s which are endpoints of this channel
6194 #[no_mangle]
6195 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6196         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
6197         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 }
6198 }
6199 /// One of the two `node_id`s which are endpoints of this channel
6200 #[no_mangle]
6201 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6202         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
6203 }
6204 /// The other of the two `node_id`s which are endpoints of this channel
6205 #[no_mangle]
6206 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6207         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
6208         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 }
6209 }
6210 /// The other of the two `node_id`s which are endpoints of this channel
6211 #[no_mangle]
6212 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6213         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
6214 }
6215 /// The funding key for the first node
6216 #[no_mangle]
6217 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6218         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
6219         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 }
6220 }
6221 /// The funding key for the first node
6222 #[no_mangle]
6223 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6224         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
6225 }
6226 /// The funding key for the second node
6227 #[no_mangle]
6228 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6229         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
6230         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 }
6231 }
6232 /// The funding key for the second node
6233 #[no_mangle]
6234 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6235         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
6236 }
6237 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6238 /// to decode.
6239 ///
6240 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6241 ///
6242 /// Returns a copy of the field.
6243 #[no_mangle]
6244 pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6245         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6246         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6247         local_inner_val.into()
6248 }
6249 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6250 /// to decode.
6251 ///
6252 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6253 #[no_mangle]
6254 pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6255         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6256         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6257 }
6258 /// Constructs a new UnsignedChannelAnnouncement given each field
6259 #[must_use]
6260 #[no_mangle]
6261 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 {
6262         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6263         UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
6264                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
6265                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6266                 short_channel_id: short_channel_id_arg,
6267                 node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
6268                 node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
6269                 bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
6270                 bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
6271                 excess_data: local_excess_data_arg,
6272         }), is_owned: true }
6273 }
6274 impl Clone for UnsignedChannelAnnouncement {
6275         fn clone(&self) -> Self {
6276                 Self {
6277                         inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6278                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6279                         is_owned: true,
6280                 }
6281         }
6282 }
6283 #[allow(unused)]
6284 /// Used only if an object of this type is returned as a trait impl by a method
6285 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6286         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
6287 }
6288 #[no_mangle]
6289 /// Creates a copy of the UnsignedChannelAnnouncement
6290 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
6291         orig.clone()
6292 }
6293 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
6294 /// This ignores pointers and is_owned flags and looks at the values in fields.
6295 /// Two objects with NULL inner values will be considered "equal" here.
6296 #[no_mangle]
6297 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
6298         if a.inner == b.inner { return true; }
6299         if a.inner.is_null() || b.inner.is_null() { return false; }
6300         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6301 }
6302
6303 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
6304 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
6305
6306 /// A [`channel_announcement`] message to be sent to or received from a peer.
6307 ///
6308 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
6309 #[must_use]
6310 #[repr(C)]
6311 pub struct ChannelAnnouncement {
6312         /// A pointer to the opaque Rust object.
6313
6314         /// Nearly everywhere, inner must be non-null, however in places where
6315         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6316         pub inner: *mut nativeChannelAnnouncement,
6317         /// Indicates that this is the only struct which contains the same pointer.
6318
6319         /// Rust functions which take ownership of an object provided via an argument require
6320         /// this to be true and invalidate the object pointed to by inner.
6321         pub is_owned: bool,
6322 }
6323
6324 impl Drop for ChannelAnnouncement {
6325         fn drop(&mut self) {
6326                 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
6327                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6328                 }
6329         }
6330 }
6331 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
6332 #[no_mangle]
6333 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
6334 #[allow(unused)]
6335 /// Used only if an object of this type is returned as a trait impl by a method
6336 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6337         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
6338 }
6339 #[allow(unused)]
6340 impl ChannelAnnouncement {
6341         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
6342                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6343         }
6344         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
6345                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6346         }
6347         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6348         pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
6349                 assert!(self.is_owned);
6350                 let ret = ObjOps::untweak_ptr(self.inner);
6351                 self.inner = core::ptr::null_mut();
6352                 ret
6353         }
6354 }
6355 /// Authentication of the announcement by the first public node
6356 #[no_mangle]
6357 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6358         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
6359         crate::c_types::ECDSASignature::from_rust(&inner_val)
6360 }
6361 /// Authentication of the announcement by the first public node
6362 #[no_mangle]
6363 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6364         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
6365 }
6366 /// Authentication of the announcement by the second public node
6367 #[no_mangle]
6368 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6369         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
6370         crate::c_types::ECDSASignature::from_rust(&inner_val)
6371 }
6372 /// Authentication of the announcement by the second public node
6373 #[no_mangle]
6374 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6375         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
6376 }
6377 /// Proof of funding UTXO ownership by the first public node
6378 #[no_mangle]
6379 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6380         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
6381         crate::c_types::ECDSASignature::from_rust(&inner_val)
6382 }
6383 /// Proof of funding UTXO ownership by the first public node
6384 #[no_mangle]
6385 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6386         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
6387 }
6388 /// Proof of funding UTXO ownership by the second public node
6389 #[no_mangle]
6390 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6391         let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
6392         crate::c_types::ECDSASignature::from_rust(&inner_val)
6393 }
6394 /// Proof of funding UTXO ownership by the second public node
6395 #[no_mangle]
6396 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6397         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
6398 }
6399 /// The actual announcement
6400 #[no_mangle]
6401 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
6402         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6403         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 }
6404 }
6405 /// The actual announcement
6406 #[no_mangle]
6407 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
6408         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6409 }
6410 /// Constructs a new ChannelAnnouncement given each field
6411 #[must_use]
6412 #[no_mangle]
6413 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 {
6414         ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
6415                 node_signature_1: node_signature_1_arg.into_rust(),
6416                 node_signature_2: node_signature_2_arg.into_rust(),
6417                 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
6418                 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
6419                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6420         }), is_owned: true }
6421 }
6422 impl Clone for ChannelAnnouncement {
6423         fn clone(&self) -> Self {
6424                 Self {
6425                         inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6426                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6427                         is_owned: true,
6428                 }
6429         }
6430 }
6431 #[allow(unused)]
6432 /// Used only if an object of this type is returned as a trait impl by a method
6433 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6434         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
6435 }
6436 #[no_mangle]
6437 /// Creates a copy of the ChannelAnnouncement
6438 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
6439         orig.clone()
6440 }
6441 /// Checks if two ChannelAnnouncements contain equal inner contents.
6442 /// This ignores pointers and is_owned flags and looks at the values in fields.
6443 /// Two objects with NULL inner values will be considered "equal" here.
6444 #[no_mangle]
6445 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
6446         if a.inner == b.inner { return true; }
6447         if a.inner.is_null() || b.inner.is_null() { return false; }
6448         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6449 }
6450
6451 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
6452 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
6453
6454 /// The unsigned part of a [`channel_update`] message.
6455 ///
6456 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6457 #[must_use]
6458 #[repr(C)]
6459 pub struct UnsignedChannelUpdate {
6460         /// A pointer to the opaque Rust object.
6461
6462         /// Nearly everywhere, inner must be non-null, however in places where
6463         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6464         pub inner: *mut nativeUnsignedChannelUpdate,
6465         /// Indicates that this is the only struct which contains the same pointer.
6466
6467         /// Rust functions which take ownership of an object provided via an argument require
6468         /// this to be true and invalidate the object pointed to by inner.
6469         pub is_owned: bool,
6470 }
6471
6472 impl Drop for UnsignedChannelUpdate {
6473         fn drop(&mut self) {
6474                 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
6475                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6476                 }
6477         }
6478 }
6479 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
6480 #[no_mangle]
6481 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
6482 #[allow(unused)]
6483 /// Used only if an object of this type is returned as a trait impl by a method
6484 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
6485         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
6486 }
6487 #[allow(unused)]
6488 impl UnsignedChannelUpdate {
6489         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
6490                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6491         }
6492         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
6493                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6494         }
6495         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6496         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
6497                 assert!(self.is_owned);
6498                 let ret = ObjOps::untweak_ptr(self.inner);
6499                 self.inner = core::ptr::null_mut();
6500                 ret
6501         }
6502 }
6503 /// The genesis hash of the blockchain where the channel is to be opened
6504 #[no_mangle]
6505 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
6506         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6507         inner_val.as_inner()
6508 }
6509 /// The genesis hash of the blockchain where the channel is to be opened
6510 #[no_mangle]
6511 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
6512         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6513 }
6514 /// The short channel ID
6515 #[no_mangle]
6516 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
6517         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6518         *inner_val
6519 }
6520 /// The short channel ID
6521 #[no_mangle]
6522 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6523         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6524 }
6525 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6526 #[no_mangle]
6527 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
6528         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
6529         *inner_val
6530 }
6531 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6532 #[no_mangle]
6533 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6534         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
6535 }
6536 /// Channel flags
6537 #[no_mangle]
6538 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
6539         let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
6540         *inner_val
6541 }
6542 /// Channel flags
6543 #[no_mangle]
6544 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
6545         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
6546 }
6547 /// The number of blocks such that if:
6548 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6549 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6550 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6551 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6552 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6553 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6554 /// constructing the route.
6555 #[no_mangle]
6556 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
6557         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
6558         *inner_val
6559 }
6560 /// The number of blocks such that if:
6561 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6562 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6563 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6564 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6565 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6566 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6567 /// constructing the route.
6568 #[no_mangle]
6569 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
6570         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
6571 }
6572 /// The minimum HTLC size incoming to sender, in milli-satoshi
6573 #[no_mangle]
6574 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6575         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
6576         *inner_val
6577 }
6578 /// The minimum HTLC size incoming to sender, in milli-satoshi
6579 #[no_mangle]
6580 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6581         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
6582 }
6583 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6584 ///
6585 /// This used to be optional.
6586 #[no_mangle]
6587 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6588         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
6589         *inner_val
6590 }
6591 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6592 ///
6593 /// This used to be optional.
6594 #[no_mangle]
6595 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6596         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
6597 }
6598 /// The base HTLC fee charged by sender, in milli-satoshi
6599 #[no_mangle]
6600 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
6601         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
6602         *inner_val
6603 }
6604 /// The base HTLC fee charged by sender, in milli-satoshi
6605 #[no_mangle]
6606 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6607         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
6608 }
6609 /// The amount to fee multiplier, in micro-satoshi
6610 #[no_mangle]
6611 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
6612         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
6613         *inner_val
6614 }
6615 /// The amount to fee multiplier, in micro-satoshi
6616 #[no_mangle]
6617 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6618         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
6619 }
6620 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6621 /// to decode.
6622 ///
6623 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6624 ///
6625 /// Returns a copy of the field.
6626 #[no_mangle]
6627 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6628         let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6629         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6630         local_inner_val.into()
6631 }
6632 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6633 /// to decode.
6634 ///
6635 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6636 #[no_mangle]
6637 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
6638         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6639         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6640 }
6641 /// Constructs a new UnsignedChannelUpdate given each field
6642 #[must_use]
6643 #[no_mangle]
6644 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 {
6645         let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6646         UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
6647                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6648                 short_channel_id: short_channel_id_arg,
6649                 timestamp: timestamp_arg,
6650                 flags: flags_arg,
6651                 cltv_expiry_delta: cltv_expiry_delta_arg,
6652                 htlc_minimum_msat: htlc_minimum_msat_arg,
6653                 htlc_maximum_msat: htlc_maximum_msat_arg,
6654                 fee_base_msat: fee_base_msat_arg,
6655                 fee_proportional_millionths: fee_proportional_millionths_arg,
6656                 excess_data: local_excess_data_arg,
6657         }), is_owned: true }
6658 }
6659 impl Clone for UnsignedChannelUpdate {
6660         fn clone(&self) -> Self {
6661                 Self {
6662                         inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6663                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6664                         is_owned: true,
6665                 }
6666         }
6667 }
6668 #[allow(unused)]
6669 /// Used only if an object of this type is returned as a trait impl by a method
6670 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6671         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
6672 }
6673 #[no_mangle]
6674 /// Creates a copy of the UnsignedChannelUpdate
6675 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
6676         orig.clone()
6677 }
6678 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
6679 /// This ignores pointers and is_owned flags and looks at the values in fields.
6680 /// Two objects with NULL inner values will be considered "equal" here.
6681 #[no_mangle]
6682 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
6683         if a.inner == b.inner { return true; }
6684         if a.inner.is_null() || b.inner.is_null() { return false; }
6685         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6686 }
6687
6688 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
6689 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
6690
6691 /// A [`channel_update`] message to be sent to or received from a peer.
6692 ///
6693 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6694 #[must_use]
6695 #[repr(C)]
6696 pub struct ChannelUpdate {
6697         /// A pointer to the opaque Rust object.
6698
6699         /// Nearly everywhere, inner must be non-null, however in places where
6700         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6701         pub inner: *mut nativeChannelUpdate,
6702         /// Indicates that this is the only struct which contains the same pointer.
6703
6704         /// Rust functions which take ownership of an object provided via an argument require
6705         /// this to be true and invalidate the object pointed to by inner.
6706         pub is_owned: bool,
6707 }
6708
6709 impl Drop for ChannelUpdate {
6710         fn drop(&mut self) {
6711                 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
6712                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6713                 }
6714         }
6715 }
6716 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
6717 #[no_mangle]
6718 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
6719 #[allow(unused)]
6720 /// Used only if an object of this type is returned as a trait impl by a method
6721 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
6722         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
6723 }
6724 #[allow(unused)]
6725 impl ChannelUpdate {
6726         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
6727                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6728         }
6729         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
6730                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6731         }
6732         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6733         pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
6734                 assert!(self.is_owned);
6735                 let ret = ObjOps::untweak_ptr(self.inner);
6736                 self.inner = core::ptr::null_mut();
6737                 ret
6738         }
6739 }
6740 /// A signature of the channel update
6741 #[no_mangle]
6742 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
6743         let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
6744         crate::c_types::ECDSASignature::from_rust(&inner_val)
6745 }
6746 /// A signature of the channel update
6747 #[no_mangle]
6748 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
6749         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
6750 }
6751 /// The actual channel update
6752 #[no_mangle]
6753 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
6754         let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6755         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 }
6756 }
6757 /// The actual channel update
6758 #[no_mangle]
6759 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
6760         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6761 }
6762 /// Constructs a new ChannelUpdate given each field
6763 #[must_use]
6764 #[no_mangle]
6765 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
6766         ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
6767                 signature: signature_arg.into_rust(),
6768                 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6769         }), is_owned: true }
6770 }
6771 impl Clone for ChannelUpdate {
6772         fn clone(&self) -> Self {
6773                 Self {
6774                         inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6775                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6776                         is_owned: true,
6777                 }
6778         }
6779 }
6780 #[allow(unused)]
6781 /// Used only if an object of this type is returned as a trait impl by a method
6782 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6783         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
6784 }
6785 #[no_mangle]
6786 /// Creates a copy of the ChannelUpdate
6787 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
6788         orig.clone()
6789 }
6790 /// Checks if two ChannelUpdates contain equal inner contents.
6791 /// This ignores pointers and is_owned flags and looks at the values in fields.
6792 /// Two objects with NULL inner values will be considered "equal" here.
6793 #[no_mangle]
6794 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
6795         if a.inner == b.inner { return true; }
6796         if a.inner.is_null() || b.inner.is_null() { return false; }
6797         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6798 }
6799
6800 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
6801 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
6802
6803 /// A [`query_channel_range`] message is used to query a peer for channel
6804 /// UTXOs in a range of blocks. The recipient of a query makes a best
6805 /// effort to reply to the query using one or more [`ReplyChannelRange`]
6806 /// messages.
6807 ///
6808 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6809 #[must_use]
6810 #[repr(C)]
6811 pub struct QueryChannelRange {
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 nativeQueryChannelRange,
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 QueryChannelRange {
6825         fn drop(&mut self) {
6826                 if self.is_owned && !<*mut nativeQueryChannelRange>::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 QueryChannelRange, if is_owned is set and inner is non-NULL.
6832 #[no_mangle]
6833 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
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 QueryChannelRange_free_void(this_ptr: *mut c_void) {
6837         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
6838 }
6839 #[allow(unused)]
6840 impl QueryChannelRange {
6841         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
6842                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6843         }
6844         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
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 nativeQueryChannelRange {
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 genesis hash of the blockchain being queried
6856 #[no_mangle]
6857 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
6858         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6859         inner_val.as_inner()
6860 }
6861 /// The genesis hash of the blockchain being queried
6862 #[no_mangle]
6863 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
6864         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6865 }
6866 /// The height of the first block for the channel UTXOs being queried
6867 #[no_mangle]
6868 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
6869         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
6870         *inner_val
6871 }
6872 /// The height of the first block for the channel UTXOs being queried
6873 #[no_mangle]
6874 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
6875         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
6876 }
6877 /// The number of blocks to include in the query results
6878 #[no_mangle]
6879 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
6880         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
6881         *inner_val
6882 }
6883 /// The number of blocks to include in the query results
6884 #[no_mangle]
6885 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
6886         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
6887 }
6888 /// Constructs a new QueryChannelRange given each field
6889 #[must_use]
6890 #[no_mangle]
6891 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 {
6892         QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
6893                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6894                 first_blocknum: first_blocknum_arg,
6895                 number_of_blocks: number_of_blocks_arg,
6896         }), is_owned: true }
6897 }
6898 impl Clone for QueryChannelRange {
6899         fn clone(&self) -> Self {
6900                 Self {
6901                         inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
6902                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6903                         is_owned: true,
6904                 }
6905         }
6906 }
6907 #[allow(unused)]
6908 /// Used only if an object of this type is returned as a trait impl by a method
6909 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
6910         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
6911 }
6912 #[no_mangle]
6913 /// Creates a copy of the QueryChannelRange
6914 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
6915         orig.clone()
6916 }
6917 /// Checks if two QueryChannelRanges contain equal inner contents.
6918 /// This ignores pointers and is_owned flags and looks at the values in fields.
6919 /// Two objects with NULL inner values will be considered "equal" here.
6920 #[no_mangle]
6921 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
6922         if a.inner == b.inner { return true; }
6923         if a.inner.is_null() || b.inner.is_null() { return false; }
6924         if a.get_native_ref() == b.get_native_ref() { true } else { false }
6925 }
6926
6927 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
6928 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
6929
6930 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
6931 /// message.
6932 ///
6933 /// Multiple `reply_channel_range` messages can be sent in reply
6934 /// to a single [`QueryChannelRange`] message. The query recipient makes a
6935 /// best effort to respond based on their local network view which may
6936 /// not be a perfect view of the network. The `short_channel_id`s in the
6937 /// reply are encoded. We only support `encoding_type=0` uncompressed
6938 /// serialization and do not support `encoding_type=1` zlib serialization.
6939 ///
6940 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6941 #[must_use]
6942 #[repr(C)]
6943 pub struct ReplyChannelRange {
6944         /// A pointer to the opaque Rust object.
6945
6946         /// Nearly everywhere, inner must be non-null, however in places where
6947         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6948         pub inner: *mut nativeReplyChannelRange,
6949         /// Indicates that this is the only struct which contains the same pointer.
6950
6951         /// Rust functions which take ownership of an object provided via an argument require
6952         /// this to be true and invalidate the object pointed to by inner.
6953         pub is_owned: bool,
6954 }
6955
6956 impl Drop for ReplyChannelRange {
6957         fn drop(&mut self) {
6958                 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
6959                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6960                 }
6961         }
6962 }
6963 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
6964 #[no_mangle]
6965 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
6966 #[allow(unused)]
6967 /// Used only if an object of this type is returned as a trait impl by a method
6968 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
6969         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
6970 }
6971 #[allow(unused)]
6972 impl ReplyChannelRange {
6973         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
6974                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6975         }
6976         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
6977                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6978         }
6979         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6980         pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
6981                 assert!(self.is_owned);
6982                 let ret = ObjOps::untweak_ptr(self.inner);
6983                 self.inner = core::ptr::null_mut();
6984                 ret
6985         }
6986 }
6987 /// The genesis hash of the blockchain being queried
6988 #[no_mangle]
6989 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
6990         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6991         inner_val.as_inner()
6992 }
6993 /// The genesis hash of the blockchain being queried
6994 #[no_mangle]
6995 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
6996         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6997 }
6998 /// The height of the first block in the range of the reply
6999 #[no_mangle]
7000 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
7001         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
7002         *inner_val
7003 }
7004 /// The height of the first block in the range of the reply
7005 #[no_mangle]
7006 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
7007         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
7008 }
7009 /// The number of blocks included in the range of the reply
7010 #[no_mangle]
7011 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
7012         let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
7013         *inner_val
7014 }
7015 /// The number of blocks included in the range of the reply
7016 #[no_mangle]
7017 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
7018         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
7019 }
7020 /// True when this is the final reply for a query
7021 #[no_mangle]
7022 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
7023         let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
7024         *inner_val
7025 }
7026 /// True when this is the final reply for a query
7027 #[no_mangle]
7028 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
7029         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
7030 }
7031 /// The `short_channel_id`s in the channel range
7032 ///
7033 /// Returns a copy of the field.
7034 #[no_mangle]
7035 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
7036         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
7037         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7038         local_inner_val.into()
7039 }
7040 /// The `short_channel_id`s in the channel range
7041 #[no_mangle]
7042 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
7043         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7044         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
7045 }
7046 /// Constructs a new ReplyChannelRange given each field
7047 #[must_use]
7048 #[no_mangle]
7049 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 {
7050         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 }); };
7051         ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
7052                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7053                 first_blocknum: first_blocknum_arg,
7054                 number_of_blocks: number_of_blocks_arg,
7055                 sync_complete: sync_complete_arg,
7056                 short_channel_ids: local_short_channel_ids_arg,
7057         }), is_owned: true }
7058 }
7059 impl Clone for ReplyChannelRange {
7060         fn clone(&self) -> Self {
7061                 Self {
7062                         inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
7063                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7064                         is_owned: true,
7065                 }
7066         }
7067 }
7068 #[allow(unused)]
7069 /// Used only if an object of this type is returned as a trait impl by a method
7070 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
7071         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
7072 }
7073 #[no_mangle]
7074 /// Creates a copy of the ReplyChannelRange
7075 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
7076         orig.clone()
7077 }
7078 /// Checks if two ReplyChannelRanges contain equal inner contents.
7079 /// This ignores pointers and is_owned flags and looks at the values in fields.
7080 /// Two objects with NULL inner values will be considered "equal" here.
7081 #[no_mangle]
7082 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
7083         if a.inner == b.inner { return true; }
7084         if a.inner.is_null() || b.inner.is_null() { return false; }
7085         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7086 }
7087
7088 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
7089 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
7090
7091 /// A [`query_short_channel_ids`] message is used to query a peer for
7092 /// routing gossip messages related to one or more `short_channel_id`s.
7093 ///
7094 /// The query recipient will reply with the latest, if available,
7095 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
7096 /// it maintains for the requested `short_channel_id`s followed by a
7097 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
7098 /// this query are encoded. We only support `encoding_type=0` uncompressed
7099 /// serialization and do not support `encoding_type=1` zlib serialization.
7100 ///
7101 /// [`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
7102 #[must_use]
7103 #[repr(C)]
7104 pub struct QueryShortChannelIds {
7105         /// A pointer to the opaque Rust object.
7106
7107         /// Nearly everywhere, inner must be non-null, however in places where
7108         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7109         pub inner: *mut nativeQueryShortChannelIds,
7110         /// Indicates that this is the only struct which contains the same pointer.
7111
7112         /// Rust functions which take ownership of an object provided via an argument require
7113         /// this to be true and invalidate the object pointed to by inner.
7114         pub is_owned: bool,
7115 }
7116
7117 impl Drop for QueryShortChannelIds {
7118         fn drop(&mut self) {
7119                 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
7120                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7121                 }
7122         }
7123 }
7124 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
7125 #[no_mangle]
7126 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
7127 #[allow(unused)]
7128 /// Used only if an object of this type is returned as a trait impl by a method
7129 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
7130         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
7131 }
7132 #[allow(unused)]
7133 impl QueryShortChannelIds {
7134         pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
7135                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7136         }
7137         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
7138                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7139         }
7140         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7141         pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
7142                 assert!(self.is_owned);
7143                 let ret = ObjOps::untweak_ptr(self.inner);
7144                 self.inner = core::ptr::null_mut();
7145                 ret
7146         }
7147 }
7148 /// The genesis hash of the blockchain being queried
7149 #[no_mangle]
7150 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
7151         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7152         inner_val.as_inner()
7153 }
7154 /// The genesis hash of the blockchain being queried
7155 #[no_mangle]
7156 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
7157         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
7158 }
7159 /// The short_channel_ids that are being queried
7160 ///
7161 /// Returns a copy of the field.
7162 #[no_mangle]
7163 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
7164         let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
7165         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7166         local_inner_val.into()
7167 }
7168 /// The short_channel_ids that are being queried
7169 #[no_mangle]
7170 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
7171         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7172         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
7173 }
7174 /// Constructs a new QueryShortChannelIds given each field
7175 #[must_use]
7176 #[no_mangle]
7177 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 {
7178         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 }); };
7179         QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
7180                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7181                 short_channel_ids: local_short_channel_ids_arg,
7182         }), is_owned: true }
7183 }
7184 impl Clone for QueryShortChannelIds {
7185         fn clone(&self) -> Self {
7186                 Self {
7187                         inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
7188                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7189                         is_owned: true,
7190                 }
7191         }
7192 }
7193 #[allow(unused)]
7194 /// Used only if an object of this type is returned as a trait impl by a method
7195 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
7196         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
7197 }
7198 #[no_mangle]
7199 /// Creates a copy of the QueryShortChannelIds
7200 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
7201         orig.clone()
7202 }
7203 /// Checks if two QueryShortChannelIdss contain equal inner contents.
7204 /// This ignores pointers and is_owned flags and looks at the values in fields.
7205 /// Two objects with NULL inner values will be considered "equal" here.
7206 #[no_mangle]
7207 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
7208         if a.inner == b.inner { return true; }
7209         if a.inner.is_null() || b.inner.is_null() { return false; }
7210         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7211 }
7212
7213 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
7214 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
7215
7216 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
7217 /// message. The query recipient makes a best
7218 /// effort to respond based on their local network view which may not be
7219 /// a perfect view of the network.
7220 ///
7221 /// [`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
7222 #[must_use]
7223 #[repr(C)]
7224 pub struct ReplyShortChannelIdsEnd {
7225         /// A pointer to the opaque Rust object.
7226
7227         /// Nearly everywhere, inner must be non-null, however in places where
7228         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7229         pub inner: *mut nativeReplyShortChannelIdsEnd,
7230         /// Indicates that this is the only struct which contains the same pointer.
7231
7232         /// Rust functions which take ownership of an object provided via an argument require
7233         /// this to be true and invalidate the object pointed to by inner.
7234         pub is_owned: bool,
7235 }
7236
7237 impl Drop for ReplyShortChannelIdsEnd {
7238         fn drop(&mut self) {
7239                 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
7240                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7241                 }
7242         }
7243 }
7244 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
7245 #[no_mangle]
7246 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
7247 #[allow(unused)]
7248 /// Used only if an object of this type is returned as a trait impl by a method
7249 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
7250         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
7251 }
7252 #[allow(unused)]
7253 impl ReplyShortChannelIdsEnd {
7254         pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
7255                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7256         }
7257         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
7258                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7259         }
7260         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7261         pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
7262                 assert!(self.is_owned);
7263                 let ret = ObjOps::untweak_ptr(self.inner);
7264                 self.inner = core::ptr::null_mut();
7265                 ret
7266         }
7267 }
7268 /// The genesis hash of the blockchain that was queried
7269 #[no_mangle]
7270 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
7271         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7272         inner_val.as_inner()
7273 }
7274 /// The genesis hash of the blockchain that was queried
7275 #[no_mangle]
7276 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
7277         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
7278 }
7279 /// Indicates if the query recipient maintains up-to-date channel
7280 /// information for the `chain_hash`
7281 #[no_mangle]
7282 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
7283         let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
7284         *inner_val
7285 }
7286 /// Indicates if the query recipient maintains up-to-date channel
7287 /// information for the `chain_hash`
7288 #[no_mangle]
7289 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
7290         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
7291 }
7292 /// Constructs a new ReplyShortChannelIdsEnd given each field
7293 #[must_use]
7294 #[no_mangle]
7295 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
7296         ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
7297                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7298                 full_information: full_information_arg,
7299         }), is_owned: true }
7300 }
7301 impl Clone for ReplyShortChannelIdsEnd {
7302         fn clone(&self) -> Self {
7303                 Self {
7304                         inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
7305                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7306                         is_owned: true,
7307                 }
7308         }
7309 }
7310 #[allow(unused)]
7311 /// Used only if an object of this type is returned as a trait impl by a method
7312 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
7313         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
7314 }
7315 #[no_mangle]
7316 /// Creates a copy of the ReplyShortChannelIdsEnd
7317 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
7318         orig.clone()
7319 }
7320 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
7321 /// This ignores pointers and is_owned flags and looks at the values in fields.
7322 /// Two objects with NULL inner values will be considered "equal" here.
7323 #[no_mangle]
7324 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
7325         if a.inner == b.inner { return true; }
7326         if a.inner.is_null() || b.inner.is_null() { return false; }
7327         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7328 }
7329
7330 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
7331 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
7332
7333 /// A [`gossip_timestamp_filter`] message is used by a node to request
7334 /// gossip relay for messages in the requested time range when the
7335 /// `gossip_queries` feature has been negotiated.
7336 ///
7337 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
7338 #[must_use]
7339 #[repr(C)]
7340 pub struct GossipTimestampFilter {
7341         /// A pointer to the opaque Rust object.
7342
7343         /// Nearly everywhere, inner must be non-null, however in places where
7344         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7345         pub inner: *mut nativeGossipTimestampFilter,
7346         /// Indicates that this is the only struct which contains the same pointer.
7347
7348         /// Rust functions which take ownership of an object provided via an argument require
7349         /// this to be true and invalidate the object pointed to by inner.
7350         pub is_owned: bool,
7351 }
7352
7353 impl Drop for GossipTimestampFilter {
7354         fn drop(&mut self) {
7355                 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
7356                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7357                 }
7358         }
7359 }
7360 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
7361 #[no_mangle]
7362 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
7363 #[allow(unused)]
7364 /// Used only if an object of this type is returned as a trait impl by a method
7365 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
7366         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
7367 }
7368 #[allow(unused)]
7369 impl GossipTimestampFilter {
7370         pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
7371                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7372         }
7373         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
7374                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7375         }
7376         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7377         pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
7378                 assert!(self.is_owned);
7379                 let ret = ObjOps::untweak_ptr(self.inner);
7380                 self.inner = core::ptr::null_mut();
7381                 ret
7382         }
7383 }
7384 /// The genesis hash of the blockchain for channel and node information
7385 #[no_mangle]
7386 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
7387         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7388         inner_val.as_inner()
7389 }
7390 /// The genesis hash of the blockchain for channel and node information
7391 #[no_mangle]
7392 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
7393         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
7394 }
7395 /// The starting unix timestamp
7396 #[no_mangle]
7397 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
7398         let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
7399         *inner_val
7400 }
7401 /// The starting unix timestamp
7402 #[no_mangle]
7403 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7404         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
7405 }
7406 /// The range of information in seconds
7407 #[no_mangle]
7408 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
7409         let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
7410         *inner_val
7411 }
7412 /// The range of information in seconds
7413 #[no_mangle]
7414 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7415         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
7416 }
7417 /// Constructs a new GossipTimestampFilter given each field
7418 #[must_use]
7419 #[no_mangle]
7420 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 {
7421         GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
7422                 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7423                 first_timestamp: first_timestamp_arg,
7424                 timestamp_range: timestamp_range_arg,
7425         }), is_owned: true }
7426 }
7427 impl Clone for GossipTimestampFilter {
7428         fn clone(&self) -> Self {
7429                 Self {
7430                         inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
7431                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7432                         is_owned: true,
7433                 }
7434         }
7435 }
7436 #[allow(unused)]
7437 /// Used only if an object of this type is returned as a trait impl by a method
7438 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
7439         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
7440 }
7441 #[no_mangle]
7442 /// Creates a copy of the GossipTimestampFilter
7443 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
7444         orig.clone()
7445 }
7446 /// Checks if two GossipTimestampFilters contain equal inner contents.
7447 /// This ignores pointers and is_owned flags and looks at the values in fields.
7448 /// Two objects with NULL inner values will be considered "equal" here.
7449 #[no_mangle]
7450 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
7451         if a.inner == b.inner { return true; }
7452         if a.inner.is_null() || b.inner.is_null() { return false; }
7453         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7454 }
7455 /// Used to put an error message in a [`LightningError`].
7456 #[derive(Clone)]
7457 #[must_use]
7458 #[repr(C)]
7459 pub enum ErrorAction {
7460         /// The peer took some action which made us think they were useless. Disconnect them.
7461         DisconnectPeer {
7462                 /// An error message which we should make an effort to send before we disconnect.
7463                 ///
7464                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
7465                 msg: crate::lightning::ln::msgs::ErrorMessage,
7466         },
7467         /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
7468         DisconnectPeerWithWarning {
7469                 /// A warning message which we should make an effort to send before we disconnect.
7470                 msg: crate::lightning::ln::msgs::WarningMessage,
7471         },
7472         /// The peer did something harmless that we weren't able to process, just log and ignore
7473         IgnoreError,
7474         /// The peer did something harmless that we weren't able to meaningfully process.
7475         /// If the error is logged, log it at the given level.
7476         IgnoreAndLog(
7477                 crate::lightning::util::logger::Level),
7478         /// The peer provided us with a gossip message which we'd already seen. In most cases this
7479         /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
7480         /// our own channel announcements.
7481         IgnoreDuplicateGossip,
7482         /// The peer did something incorrect. Tell them.
7483         SendErrorMessage {
7484                 /// The message to send.
7485                 msg: crate::lightning::ln::msgs::ErrorMessage,
7486         },
7487         /// The peer did something incorrect. Tell them without closing any channels.
7488         SendWarningMessage {
7489                 /// The message to send.
7490                 msg: crate::lightning::ln::msgs::WarningMessage,
7491                 /// The peer may have done something harmless that we weren't able to meaningfully process,
7492                 /// though we should still tell them about it.
7493                 /// If this event is logged, log it at the given level.
7494                 log_level: crate::lightning::util::logger::Level,
7495         },
7496 }
7497 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
7498 pub(crate) type nativeErrorAction = ErrorActionImport;
7499
7500 impl ErrorAction {
7501         #[allow(unused)]
7502         pub(crate) fn to_native(&self) -> nativeErrorAction {
7503                 match self {
7504                         ErrorAction::DisconnectPeer {ref msg, } => {
7505                                 let mut msg_nonref = Clone::clone(msg);
7506                                 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
7507                                 nativeErrorAction::DisconnectPeer {
7508                                         msg: local_msg_nonref,
7509                                 }
7510                         },
7511                         ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7512                                 let mut msg_nonref = Clone::clone(msg);
7513                                 nativeErrorAction::DisconnectPeerWithWarning {
7514                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7515                                 }
7516                         },
7517                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7518                         ErrorAction::IgnoreAndLog (ref a, ) => {
7519                                 let mut a_nonref = Clone::clone(a);
7520                                 nativeErrorAction::IgnoreAndLog (
7521                                         a_nonref.into_native(),
7522                                 )
7523                         },
7524                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7525                         ErrorAction::SendErrorMessage {ref msg, } => {
7526                                 let mut msg_nonref = Clone::clone(msg);
7527                                 nativeErrorAction::SendErrorMessage {
7528                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7529                                 }
7530                         },
7531                         ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7532                                 let mut msg_nonref = Clone::clone(msg);
7533                                 let mut log_level_nonref = Clone::clone(log_level);
7534                                 nativeErrorAction::SendWarningMessage {
7535                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7536                                         log_level: log_level_nonref.into_native(),
7537                                 }
7538                         },
7539                 }
7540         }
7541         #[allow(unused)]
7542         pub(crate) fn into_native(self) -> nativeErrorAction {
7543                 match self {
7544                         ErrorAction::DisconnectPeer {mut msg, } => {
7545                                 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
7546                                 nativeErrorAction::DisconnectPeer {
7547                                         msg: local_msg,
7548                                 }
7549                         },
7550                         ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7551                                 nativeErrorAction::DisconnectPeerWithWarning {
7552                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
7553                                 }
7554                         },
7555                         ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7556                         ErrorAction::IgnoreAndLog (mut a, ) => {
7557                                 nativeErrorAction::IgnoreAndLog (
7558                                         a.into_native(),
7559                                 )
7560                         },
7561                         ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7562                         ErrorAction::SendErrorMessage {mut msg, } => {
7563                                 nativeErrorAction::SendErrorMessage {
7564                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
7565                                 }
7566                         },
7567                         ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7568                                 nativeErrorAction::SendWarningMessage {
7569                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
7570                                         log_level: log_level.into_native(),
7571                                 }
7572                         },
7573                 }
7574         }
7575         #[allow(unused)]
7576         pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
7577                 match native {
7578                         nativeErrorAction::DisconnectPeer {ref msg, } => {
7579                                 let mut msg_nonref = Clone::clone(msg);
7580                                 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 };
7581                                 ErrorAction::DisconnectPeer {
7582                                         msg: local_msg_nonref,
7583                                 }
7584                         },
7585                         nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7586                                 let mut msg_nonref = Clone::clone(msg);
7587                                 ErrorAction::DisconnectPeerWithWarning {
7588                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7589                                 }
7590                         },
7591                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7592                         nativeErrorAction::IgnoreAndLog (ref a, ) => {
7593                                 let mut a_nonref = Clone::clone(a);
7594                                 ErrorAction::IgnoreAndLog (
7595                                         crate::lightning::util::logger::Level::native_into(a_nonref),
7596                                 )
7597                         },
7598                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7599                         nativeErrorAction::SendErrorMessage {ref msg, } => {
7600                                 let mut msg_nonref = Clone::clone(msg);
7601                                 ErrorAction::SendErrorMessage {
7602                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7603                                 }
7604                         },
7605                         nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7606                                 let mut msg_nonref = Clone::clone(msg);
7607                                 let mut log_level_nonref = Clone::clone(log_level);
7608                                 ErrorAction::SendWarningMessage {
7609                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7610                                         log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
7611                                 }
7612                         },
7613                 }
7614         }
7615         #[allow(unused)]
7616         pub(crate) fn native_into(native: nativeErrorAction) -> Self {
7617                 match native {
7618                         nativeErrorAction::DisconnectPeer {mut msg, } => {
7619                                 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 };
7620                                 ErrorAction::DisconnectPeer {
7621                                         msg: local_msg,
7622                                 }
7623                         },
7624                         nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7625                                 ErrorAction::DisconnectPeerWithWarning {
7626                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7627                                 }
7628                         },
7629                         nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7630                         nativeErrorAction::IgnoreAndLog (mut a, ) => {
7631                                 ErrorAction::IgnoreAndLog (
7632                                         crate::lightning::util::logger::Level::native_into(a),
7633                                 )
7634                         },
7635                         nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7636                         nativeErrorAction::SendErrorMessage {mut msg, } => {
7637                                 ErrorAction::SendErrorMessage {
7638                                         msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7639                                 }
7640                         },
7641                         nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7642                                 ErrorAction::SendWarningMessage {
7643                                         msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7644                                         log_level: crate::lightning::util::logger::Level::native_into(log_level),
7645                                 }
7646                         },
7647                 }
7648         }
7649 }
7650 /// Frees any resources used by the ErrorAction
7651 #[no_mangle]
7652 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
7653 /// Creates a copy of the ErrorAction
7654 #[no_mangle]
7655 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
7656         orig.clone()
7657 }
7658 #[no_mangle]
7659 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
7660 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7661         ErrorAction::DisconnectPeer {
7662                 msg,
7663         }
7664 }
7665 #[no_mangle]
7666 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
7667 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
7668         ErrorAction::DisconnectPeerWithWarning {
7669                 msg,
7670         }
7671 }
7672 #[no_mangle]
7673 /// Utility method to constructs a new IgnoreError-variant ErrorAction
7674 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
7675         ErrorAction::IgnoreError}
7676 #[no_mangle]
7677 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
7678 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
7679         ErrorAction::IgnoreAndLog(a, )
7680 }
7681 #[no_mangle]
7682 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
7683 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
7684         ErrorAction::IgnoreDuplicateGossip}
7685 #[no_mangle]
7686 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
7687 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7688         ErrorAction::SendErrorMessage {
7689                 msg,
7690         }
7691 }
7692 #[no_mangle]
7693 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
7694 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
7695         ErrorAction::SendWarningMessage {
7696                 msg,
7697                 log_level,
7698         }
7699 }
7700
7701 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
7702 pub(crate) type nativeLightningError = nativeLightningErrorImport;
7703
7704 /// An Err type for failure to process messages.
7705 #[must_use]
7706 #[repr(C)]
7707 pub struct LightningError {
7708         /// A pointer to the opaque Rust object.
7709
7710         /// Nearly everywhere, inner must be non-null, however in places where
7711         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7712         pub inner: *mut nativeLightningError,
7713         /// Indicates that this is the only struct which contains the same pointer.
7714
7715         /// Rust functions which take ownership of an object provided via an argument require
7716         /// this to be true and invalidate the object pointed to by inner.
7717         pub is_owned: bool,
7718 }
7719
7720 impl Drop for LightningError {
7721         fn drop(&mut self) {
7722                 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
7723                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7724                 }
7725         }
7726 }
7727 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
7728 #[no_mangle]
7729 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
7730 #[allow(unused)]
7731 /// Used only if an object of this type is returned as a trait impl by a method
7732 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
7733         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
7734 }
7735 #[allow(unused)]
7736 impl LightningError {
7737         pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
7738                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7739         }
7740         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
7741                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7742         }
7743         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7744         pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
7745                 assert!(self.is_owned);
7746                 let ret = ObjOps::untweak_ptr(self.inner);
7747                 self.inner = core::ptr::null_mut();
7748                 ret
7749         }
7750 }
7751 /// A human-readable message describing the error
7752 #[no_mangle]
7753 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
7754         let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
7755         inner_val.as_str().into()
7756 }
7757 /// A human-readable message describing the error
7758 #[no_mangle]
7759 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
7760         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
7761 }
7762 /// The action which should be taken against the offending peer.
7763 #[no_mangle]
7764 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
7765         let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
7766         crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
7767 }
7768 /// The action which should be taken against the offending peer.
7769 #[no_mangle]
7770 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
7771         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
7772 }
7773 /// Constructs a new LightningError given each field
7774 #[must_use]
7775 #[no_mangle]
7776 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
7777         LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
7778                 err: err_arg.into_string(),
7779                 action: action_arg.into_native(),
7780         }), is_owned: true }
7781 }
7782 impl Clone for LightningError {
7783         fn clone(&self) -> Self {
7784                 Self {
7785                         inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
7786                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7787                         is_owned: true,
7788                 }
7789         }
7790 }
7791 #[allow(unused)]
7792 /// Used only if an object of this type is returned as a trait impl by a method
7793 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
7794         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
7795 }
7796 #[no_mangle]
7797 /// Creates a copy of the LightningError
7798 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
7799         orig.clone()
7800 }
7801
7802 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
7803 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
7804
7805 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
7806 /// transaction updates if they were pending.
7807 #[must_use]
7808 #[repr(C)]
7809 pub struct CommitmentUpdate {
7810         /// A pointer to the opaque Rust object.
7811
7812         /// Nearly everywhere, inner must be non-null, however in places where
7813         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7814         pub inner: *mut nativeCommitmentUpdate,
7815         /// Indicates that this is the only struct which contains the same pointer.
7816
7817         /// Rust functions which take ownership of an object provided via an argument require
7818         /// this to be true and invalidate the object pointed to by inner.
7819         pub is_owned: bool,
7820 }
7821
7822 impl Drop for CommitmentUpdate {
7823         fn drop(&mut self) {
7824                 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
7825                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7826                 }
7827         }
7828 }
7829 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
7830 #[no_mangle]
7831 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
7832 #[allow(unused)]
7833 /// Used only if an object of this type is returned as a trait impl by a method
7834 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
7835         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
7836 }
7837 #[allow(unused)]
7838 impl CommitmentUpdate {
7839         pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
7840                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7841         }
7842         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
7843                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7844         }
7845         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7846         pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
7847                 assert!(self.is_owned);
7848                 let ret = ObjOps::untweak_ptr(self.inner);
7849                 self.inner = core::ptr::null_mut();
7850                 ret
7851         }
7852 }
7853 /// `update_add_htlc` messages which should be sent
7854 #[no_mangle]
7855 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
7856         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
7857         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 } }); };
7858         local_inner_val.into()
7859 }
7860 /// `update_add_htlc` messages which should be sent
7861 #[no_mangle]
7862 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
7863         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7864         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
7865 }
7866 /// `update_fulfill_htlc` messages which should be sent
7867 #[no_mangle]
7868 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
7869         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
7870         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 } }); };
7871         local_inner_val.into()
7872 }
7873 /// `update_fulfill_htlc` messages which should be sent
7874 #[no_mangle]
7875 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
7876         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7877         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
7878 }
7879 /// `update_fail_htlc` messages which should be sent
7880 #[no_mangle]
7881 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
7882         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
7883         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 } }); };
7884         local_inner_val.into()
7885 }
7886 /// `update_fail_htlc` messages which should be sent
7887 #[no_mangle]
7888 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
7889         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7890         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
7891 }
7892 /// `update_fail_malformed_htlc` messages which should be sent
7893 #[no_mangle]
7894 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
7895         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
7896         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 } }); };
7897         local_inner_val.into()
7898 }
7899 /// `update_fail_malformed_htlc` messages which should be sent
7900 #[no_mangle]
7901 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
7902         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7903         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
7904 }
7905 /// An `update_fee` message which should be sent
7906 ///
7907 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
7908 #[no_mangle]
7909 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
7910         let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
7911         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 };
7912         local_inner_val
7913 }
7914 /// An `update_fee` message which should be sent
7915 ///
7916 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
7917 #[no_mangle]
7918 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
7919         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
7920         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
7921 }
7922 /// A `commitment_signed` message which should be sent
7923 #[no_mangle]
7924 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
7925         let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
7926         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 }
7927 }
7928 /// A `commitment_signed` message which should be sent
7929 #[no_mangle]
7930 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
7931         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
7932 }
7933 /// Constructs a new CommitmentUpdate given each field
7934 ///
7935 /// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
7936 #[must_use]
7937 #[no_mangle]
7938 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 {
7939         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()) } }); };
7940         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()) } }); };
7941         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()) } }); };
7942         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()) } }); };
7943         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()) } }) };
7944         CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
7945                 update_add_htlcs: local_update_add_htlcs_arg,
7946                 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
7947                 update_fail_htlcs: local_update_fail_htlcs_arg,
7948                 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
7949                 update_fee: local_update_fee_arg,
7950                 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
7951         }), is_owned: true }
7952 }
7953 impl Clone for CommitmentUpdate {
7954         fn clone(&self) -> Self {
7955                 Self {
7956                         inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7957                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7958                         is_owned: true,
7959                 }
7960         }
7961 }
7962 #[allow(unused)]
7963 /// Used only if an object of this type is returned as a trait impl by a method
7964 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7965         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
7966 }
7967 #[no_mangle]
7968 /// Creates a copy of the CommitmentUpdate
7969 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
7970         orig.clone()
7971 }
7972 /// Checks if two CommitmentUpdates contain equal inner contents.
7973 /// This ignores pointers and is_owned flags and looks at the values in fields.
7974 /// Two objects with NULL inner values will be considered "equal" here.
7975 #[no_mangle]
7976 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
7977         if a.inner == b.inner { return true; }
7978         if a.inner.is_null() || b.inner.is_null() { return false; }
7979         if a.get_native_ref() == b.get_native_ref() { true } else { false }
7980 }
7981 /// A trait to describe an object which can receive channel messages.
7982 ///
7983 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
7984 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
7985 #[repr(C)]
7986 pub struct ChannelMessageHandler {
7987         /// An opaque pointer which is passed to your function implementations as an argument.
7988         /// This has no meaning in the LDK, and can be NULL or any other value.
7989         pub this_arg: *mut c_void,
7990         /// Handle an incoming `open_channel` message from the given peer.
7991         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),
7992         /// Handle an incoming `open_channel2` message from the given peer.
7993         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),
7994         /// Handle an incoming `accept_channel` message from the given peer.
7995         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),
7996         /// Handle an incoming `accept_channel2` message from the given peer.
7997         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),
7998         /// Handle an incoming `funding_created` message from the given peer.
7999         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),
8000         /// Handle an incoming `funding_signed` message from the given peer.
8001         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),
8002         /// Handle an incoming `channel_ready` message from the given peer.
8003         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),
8004         /// Handle an incoming `shutdown` message from the given peer.
8005         pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
8006         /// Handle an incoming `closing_signed` message from the given peer.
8007         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),
8008         /// Handle an incoming `tx_add_input message` from the given peer.
8009         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),
8010         /// Handle an incoming `tx_add_output` message from the given peer.
8011         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),
8012         /// Handle an incoming `tx_remove_input` message from the given peer.
8013         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),
8014         /// Handle an incoming `tx_remove_output` message from the given peer.
8015         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),
8016         /// Handle an incoming `tx_complete message` from the given peer.
8017         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),
8018         /// Handle an incoming `tx_signatures` message from the given peer.
8019         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),
8020         /// Handle an incoming `tx_init_rbf` message from the given peer.
8021         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),
8022         /// Handle an incoming `tx_ack_rbf` message from the given peer.
8023         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),
8024         /// Handle an incoming `tx_abort message` from the given peer.
8025         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),
8026         /// Handle an incoming `update_add_htlc` message from the given peer.
8027         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),
8028         /// Handle an incoming `update_fulfill_htlc` message from the given peer.
8029         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),
8030         /// Handle an incoming `update_fail_htlc` message from the given peer.
8031         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),
8032         /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
8033         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),
8034         /// Handle an incoming `commitment_signed` message from the given peer.
8035         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),
8036         /// Handle an incoming `revoke_and_ack` message from the given peer.
8037         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),
8038         /// Handle an incoming `update_fee` message from the given peer.
8039         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),
8040         /// Handle an incoming `announcement_signatures` message from the given peer.
8041         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),
8042         /// Indicates a connection to the peer failed/an existing connection was lost.
8043         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
8044         /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
8045         ///
8046         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8047         /// with us. Implementors should be somewhat conservative about doing so, however, as other
8048         /// message handlers may still wish to communicate with this peer.
8049         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,
8050         /// Handle an incoming `channel_reestablish` message from the given peer.
8051         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),
8052         /// Handle an incoming `channel_update` message from the given peer.
8053         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),
8054         /// Handle an incoming `error` message from the given peer.
8055         pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
8056         /// Gets the node feature flags which this handler itself supports. All available handlers are
8057         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8058         /// which are broadcasted in our [`NodeAnnouncement`] message.
8059         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8060         /// Gets the init feature flags which should be sent to the given peer. All available handlers
8061         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8062         /// which are sent in our [`Init`] message.
8063         ///
8064         /// Note that this method is called before [`Self::peer_connected`].
8065         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8066         /// Gets the genesis hashes for this `ChannelMessageHandler` indicating which chains it supports.
8067         ///
8068         /// If it's `None`, then no particular network chain hash compatibility will be enforced when
8069         /// connecting to peers.
8070         pub get_genesis_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ,
8071         /// Implementation of MessageSendEventsProvider for this object.
8072         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
8073         /// Frees any resources associated with this object given its this_arg pointer.
8074         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8075         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8076 }
8077 unsafe impl Send for ChannelMessageHandler {}
8078 unsafe impl Sync for ChannelMessageHandler {}
8079 pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
8080         ChannelMessageHandler {
8081                 this_arg: orig.this_arg,
8082                 handle_open_channel: Clone::clone(&orig.handle_open_channel),
8083                 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
8084                 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
8085                 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
8086                 handle_funding_created: Clone::clone(&orig.handle_funding_created),
8087                 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
8088                 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
8089                 handle_shutdown: Clone::clone(&orig.handle_shutdown),
8090                 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
8091                 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
8092                 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
8093                 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
8094                 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
8095                 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
8096                 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
8097                 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
8098                 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
8099                 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
8100                 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
8101                 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
8102                 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
8103                 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
8104                 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
8105                 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
8106                 handle_update_fee: Clone::clone(&orig.handle_update_fee),
8107                 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
8108                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
8109                 peer_connected: Clone::clone(&orig.peer_connected),
8110                 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
8111                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
8112                 handle_error: Clone::clone(&orig.handle_error),
8113                 provided_node_features: Clone::clone(&orig.provided_node_features),
8114                 provided_init_features: Clone::clone(&orig.provided_init_features),
8115                 get_genesis_hashes: Clone::clone(&orig.get_genesis_hashes),
8116                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
8117                 free: Clone::clone(&orig.free),
8118         }
8119 }
8120 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
8121         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
8122                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
8123                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
8124                 local_ret
8125         }
8126 }
8127
8128 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
8129 impl rustChannelMessageHandler for ChannelMessageHandler {
8130         fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
8131                 (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 })
8132         }
8133         fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
8134                 (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 })
8135         }
8136         fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
8137                 (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 })
8138         }
8139         fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
8140                 (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 })
8141         }
8142         fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
8143                 (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 })
8144         }
8145         fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
8146                 (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 })
8147         }
8148         fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
8149                 (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 })
8150         }
8151         fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
8152                 (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 })
8153         }
8154         fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
8155                 (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 })
8156         }
8157         fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
8158                 (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 })
8159         }
8160         fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
8161                 (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 })
8162         }
8163         fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
8164                 (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 })
8165         }
8166         fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
8167                 (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 })
8168         }
8169         fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
8170                 (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 })
8171         }
8172         fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
8173                 (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 })
8174         }
8175         fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
8176                 (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 })
8177         }
8178         fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
8179                 (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 })
8180         }
8181         fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
8182                 (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 })
8183         }
8184         fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
8185                 (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 })
8186         }
8187         fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
8188                 (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 })
8189         }
8190         fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
8191                 (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 })
8192         }
8193         fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
8194                 (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 })
8195         }
8196         fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
8197                 (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 })
8198         }
8199         fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
8200                 (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 })
8201         }
8202         fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
8203                 (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 })
8204         }
8205         fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
8206                 (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 })
8207         }
8208         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8209                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8210         }
8211         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8212                 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);
8213                 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)) })*/ })};
8214                 local_ret
8215         }
8216         fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
8217                 (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 })
8218         }
8219         fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
8220                 (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 })
8221         }
8222         fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
8223                 (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 })
8224         }
8225         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8226                 let mut ret = (self.provided_node_features)(self.this_arg);
8227                 *unsafe { Box::from_raw(ret.take_inner()) }
8228         }
8229         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8230                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8231                 *unsafe { Box::from_raw(ret.take_inner()) }
8232         }
8233         fn get_genesis_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
8234                 let mut ret = (self.get_genesis_hashes)(self.this_arg);
8235                 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 }})} };
8236                 local_ret
8237         }
8238 }
8239
8240 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8241 // directly as a Deref trait in higher-level structs:
8242 impl core::ops::Deref for ChannelMessageHandler {
8243         type Target = Self;
8244         fn deref(&self) -> &Self {
8245                 self
8246         }
8247 }
8248 impl core::ops::DerefMut for ChannelMessageHandler {
8249         fn deref_mut(&mut self) -> &mut Self {
8250                 self
8251         }
8252 }
8253 /// Calls the free function if one is set
8254 #[no_mangle]
8255 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
8256 impl Drop for ChannelMessageHandler {
8257         fn drop(&mut self) {
8258                 if let Some(f) = self.free {
8259                         f(self.this_arg);
8260                 }
8261         }
8262 }
8263 /// A trait to describe an object which can receive routing messages.
8264 ///
8265 /// # Implementor DoS Warnings
8266 ///
8267 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
8268 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
8269 /// repeated disk I/O for queries accessing different parts of the network graph.
8270 #[repr(C)]
8271 pub struct RoutingMessageHandler {
8272         /// An opaque pointer which is passed to your function implementations as an argument.
8273         /// This has no meaning in the LDK, and can be NULL or any other value.
8274         pub this_arg: *mut c_void,
8275         /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
8276         /// `false` or returning an `Err` otherwise.
8277         pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8278         /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
8279         /// or returning an `Err` otherwise.
8280         pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8281         /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
8282         /// `false` or returning an `Err` otherwise.
8283         pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8284         /// Gets channel announcements and updates required to dump our routing table to a remote node,
8285         /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
8286         /// for a single channel.
8287         pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
8288         /// Gets a node announcement required to dump our routing table to a remote node, starting at
8289         /// the node *after* the provided pubkey and including up to one announcement immediately
8290         /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
8291         /// If `None` is provided for `starting_point`, we start at the first node.
8292         ///
8293         /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
8294         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
8295         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,
8296         /// Called when a connection is established with a peer. This can be used to
8297         /// perform routing table synchronization using a strategy defined by the
8298         /// implementor.
8299         ///
8300         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8301         /// with us. Implementors should be somewhat conservative about doing so, however, as other
8302         /// message handlers may still wish to communicate with this peer.
8303         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,
8304         /// Handles the reply of a query we initiated to learn about channels
8305         /// for a given range of blocks. We can expect to receive one or more
8306         /// replies to a single query.
8307         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,
8308         /// Handles the reply of a query we initiated asking for routing gossip
8309         /// messages for a list of channels. We should receive this message when
8310         /// a node has completed its best effort to send us the pertaining routing
8311         /// gossip messages.
8312         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,
8313         /// Handles when a peer asks us to send a list of `short_channel_id`s
8314         /// for the requested range of blocks.
8315         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,
8316         /// Handles when a peer asks us to send routing gossip messages for a
8317         /// list of `short_channel_id`s.
8318         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,
8319         /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
8320         /// pending some async action. While there is no guarantee of the rate of future messages, the
8321         /// caller should seek to reduce the rate of new gossip messages handled, especially
8322         /// [`ChannelAnnouncement`]s.
8323         pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
8324         /// Gets the node feature flags which this handler itself supports. All available handlers are
8325         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8326         /// which are broadcasted in our [`NodeAnnouncement`] message.
8327         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8328         /// Gets the init feature flags which should be sent to the given peer. All available handlers
8329         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8330         /// which are sent in our [`Init`] message.
8331         ///
8332         /// Note that this method is called before [`Self::peer_connected`].
8333         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8334         /// Implementation of MessageSendEventsProvider for this object.
8335         pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
8336         /// Frees any resources associated with this object given its this_arg pointer.
8337         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8338         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8339 }
8340 unsafe impl Send for RoutingMessageHandler {}
8341 unsafe impl Sync for RoutingMessageHandler {}
8342 pub(crate) fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
8343         RoutingMessageHandler {
8344                 this_arg: orig.this_arg,
8345                 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
8346                 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
8347                 handle_channel_update: Clone::clone(&orig.handle_channel_update),
8348                 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
8349                 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
8350                 peer_connected: Clone::clone(&orig.peer_connected),
8351                 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
8352                 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
8353                 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
8354                 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
8355                 processing_queue_high: Clone::clone(&orig.processing_queue_high),
8356                 provided_node_features: Clone::clone(&orig.provided_node_features),
8357                 provided_init_features: Clone::clone(&orig.provided_init_features),
8358                 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
8359                 free: Clone::clone(&orig.free),
8360         }
8361 }
8362 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
8363         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
8364                 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
8365                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
8366                 local_ret
8367         }
8368 }
8369
8370 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
8371 impl rustRoutingMessageHandler for RoutingMessageHandler {
8372         fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8373                 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 });
8374                 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()) } })};
8375                 local_ret
8376         }
8377         fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8378                 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 });
8379                 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()) } })};
8380                 local_ret
8381         }
8382         fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
8383                 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 });
8384                 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()) } })};
8385                 local_ret
8386         }
8387         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>)> {
8388                 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
8389                 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 };
8390                 local_ret
8391         }
8392         fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
8393                 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 };
8394                 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
8395                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8396                 local_ret
8397         }
8398         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8399                 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);
8400                 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)) })*/ })};
8401                 local_ret
8402         }
8403         fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8404                 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 });
8405                 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()) } })};
8406                 local_ret
8407         }
8408         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> {
8409                 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 });
8410                 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()) } })};
8411                 local_ret
8412         }
8413         fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8414                 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 });
8415                 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()) } })};
8416                 local_ret
8417         }
8418         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> {
8419                 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 });
8420                 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()) } })};
8421                 local_ret
8422         }
8423         fn processing_queue_high(&self) -> bool {
8424                 let mut ret = (self.processing_queue_high)(self.this_arg);
8425                 ret
8426         }
8427         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8428                 let mut ret = (self.provided_node_features)(self.this_arg);
8429                 *unsafe { Box::from_raw(ret.take_inner()) }
8430         }
8431         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8432                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8433                 *unsafe { Box::from_raw(ret.take_inner()) }
8434         }
8435 }
8436
8437 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8438 // directly as a Deref trait in higher-level structs:
8439 impl core::ops::Deref for RoutingMessageHandler {
8440         type Target = Self;
8441         fn deref(&self) -> &Self {
8442                 self
8443         }
8444 }
8445 impl core::ops::DerefMut for RoutingMessageHandler {
8446         fn deref_mut(&mut self) -> &mut Self {
8447                 self
8448         }
8449 }
8450 /// Calls the free function if one is set
8451 #[no_mangle]
8452 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
8453 impl Drop for RoutingMessageHandler {
8454         fn drop(&mut self) {
8455                 if let Some(f) = self.free {
8456                         f(self.this_arg);
8457                 }
8458         }
8459 }
8460 /// A trait to describe an object that can receive onion messages.
8461 #[repr(C)]
8462 pub struct OnionMessageHandler {
8463         /// An opaque pointer which is passed to your function implementations as an argument.
8464         /// This has no meaning in the LDK, and can be NULL or any other value.
8465         pub this_arg: *mut c_void,
8466         /// Handle an incoming `onion_message` message from the given peer.
8467         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),
8468         /// Called when a connection is established with a peer. Can be used to track which peers
8469         /// advertise onion message support and are online.
8470         ///
8471         /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8472         /// with us. Implementors should be somewhat conservative about doing so, however, as other
8473         /// message handlers may still wish to communicate with this peer.
8474         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,
8475         /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
8476         /// drop and refuse to forward onion messages to this peer.
8477         pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
8478         /// Gets the node feature flags which this handler itself supports. All available handlers are
8479         /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8480         /// which are broadcasted in our [`NodeAnnouncement`] message.
8481         pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8482         /// Gets the init feature flags which should be sent to the given peer. All available handlers
8483         /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8484         /// which are sent in our [`Init`] message.
8485         ///
8486         /// Note that this method is called before [`Self::peer_connected`].
8487         pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8488         /// Implementation of OnionMessageProvider for this object.
8489         pub OnionMessageProvider: crate::lightning::events::OnionMessageProvider,
8490         /// Frees any resources associated with this object given its this_arg pointer.
8491         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8492         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8493 }
8494 unsafe impl Send for OnionMessageHandler {}
8495 unsafe impl Sync for OnionMessageHandler {}
8496 pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
8497         OnionMessageHandler {
8498                 this_arg: orig.this_arg,
8499                 handle_onion_message: Clone::clone(&orig.handle_onion_message),
8500                 peer_connected: Clone::clone(&orig.peer_connected),
8501                 peer_disconnected: Clone::clone(&orig.peer_disconnected),
8502                 provided_node_features: Clone::clone(&orig.provided_node_features),
8503                 provided_init_features: Clone::clone(&orig.provided_init_features),
8504                 OnionMessageProvider: crate::lightning::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider),
8505                 free: Clone::clone(&orig.free),
8506         }
8507 }
8508 impl lightning::events::OnionMessageProvider for OnionMessageHandler {
8509         fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
8510                 let mut ret = (self.OnionMessageProvider.next_onion_message_for_peer)(self.OnionMessageProvider.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
8511                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8512                 local_ret
8513         }
8514 }
8515
8516 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
8517 impl rustOnionMessageHandler for OnionMessageHandler {
8518         fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
8519                 (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 })
8520         }
8521         fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8522                 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);
8523                 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)) })*/ })};
8524                 local_ret
8525         }
8526         fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8527                 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8528         }
8529         fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8530                 let mut ret = (self.provided_node_features)(self.this_arg);
8531                 *unsafe { Box::from_raw(ret.take_inner()) }
8532         }
8533         fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8534                 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8535                 *unsafe { Box::from_raw(ret.take_inner()) }
8536         }
8537 }
8538
8539 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8540 // directly as a Deref trait in higher-level structs:
8541 impl core::ops::Deref for OnionMessageHandler {
8542         type Target = Self;
8543         fn deref(&self) -> &Self {
8544                 self
8545         }
8546 }
8547 impl core::ops::DerefMut for OnionMessageHandler {
8548         fn deref_mut(&mut self) -> &mut Self {
8549                 self
8550         }
8551 }
8552 /// Calls the free function if one is set
8553 #[no_mangle]
8554 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
8555 impl Drop for OnionMessageHandler {
8556         fn drop(&mut self) {
8557                 if let Some(f) = self.free {
8558                         f(self.this_arg);
8559                 }
8560         }
8561 }
8562 mod fuzzy_internal_msgs {
8563
8564 use alloc::str::FromStr;
8565 use alloc::string::String;
8566 use core::ffi::c_void;
8567 use core::convert::Infallible;
8568 use bitcoin::hashes::Hash;
8569 use crate::c_types::*;
8570 #[cfg(feature="no-std")]
8571 use alloc::{vec::Vec, boxed::Box};
8572
8573 }
8574 #[no_mangle]
8575 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
8576 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
8577         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8578 }
8579 #[no_mangle]
8580 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8581         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
8582 }
8583 #[no_mangle]
8584 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
8585 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
8586         let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8587         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() };
8588         local_res
8589 }
8590 #[no_mangle]
8591 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
8592 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
8593         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8594 }
8595 #[no_mangle]
8596 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8597         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
8598 }
8599 #[no_mangle]
8600 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
8601 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
8602         let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8603         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() };
8604         local_res
8605 }
8606 #[no_mangle]
8607 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
8608 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
8609         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8610 }
8611 #[no_mangle]
8612 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8613         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
8614 }
8615 #[no_mangle]
8616 /// Read a TxAddInput from a byte array, created by TxAddInput_write
8617 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
8618         let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8619         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() };
8620         local_res
8621 }
8622 #[no_mangle]
8623 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
8624 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
8625         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8626 }
8627 #[no_mangle]
8628 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8629         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
8630 }
8631 #[no_mangle]
8632 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
8633 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
8634         let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8635         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() };
8636         local_res
8637 }
8638 #[no_mangle]
8639 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
8640 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
8641         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8642 }
8643 #[no_mangle]
8644 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8645         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
8646 }
8647 #[no_mangle]
8648 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
8649 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
8650         let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8651         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() };
8652         local_res
8653 }
8654 #[no_mangle]
8655 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
8656 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
8657         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8658 }
8659 #[no_mangle]
8660 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8661         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
8662 }
8663 #[no_mangle]
8664 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
8665 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
8666         let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8667         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() };
8668         local_res
8669 }
8670 #[no_mangle]
8671 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
8672 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
8673         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8674 }
8675 #[no_mangle]
8676 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8677         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
8678 }
8679 #[no_mangle]
8680 /// Read a TxComplete from a byte array, created by TxComplete_write
8681 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
8682         let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8683         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() };
8684         local_res
8685 }
8686 #[no_mangle]
8687 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
8688 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
8689         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8690 }
8691 #[no_mangle]
8692 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8693         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
8694 }
8695 #[no_mangle]
8696 /// Read a TxSignatures from a byte array, created by TxSignatures_write
8697 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
8698         let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8699         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() };
8700         local_res
8701 }
8702 #[no_mangle]
8703 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
8704 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
8705         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8706 }
8707 #[no_mangle]
8708 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8709         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
8710 }
8711 #[no_mangle]
8712 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
8713 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
8714         let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8715         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() };
8716         local_res
8717 }
8718 #[no_mangle]
8719 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
8720 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
8721         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8722 }
8723 #[no_mangle]
8724 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8725         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
8726 }
8727 #[no_mangle]
8728 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
8729 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
8730         let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8731         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() };
8732         local_res
8733 }
8734 #[no_mangle]
8735 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
8736 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
8737         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8738 }
8739 #[no_mangle]
8740 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8741         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
8742 }
8743 #[no_mangle]
8744 /// Read a TxAbort from a byte array, created by TxAbort_write
8745 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
8746         let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8747         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() };
8748         local_res
8749 }
8750 #[no_mangle]
8751 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
8752 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
8753         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8754 }
8755 #[no_mangle]
8756 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8757         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
8758 }
8759 #[no_mangle]
8760 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
8761 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
8762         let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8763         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() };
8764         local_res
8765 }
8766 #[no_mangle]
8767 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
8768 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
8769         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8770 }
8771 #[no_mangle]
8772 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8773         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
8774 }
8775 #[no_mangle]
8776 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
8777 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
8778         let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8779         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() };
8780         local_res
8781 }
8782 #[no_mangle]
8783 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
8784 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
8785         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8786 }
8787 #[no_mangle]
8788 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8789         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
8790 }
8791 #[no_mangle]
8792 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
8793 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
8794         let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8795         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() };
8796         local_res
8797 }
8798 #[no_mangle]
8799 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
8800 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
8801         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8802 }
8803 #[no_mangle]
8804 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8805         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
8806 }
8807 #[no_mangle]
8808 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
8809 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
8810         let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8811         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() };
8812         local_res
8813 }
8814 #[no_mangle]
8815 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
8816 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
8817         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8818 }
8819 #[no_mangle]
8820 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8821         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
8822 }
8823 #[no_mangle]
8824 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
8825 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
8826         let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8827         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() };
8828         local_res
8829 }
8830 #[no_mangle]
8831 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
8832 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
8833         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8834 }
8835 #[no_mangle]
8836 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8837         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
8838 }
8839 #[no_mangle]
8840 /// Read a FundingCreated from a byte array, created by FundingCreated_write
8841 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
8842         let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8843         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() };
8844         local_res
8845 }
8846 #[no_mangle]
8847 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
8848 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
8849         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8850 }
8851 #[no_mangle]
8852 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8853         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
8854 }
8855 #[no_mangle]
8856 /// Read a FundingSigned from a byte array, created by FundingSigned_write
8857 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
8858         let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8859         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() };
8860         local_res
8861 }
8862 #[no_mangle]
8863 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
8864 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
8865         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8866 }
8867 #[no_mangle]
8868 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8869         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
8870 }
8871 #[no_mangle]
8872 /// Read a ChannelReady from a byte array, created by ChannelReady_write
8873 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
8874         let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8875         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() };
8876         local_res
8877 }
8878 #[no_mangle]
8879 /// Serialize the Init object into a byte array which can be read by Init_read
8880 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
8881         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8882 }
8883 #[no_mangle]
8884 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8885         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
8886 }
8887 #[no_mangle]
8888 /// Read a Init from a byte array, created by Init_write
8889 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
8890         let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8891         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() };
8892         local_res
8893 }
8894 #[no_mangle]
8895 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
8896 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
8897         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8898 }
8899 #[no_mangle]
8900 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8901         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
8902 }
8903 #[no_mangle]
8904 /// Read a OpenChannel from a byte array, created by OpenChannel_write
8905 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
8906         let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8907         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() };
8908         local_res
8909 }
8910 #[no_mangle]
8911 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
8912 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
8913         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8914 }
8915 #[no_mangle]
8916 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8917         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
8918 }
8919 #[no_mangle]
8920 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
8921 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
8922         let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8923         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() };
8924         local_res
8925 }
8926 #[no_mangle]
8927 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
8928 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
8929         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8930 }
8931 #[no_mangle]
8932 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8933         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
8934 }
8935 #[no_mangle]
8936 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
8937 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
8938         let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8939         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() };
8940         local_res
8941 }
8942 #[no_mangle]
8943 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
8944 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
8945         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8946 }
8947 #[no_mangle]
8948 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8949         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
8950 }
8951 #[no_mangle]
8952 /// Read a Shutdown from a byte array, created by Shutdown_write
8953 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
8954         let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8955         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() };
8956         local_res
8957 }
8958 #[no_mangle]
8959 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
8960 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
8961         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8962 }
8963 #[no_mangle]
8964 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8965         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
8966 }
8967 #[no_mangle]
8968 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
8969 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
8970         let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8971         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() };
8972         local_res
8973 }
8974 #[no_mangle]
8975 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
8976 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
8977         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8978 }
8979 #[no_mangle]
8980 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8981         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
8982 }
8983 #[no_mangle]
8984 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
8985 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
8986         let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8987         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() };
8988         local_res
8989 }
8990 #[no_mangle]
8991 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
8992 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
8993         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8994 }
8995 #[no_mangle]
8996 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8997         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
8998 }
8999 #[no_mangle]
9000 /// Read a UpdateFee from a byte array, created by UpdateFee_write
9001 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
9002         let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9003         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() };
9004         local_res
9005 }
9006 #[no_mangle]
9007 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
9008 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
9009         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9010 }
9011 #[no_mangle]
9012 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9013         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
9014 }
9015 #[no_mangle]
9016 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
9017 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
9018         let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9019         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() };
9020         local_res
9021 }
9022 #[no_mangle]
9023 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
9024 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
9025         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9026 }
9027 #[no_mangle]
9028 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9029         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
9030 }
9031 #[no_mangle]
9032 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
9033 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
9034         let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9035         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() };
9036         local_res
9037 }
9038 #[no_mangle]
9039 /// Read a OnionMessage from a byte array, created by OnionMessage_write
9040 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
9041         let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9042         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() };
9043         local_res
9044 }
9045 #[no_mangle]
9046 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
9047 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
9048         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9049 }
9050 #[no_mangle]
9051 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9052         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
9053 }
9054 #[no_mangle]
9055 /// Serialize the Ping object into a byte array which can be read by Ping_read
9056 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
9057         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9058 }
9059 #[no_mangle]
9060 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9061         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
9062 }
9063 #[no_mangle]
9064 /// Read a Ping from a byte array, created by Ping_write
9065 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
9066         let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9067         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() };
9068         local_res
9069 }
9070 #[no_mangle]
9071 /// Serialize the Pong object into a byte array which can be read by Pong_read
9072 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
9073         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9074 }
9075 #[no_mangle]
9076 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9077         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
9078 }
9079 #[no_mangle]
9080 /// Read a Pong from a byte array, created by Pong_write
9081 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
9082         let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9083         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() };
9084         local_res
9085 }
9086 #[no_mangle]
9087 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
9088 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9089         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9090 }
9091 #[no_mangle]
9092 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9093         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
9094 }
9095 #[no_mangle]
9096 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
9097 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
9098         let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9099         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() };
9100         local_res
9101 }
9102 #[no_mangle]
9103 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
9104 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9105         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9106 }
9107 #[no_mangle]
9108 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9109         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
9110 }
9111 #[no_mangle]
9112 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
9113 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
9114         let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9115         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() };
9116         local_res
9117 }
9118 #[no_mangle]
9119 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
9120 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
9121         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9122 }
9123 #[no_mangle]
9124 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9125         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
9126 }
9127 #[no_mangle]
9128 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
9129 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
9130         let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9131         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() };
9132         local_res
9133 }
9134 #[no_mangle]
9135 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
9136 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
9137         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9138 }
9139 #[no_mangle]
9140 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9141         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
9142 }
9143 #[no_mangle]
9144 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
9145 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
9146         let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9147         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() };
9148         local_res
9149 }
9150 #[no_mangle]
9151 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
9152 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
9153         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9154 }
9155 #[no_mangle]
9156 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9157         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
9158 }
9159 #[no_mangle]
9160 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
9161 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
9162         let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9163         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() };
9164         local_res
9165 }
9166 #[no_mangle]
9167 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
9168 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
9169         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9170 }
9171 #[no_mangle]
9172 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9173         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
9174 }
9175 #[no_mangle]
9176 /// Read a WarningMessage from a byte array, created by WarningMessage_write
9177 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
9178         let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9179         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() };
9180         local_res
9181 }
9182 #[no_mangle]
9183 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
9184 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9185         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9186 }
9187 #[no_mangle]
9188 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9189         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
9190 }
9191 #[no_mangle]
9192 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
9193 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
9194         let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9195         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() };
9196         local_res
9197 }
9198 #[no_mangle]
9199 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
9200 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9201         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9202 }
9203 #[no_mangle]
9204 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9205         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
9206 }
9207 #[no_mangle]
9208 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
9209 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
9210         let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9211         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() };
9212         local_res
9213 }
9214 #[no_mangle]
9215 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
9216 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
9217         let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9218         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() };
9219         local_res
9220 }
9221 #[no_mangle]
9222 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
9223 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
9224         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9225 }
9226 #[no_mangle]
9227 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9228         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
9229 }
9230 #[no_mangle]
9231 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
9232 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
9233         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9234 }
9235 #[no_mangle]
9236 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9237         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
9238 }
9239 #[no_mangle]
9240 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
9241 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
9242         let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9243         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() };
9244         local_res
9245 }
9246 /// Calculates the overflow safe ending block height for the query.
9247 ///
9248 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
9249 #[must_use]
9250 #[no_mangle]
9251 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
9252         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
9253         ret
9254 }
9255
9256 #[no_mangle]
9257 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
9258 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
9259         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9260 }
9261 #[no_mangle]
9262 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9263         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
9264 }
9265 #[no_mangle]
9266 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
9267 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
9268         let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9269         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() };
9270         local_res
9271 }
9272 #[no_mangle]
9273 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
9274 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
9275         let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9276         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() };
9277         local_res
9278 }
9279 #[no_mangle]
9280 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
9281 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
9282         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9283 }
9284 #[no_mangle]
9285 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9286         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
9287 }
9288 #[no_mangle]
9289 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
9290 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
9291         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9292 }
9293 #[no_mangle]
9294 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9295         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
9296 }
9297 #[no_mangle]
9298 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
9299 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
9300         let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9301         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() };
9302         local_res
9303 }