1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
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.
9 //! Wire messages, traits representing wire message handlers, and a few error types live here.
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
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.
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};
35 /// An error in decoding a message or struct.
39 pub enum DecodeError {
40 /// A version byte specified something we don't know how to handle.
42 /// Includes unknown realm byte in an onion hop data packet.
44 /// Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type)
45 UnknownRequiredFeature,
46 /// Value was invalid.
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.
52 /// The buffer to be read was too short.
54 /// A length descriptor in the packet didn't describe the later data correctly.
56 /// Error from [`std::io`].
58 crate::c_types::IOError),
59 /// The message included zlib-compressed values, which we don't support.
60 UnsupportedCompression,
62 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
63 pub(crate) type nativeDecodeError = DecodeErrorImport;
67 pub(crate) fn to_native(&self) -> nativeDecodeError {
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(),
80 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
84 pub(crate) fn into_native(self) -> nativeDecodeError {
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 (
96 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
100 pub(crate) fn from_native(native: &DecodeErrorImport) -> Self {
101 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeDecodeError) };
103 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
104 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
105 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
106 nativeDecodeError::ShortRead => DecodeError::ShortRead,
107 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
108 nativeDecodeError::Io (ref a, ) => {
109 let mut a_nonref = Clone::clone(a);
111 crate::c_types::IOError::from_rust_kind(a_nonref),
114 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
118 pub(crate) fn native_into(native: nativeDecodeError) -> Self {
120 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
121 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
122 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
123 nativeDecodeError::ShortRead => DecodeError::ShortRead,
124 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
125 nativeDecodeError::Io (mut a, ) => {
127 crate::c_types::IOError::from_rust_kind(a),
130 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
134 /// Frees any resources used by the DecodeError
136 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
137 /// Creates a copy of the DecodeError
139 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
143 /// Used only if an object of this type is returned as a trait impl by a method
144 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
145 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const DecodeError)).clone() })) as *mut c_void
148 /// Used only if an object of this type is returned as a trait impl by a method
149 pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
150 let _ = unsafe { Box::from_raw(this_ptr as *mut DecodeError) };
153 /// Utility method to constructs a new UnknownVersion-variant DecodeError
154 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
155 DecodeError::UnknownVersion}
157 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
158 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
159 DecodeError::UnknownRequiredFeature}
161 /// Utility method to constructs a new InvalidValue-variant DecodeError
162 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
163 DecodeError::InvalidValue}
165 /// Utility method to constructs a new ShortRead-variant DecodeError
166 pub extern "C" fn DecodeError_short_read() -> DecodeError {
167 DecodeError::ShortRead}
169 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
170 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
171 DecodeError::BadLengthDescriptor}
173 /// Utility method to constructs a new Io-variant DecodeError
174 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
178 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
179 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
180 DecodeError::UnsupportedCompression}
181 /// Get a string which allows debug introspection of a DecodeError object
182 pub extern "C" fn DecodeError_debug_str_void(o: *const c_void) -> Str {
183 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::DecodeError }).into()}
184 /// Generates a non-cryptographic 64-bit hash of the DecodeError.
186 pub extern "C" fn DecodeError_hash(o: &DecodeError) -> u64 {
187 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
189 let mut hasher = core::hash::SipHasher::new();
190 core::hash::Hash::hash(&o.to_native(), &mut hasher);
191 core::hash::Hasher::finish(&hasher)
193 /// Checks if two DecodeErrors contain equal inner contents.
194 /// This ignores pointers and is_owned flags and looks at the values in fields.
196 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
197 if &a.to_native() == &b.to_native() { true } else { false }
200 use lightning::ln::msgs::Init as nativeInitImport;
201 pub(crate) type nativeInit = nativeInitImport;
203 /// An [`init`] message to be sent to or received from a peer.
205 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
209 /// A pointer to the opaque Rust object.
211 /// Nearly everywhere, inner must be non-null, however in places where
212 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
213 pub inner: *mut nativeInit,
214 /// Indicates that this is the only struct which contains the same pointer.
216 /// Rust functions which take ownership of an object provided via an argument require
217 /// this to be true and invalidate the object pointed to by inner.
223 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
224 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
228 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
230 pub extern "C" fn Init_free(this_obj: Init) { }
232 /// Used only if an object of this type is returned as a trait impl by a method
233 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
234 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
238 pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
239 unsafe { &*ObjOps::untweak_ptr(self.inner) }
241 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
242 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
244 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
245 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
246 assert!(self.is_owned);
247 let ret = ObjOps::untweak_ptr(self.inner);
248 self.inner = core::ptr::null_mut();
252 /// The relevant features which the sender supports.
254 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
255 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
256 crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }
258 /// The relevant features which the sender supports.
260 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
261 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
263 /// Indicates chains the sender is interested in.
265 /// If there are no common chains, the connection will be closed.
267 /// Returns a copy of the field.
269 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
270 let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
271 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); }; local_inner_val_0.into() }) };
274 /// Indicates chains the sender is interested in.
276 /// If there are no common chains, the connection will be closed.
278 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ) {
279 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_val_0 }})} };
280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
282 /// The receipient's network address.
284 /// This adds the option to report a remote IP address back to a connecting peer using the init
285 /// message. A node can decide to use that information to discover a potential update to its
286 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
289 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_SocketAddressZ {
290 let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
291 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_SocketAddressZ::None } else { crate::c_types::derived::COption_SocketAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::msgs::SocketAddress::native_into((*inner_val.as_ref().unwrap()).clone()) }) };
294 /// The receipient's network address.
296 /// This adds the option to report a remote IP address back to a connecting peer using the init
297 /// message. A node can decide to use that information to discover a potential update to its
298 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
301 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_SocketAddressZ) {
302 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
303 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
305 /// Constructs a new Init given each field
308 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ, mut remote_network_address_arg: crate::c_types::derived::COption_SocketAddressZ) -> Init {
309 let mut local_networks_arg = { /*networks_arg*/ let networks_arg_opt = networks_arg; if networks_arg_opt.is_none() { None } else { Some({ { let mut local_networks_arg_0 = Vec::new(); for mut item in { networks_arg_opt.take() }.into_rust().drain(..) { local_networks_arg_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_networks_arg_0 }})} };
310 let mut local_remote_network_address_arg = { /*remote_network_address_arg*/ let remote_network_address_arg_opt = remote_network_address_arg; if remote_network_address_arg_opt.is_none() { None } else { Some({ { { remote_network_address_arg_opt.take() }.into_native() }})} };
311 Init { inner: ObjOps::heap_alloc(nativeInit {
312 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
313 networks: local_networks_arg,
314 remote_network_address: local_remote_network_address_arg,
317 impl Clone for Init {
318 fn clone(&self) -> Self {
320 inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
321 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
327 /// Used only if an object of this type is returned as a trait impl by a method
328 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
329 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInit)).clone() })) as *mut c_void
332 /// Creates a copy of the Init
333 pub extern "C" fn Init_clone(orig: &Init) -> Init {
336 /// Get a string which allows debug introspection of a Init object
337 pub extern "C" fn Init_debug_str_void(o: *const c_void) -> Str {
338 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Init }).into()}
339 /// Generates a non-cryptographic 64-bit hash of the Init.
341 pub extern "C" fn Init_hash(o: &Init) -> u64 {
342 if o.inner.is_null() { return 0; }
343 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
345 let mut hasher = core::hash::SipHasher::new();
346 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
347 core::hash::Hasher::finish(&hasher)
349 /// Checks if two Inits contain equal inner contents.
350 /// This ignores pointers and is_owned flags and looks at the values in fields.
351 /// Two objects with NULL inner values will be considered "equal" here.
353 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
354 if a.inner == b.inner { return true; }
355 if a.inner.is_null() || b.inner.is_null() { return false; }
356 if a.get_native_ref() == b.get_native_ref() { true } else { false }
359 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
360 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
362 /// An [`error`] message to be sent to or received from a peer.
364 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
367 pub struct ErrorMessage {
368 /// A pointer to the opaque Rust object.
370 /// Nearly everywhere, inner must be non-null, however in places where
371 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
372 pub inner: *mut nativeErrorMessage,
373 /// Indicates that this is the only struct which contains the same pointer.
375 /// Rust functions which take ownership of an object provided via an argument require
376 /// this to be true and invalidate the object pointed to by inner.
380 impl Drop for ErrorMessage {
382 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
383 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
387 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
389 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
391 /// Used only if an object of this type is returned as a trait impl by a method
392 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
393 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
397 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
398 unsafe { &*ObjOps::untweak_ptr(self.inner) }
400 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
401 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
403 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
404 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
405 assert!(self.is_owned);
406 let ret = ObjOps::untweak_ptr(self.inner);
407 self.inner = core::ptr::null_mut();
411 /// The channel ID involved in the error.
413 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
414 /// with the sending peer should be closed.
416 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
417 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
420 /// The channel ID involved in the error.
422 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
423 /// with the sending peer should be closed.
425 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
426 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
428 /// A possibly human-readable error description.
430 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
431 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
432 /// the terminal emulator or the logging subsystem.
434 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
435 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
436 inner_val.as_str().into()
438 /// A possibly human-readable error description.
440 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
441 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
442 /// the terminal emulator or the logging subsystem.
444 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
445 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
447 /// Constructs a new ErrorMessage given each field
450 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
451 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
452 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
453 data: data_arg.into_string(),
456 impl Clone for ErrorMessage {
457 fn clone(&self) -> Self {
459 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
460 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
466 /// Used only if an object of this type is returned as a trait impl by a method
467 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
468 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeErrorMessage)).clone() })) as *mut c_void
471 /// Creates a copy of the ErrorMessage
472 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
475 /// Get a string which allows debug introspection of a ErrorMessage object
476 pub extern "C" fn ErrorMessage_debug_str_void(o: *const c_void) -> Str {
477 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorMessage }).into()}
478 /// Generates a non-cryptographic 64-bit hash of the ErrorMessage.
480 pub extern "C" fn ErrorMessage_hash(o: &ErrorMessage) -> u64 {
481 if o.inner.is_null() { return 0; }
482 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
484 let mut hasher = core::hash::SipHasher::new();
485 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
486 core::hash::Hasher::finish(&hasher)
488 /// Checks if two ErrorMessages contain equal inner contents.
489 /// This ignores pointers and is_owned flags and looks at the values in fields.
490 /// Two objects with NULL inner values will be considered "equal" here.
492 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
493 if a.inner == b.inner { return true; }
494 if a.inner.is_null() || b.inner.is_null() { return false; }
495 if a.get_native_ref() == b.get_native_ref() { true } else { false }
498 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
499 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
501 /// A [`warning`] message to be sent to or received from a peer.
503 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
506 pub struct WarningMessage {
507 /// A pointer to the opaque Rust object.
509 /// Nearly everywhere, inner must be non-null, however in places where
510 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
511 pub inner: *mut nativeWarningMessage,
512 /// Indicates that this is the only struct which contains the same pointer.
514 /// Rust functions which take ownership of an object provided via an argument require
515 /// this to be true and invalidate the object pointed to by inner.
519 impl Drop for WarningMessage {
521 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
522 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
526 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
528 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
530 /// Used only if an object of this type is returned as a trait impl by a method
531 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
532 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
535 impl WarningMessage {
536 pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
537 unsafe { &*ObjOps::untweak_ptr(self.inner) }
539 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
540 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
542 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
543 pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
544 assert!(self.is_owned);
545 let ret = ObjOps::untweak_ptr(self.inner);
546 self.inner = core::ptr::null_mut();
550 /// The channel ID involved in the warning.
552 /// All-0s indicates a warning unrelated to a specific channel.
554 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
555 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
558 /// The channel ID involved in the warning.
560 /// All-0s indicates a warning unrelated to a specific channel.
562 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
563 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
565 /// A possibly human-readable warning description.
567 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
568 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
569 /// the terminal emulator or the logging subsystem.
571 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
572 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
573 inner_val.as_str().into()
575 /// A possibly human-readable warning description.
577 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
578 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
579 /// the terminal emulator or the logging subsystem.
581 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
582 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
584 /// Constructs a new WarningMessage given each field
587 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
588 WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
589 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
590 data: data_arg.into_string(),
593 impl Clone for WarningMessage {
594 fn clone(&self) -> Self {
596 inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
597 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
603 /// Used only if an object of this type is returned as a trait impl by a method
604 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
605 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeWarningMessage)).clone() })) as *mut c_void
608 /// Creates a copy of the WarningMessage
609 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
612 /// Get a string which allows debug introspection of a WarningMessage object
613 pub extern "C" fn WarningMessage_debug_str_void(o: *const c_void) -> Str {
614 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::WarningMessage }).into()}
615 /// Generates a non-cryptographic 64-bit hash of the WarningMessage.
617 pub extern "C" fn WarningMessage_hash(o: &WarningMessage) -> u64 {
618 if o.inner.is_null() { return 0; }
619 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
621 let mut hasher = core::hash::SipHasher::new();
622 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
623 core::hash::Hasher::finish(&hasher)
625 /// Checks if two WarningMessages contain equal inner contents.
626 /// This ignores pointers and is_owned flags and looks at the values in fields.
627 /// Two objects with NULL inner values will be considered "equal" here.
629 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
630 if a.inner == b.inner { return true; }
631 if a.inner.is_null() || b.inner.is_null() { return false; }
632 if a.get_native_ref() == b.get_native_ref() { true } else { false }
635 use lightning::ln::msgs::Ping as nativePingImport;
636 pub(crate) type nativePing = nativePingImport;
638 /// A [`ping`] message to be sent to or received from a peer.
640 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
644 /// A pointer to the opaque Rust object.
646 /// Nearly everywhere, inner must be non-null, however in places where
647 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
648 pub inner: *mut nativePing,
649 /// Indicates that this is the only struct which contains the same pointer.
651 /// Rust functions which take ownership of an object provided via an argument require
652 /// this to be true and invalidate the object pointed to by inner.
658 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
659 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
663 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
665 pub extern "C" fn Ping_free(this_obj: Ping) { }
667 /// Used only if an object of this type is returned as a trait impl by a method
668 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
669 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
673 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
674 unsafe { &*ObjOps::untweak_ptr(self.inner) }
676 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
677 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
679 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
680 pub(crate) fn take_inner(mut self) -> *mut nativePing {
681 assert!(self.is_owned);
682 let ret = ObjOps::untweak_ptr(self.inner);
683 self.inner = core::ptr::null_mut();
687 /// The desired response length.
689 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
690 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
693 /// The desired response length.
695 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
696 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
698 /// The ping packet size.
700 /// This field is not sent on the wire. byteslen zeros are sent.
702 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
703 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
706 /// The ping packet size.
708 /// This field is not sent on the wire. byteslen zeros are sent.
710 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
711 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
713 /// Constructs a new Ping given each field
716 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
717 Ping { inner: ObjOps::heap_alloc(nativePing {
718 ponglen: ponglen_arg,
719 byteslen: byteslen_arg,
722 impl Clone for Ping {
723 fn clone(&self) -> Self {
725 inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
726 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
732 /// Used only if an object of this type is returned as a trait impl by a method
733 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
734 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePing)).clone() })) as *mut c_void
737 /// Creates a copy of the Ping
738 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
741 /// Get a string which allows debug introspection of a Ping object
742 pub extern "C" fn Ping_debug_str_void(o: *const c_void) -> Str {
743 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Ping }).into()}
744 /// Generates a non-cryptographic 64-bit hash of the Ping.
746 pub extern "C" fn Ping_hash(o: &Ping) -> u64 {
747 if o.inner.is_null() { return 0; }
748 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
750 let mut hasher = core::hash::SipHasher::new();
751 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
752 core::hash::Hasher::finish(&hasher)
754 /// Checks if two Pings contain equal inner contents.
755 /// This ignores pointers and is_owned flags and looks at the values in fields.
756 /// Two objects with NULL inner values will be considered "equal" here.
758 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
759 if a.inner == b.inner { return true; }
760 if a.inner.is_null() || b.inner.is_null() { return false; }
761 if a.get_native_ref() == b.get_native_ref() { true } else { false }
764 use lightning::ln::msgs::Pong as nativePongImport;
765 pub(crate) type nativePong = nativePongImport;
767 /// A [`pong`] message to be sent to or received from a peer.
769 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
773 /// A pointer to the opaque Rust object.
775 /// Nearly everywhere, inner must be non-null, however in places where
776 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
777 pub inner: *mut nativePong,
778 /// Indicates that this is the only struct which contains the same pointer.
780 /// Rust functions which take ownership of an object provided via an argument require
781 /// this to be true and invalidate the object pointed to by inner.
787 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
788 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
792 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
794 pub extern "C" fn Pong_free(this_obj: Pong) { }
796 /// Used only if an object of this type is returned as a trait impl by a method
797 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
798 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
802 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
803 unsafe { &*ObjOps::untweak_ptr(self.inner) }
805 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
806 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
808 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
809 pub(crate) fn take_inner(mut self) -> *mut nativePong {
810 assert!(self.is_owned);
811 let ret = ObjOps::untweak_ptr(self.inner);
812 self.inner = core::ptr::null_mut();
816 /// The pong packet size.
818 /// This field is not sent on the wire. byteslen zeros are sent.
820 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
821 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
824 /// The pong packet size.
826 /// This field is not sent on the wire. byteslen zeros are sent.
828 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
829 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
831 /// Constructs a new Pong given each field
834 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
835 Pong { inner: ObjOps::heap_alloc(nativePong {
836 byteslen: byteslen_arg,
839 impl Clone for Pong {
840 fn clone(&self) -> Self {
842 inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
843 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
849 /// Used only if an object of this type is returned as a trait impl by a method
850 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
851 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePong)).clone() })) as *mut c_void
854 /// Creates a copy of the Pong
855 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
858 /// Get a string which allows debug introspection of a Pong object
859 pub extern "C" fn Pong_debug_str_void(o: *const c_void) -> Str {
860 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Pong }).into()}
861 /// Generates a non-cryptographic 64-bit hash of the Pong.
863 pub extern "C" fn Pong_hash(o: &Pong) -> u64 {
864 if o.inner.is_null() { return 0; }
865 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
867 let mut hasher = core::hash::SipHasher::new();
868 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
869 core::hash::Hasher::finish(&hasher)
871 /// Checks if two Pongs contain equal inner contents.
872 /// This ignores pointers and is_owned flags and looks at the values in fields.
873 /// Two objects with NULL inner values will be considered "equal" here.
875 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
876 if a.inner == b.inner { return true; }
877 if a.inner.is_null() || b.inner.is_null() { return false; }
878 if a.get_native_ref() == b.get_native_ref() { true } else { false }
881 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
882 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
884 /// An [`open_channel`] message to be sent to or received from a peer.
886 /// Used in V1 channel establishment
888 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
891 pub struct OpenChannel {
892 /// A pointer to the opaque Rust object.
894 /// Nearly everywhere, inner must be non-null, however in places where
895 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
896 pub inner: *mut nativeOpenChannel,
897 /// Indicates that this is the only struct which contains the same pointer.
899 /// Rust functions which take ownership of an object provided via an argument require
900 /// this to be true and invalidate the object pointed to by inner.
904 impl Drop for OpenChannel {
906 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
907 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
911 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
913 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
915 /// Used only if an object of this type is returned as a trait impl by a method
916 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
917 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
921 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
922 unsafe { &*ObjOps::untweak_ptr(self.inner) }
924 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
925 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
927 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
928 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
929 assert!(self.is_owned);
930 let ret = ObjOps::untweak_ptr(self.inner);
931 self.inner = core::ptr::null_mut();
935 /// The genesis hash of the blockchain where the channel is to be opened
937 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
938 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
941 /// The genesis hash of the blockchain where the channel is to be opened
943 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
944 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
946 /// A temporary channel ID, until the funding outpoint is announced
948 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
949 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
952 /// A temporary channel ID, until the funding outpoint is announced
954 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
955 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
957 /// The channel value
959 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
960 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
963 /// The channel value
965 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
966 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
968 /// The amount to push to the counterparty as part of the open, in milli-satoshi
970 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
971 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
974 /// The amount to push to the counterparty as part of the open, in milli-satoshi
976 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
977 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
979 /// The threshold below which outputs on transactions broadcast by sender will be omitted
981 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
982 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
985 /// The threshold below which outputs on transactions broadcast by sender will be omitted
987 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
988 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
990 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
992 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
993 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
996 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
998 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
999 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1001 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1003 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
1004 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1007 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1009 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
1010 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1012 /// The minimum HTLC size incoming to sender, in milli-satoshi
1014 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
1015 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1018 /// The minimum HTLC size incoming to sender, in milli-satoshi
1020 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
1021 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1023 /// The feerate per 1000-weight of sender generated transactions, until updated by
1026 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
1027 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
1030 /// The feerate per 1000-weight of sender generated transactions, until updated by
1033 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
1034 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
1036 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
1037 /// they broadcast a commitment transaction
1039 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
1040 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1043 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
1044 /// they broadcast a commitment transaction
1046 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
1047 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1049 /// The maximum number of inbound HTLCs towards sender
1051 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
1052 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1055 /// The maximum number of inbound HTLCs towards sender
1057 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
1058 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1060 /// The sender's key controlling the funding transaction
1062 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1063 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1064 crate::c_types::PublicKey::from_rust(&inner_val)
1066 /// The sender's key controlling the funding transaction
1068 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1069 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1071 /// Used to derive a revocation key for transactions broadcast by counterparty
1073 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1074 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1075 crate::c_types::PublicKey::from_rust(&inner_val)
1077 /// Used to derive a revocation key for transactions broadcast by counterparty
1079 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1080 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1082 /// A payment key to sender for transactions broadcast by counterparty
1084 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1085 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1086 crate::c_types::PublicKey::from_rust(&inner_val)
1088 /// A payment key to sender for transactions broadcast by counterparty
1090 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1091 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1093 /// Used to derive a payment key to sender for transactions broadcast by sender
1095 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1096 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1097 crate::c_types::PublicKey::from_rust(&inner_val)
1099 /// Used to derive a payment key to sender for transactions broadcast by sender
1101 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1102 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1104 /// Used to derive an HTLC payment key to sender
1106 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1107 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1108 crate::c_types::PublicKey::from_rust(&inner_val)
1110 /// Used to derive an HTLC payment key to sender
1112 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1113 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1115 /// The first to-be-broadcast-by-sender transaction's per commitment point
1117 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1118 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1119 crate::c_types::PublicKey::from_rust(&inner_val)
1121 /// The first to-be-broadcast-by-sender transaction's per commitment point
1123 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1124 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1126 /// The channel flags to be used
1128 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
1129 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1132 /// The channel flags to be used
1134 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
1135 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1137 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1139 pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1140 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1141 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) };
1144 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1146 pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1147 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
1148 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1150 /// The channel type that this channel will represent
1152 /// If this is `None`, we derive the channel type from the intersection of our
1153 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1155 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1157 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1158 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1159 let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1162 /// The channel type that this channel will represent
1164 /// If this is `None`, we derive the channel type from the intersection of our
1165 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1167 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1169 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1170 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1171 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1173 /// Constructs a new OpenChannel given each field
1175 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1178 pub extern "C" fn OpenChannel_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut push_msat_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut feerate_per_kw_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> OpenChannel {
1179 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1180 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1181 OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1182 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
1183 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1184 funding_satoshis: funding_satoshis_arg,
1185 push_msat: push_msat_arg,
1186 dust_limit_satoshis: dust_limit_satoshis_arg,
1187 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1188 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1189 htlc_minimum_msat: htlc_minimum_msat_arg,
1190 feerate_per_kw: feerate_per_kw_arg,
1191 to_self_delay: to_self_delay_arg,
1192 max_accepted_htlcs: max_accepted_htlcs_arg,
1193 funding_pubkey: funding_pubkey_arg.into_rust(),
1194 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1195 payment_point: payment_point_arg.into_rust(),
1196 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1197 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1198 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1199 channel_flags: channel_flags_arg,
1200 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1201 channel_type: local_channel_type_arg,
1202 }), is_owned: true }
1204 impl Clone for OpenChannel {
1205 fn clone(&self) -> Self {
1207 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1208 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1214 /// Used only if an object of this type is returned as a trait impl by a method
1215 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1216 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannel)).clone() })) as *mut c_void
1219 /// Creates a copy of the OpenChannel
1220 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1223 /// Get a string which allows debug introspection of a OpenChannel object
1224 pub extern "C" fn OpenChannel_debug_str_void(o: *const c_void) -> Str {
1225 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannel }).into()}
1226 /// Generates a non-cryptographic 64-bit hash of the OpenChannel.
1228 pub extern "C" fn OpenChannel_hash(o: &OpenChannel) -> u64 {
1229 if o.inner.is_null() { return 0; }
1230 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1231 #[allow(deprecated)]
1232 let mut hasher = core::hash::SipHasher::new();
1233 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1234 core::hash::Hasher::finish(&hasher)
1236 /// Checks if two OpenChannels contain equal inner contents.
1237 /// This ignores pointers and is_owned flags and looks at the values in fields.
1238 /// Two objects with NULL inner values will be considered "equal" here.
1240 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1241 if a.inner == b.inner { return true; }
1242 if a.inner.is_null() || b.inner.is_null() { return false; }
1243 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1246 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1247 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1249 /// An open_channel2 message to be sent by or received from the channel initiator.
1251 /// Used in V2 channel establishment
1255 pub struct OpenChannelV2 {
1256 /// A pointer to the opaque Rust object.
1258 /// Nearly everywhere, inner must be non-null, however in places where
1259 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1260 pub inner: *mut nativeOpenChannelV2,
1261 /// Indicates that this is the only struct which contains the same pointer.
1263 /// Rust functions which take ownership of an object provided via an argument require
1264 /// this to be true and invalidate the object pointed to by inner.
1268 impl Drop for OpenChannelV2 {
1269 fn drop(&mut self) {
1270 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1271 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1275 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1277 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1279 /// Used only if an object of this type is returned as a trait impl by a method
1280 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1281 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1284 impl OpenChannelV2 {
1285 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1286 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1288 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1289 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1291 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1292 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1293 assert!(self.is_owned);
1294 let ret = ObjOps::untweak_ptr(self.inner);
1295 self.inner = core::ptr::null_mut();
1299 /// The genesis hash of the blockchain where the channel is to be opened
1301 pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1302 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
1305 /// The genesis hash of the blockchain where the channel is to be opened
1307 pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1308 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
1310 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1312 pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1313 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1316 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1318 pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1319 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1321 /// The feerate for the funding transaction set by the channel initiator
1323 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1324 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1327 /// The feerate for the funding transaction set by the channel initiator
1329 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1330 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1332 /// The feerate for the commitment transaction set by the channel initiator
1334 pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1335 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1338 /// The feerate for the commitment transaction set by the channel initiator
1340 pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1341 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1343 /// Part of the channel value contributed by the channel initiator
1345 pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1346 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1349 /// Part of the channel value contributed by the channel initiator
1351 pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1352 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1354 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1357 pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1358 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1361 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1364 pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1365 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1367 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1369 pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 {
1370 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1373 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1375 pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1376 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1378 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1380 pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 {
1381 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1384 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1386 pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1387 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1389 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1390 /// broadcast a commitment transaction
1392 pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 {
1393 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1396 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1397 /// broadcast a commitment transaction
1399 pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) {
1400 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1402 /// The maximum number of inbound HTLCs towards channel initiator
1404 pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 {
1405 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1408 /// The maximum number of inbound HTLCs towards channel initiator
1410 pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) {
1411 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1413 /// The locktime for the funding transaction
1415 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1416 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1419 /// The locktime for the funding transaction
1421 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1422 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1424 /// The channel initiator's key controlling the funding transaction
1426 pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1427 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1428 crate::c_types::PublicKey::from_rust(&inner_val)
1430 /// The channel initiator's key controlling the funding transaction
1432 pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1433 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1435 /// Used to derive a revocation key for transactions broadcast by counterparty
1437 pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1438 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1439 crate::c_types::PublicKey::from_rust(&inner_val)
1441 /// Used to derive a revocation key for transactions broadcast by counterparty
1443 pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1444 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1446 /// A payment key to channel initiator for transactions broadcast by counterparty
1448 pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1449 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1450 crate::c_types::PublicKey::from_rust(&inner_val)
1452 /// A payment key to channel initiator for transactions broadcast by counterparty
1454 pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1455 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1457 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1460 pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1461 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1462 crate::c_types::PublicKey::from_rust(&inner_val)
1464 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1467 pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1468 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1470 /// Used to derive an HTLC payment key to channel initiator
1472 pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1473 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1474 crate::c_types::PublicKey::from_rust(&inner_val)
1476 /// Used to derive an HTLC payment key to channel initiator
1478 pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1479 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1481 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1483 pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1484 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1485 crate::c_types::PublicKey::from_rust(&inner_val)
1487 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1489 pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1490 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1492 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1494 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1495 let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1496 crate::c_types::PublicKey::from_rust(&inner_val)
1498 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1500 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1501 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1505 pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 {
1506 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1511 pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) {
1512 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1514 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1515 /// collaboratively close
1517 pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
1518 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1519 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) };
1522 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1523 /// collaboratively close
1525 pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1526 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
1527 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1529 /// The channel type that this channel will represent. If none is set, we derive the channel
1530 /// type from the intersection of our feature bits with our counterparty's feature bits from
1531 /// the Init message.
1533 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1535 pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
1536 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1537 let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1540 /// The channel type that this channel will represent. If none is set, we derive the channel
1541 /// type from the intersection of our feature bits with our counterparty's feature bits from
1542 /// the Init message.
1544 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1546 pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1547 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1548 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1550 /// Optionally, a requirement that only confirmed inputs can be added
1552 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1553 let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1554 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ };
1557 /// Optionally, a requirement that only confirmed inputs can be added
1559 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1560 let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1561 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1563 /// Constructs a new OpenChannelV2 given each field
1565 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1568 pub extern "C" fn OpenChannelV2_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_feerate_sat_per_1000_weight_arg: u32, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 {
1569 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1570 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1571 let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1572 OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1573 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
1574 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1575 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1576 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1577 funding_satoshis: funding_satoshis_arg,
1578 dust_limit_satoshis: dust_limit_satoshis_arg,
1579 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1580 htlc_minimum_msat: htlc_minimum_msat_arg,
1581 to_self_delay: to_self_delay_arg,
1582 max_accepted_htlcs: max_accepted_htlcs_arg,
1583 locktime: locktime_arg,
1584 funding_pubkey: funding_pubkey_arg.into_rust(),
1585 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1586 payment_basepoint: payment_basepoint_arg.into_rust(),
1587 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1588 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1589 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1590 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1591 channel_flags: channel_flags_arg,
1592 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1593 channel_type: local_channel_type_arg,
1594 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1595 }), is_owned: true }
1597 impl Clone for OpenChannelV2 {
1598 fn clone(&self) -> Self {
1600 inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1601 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1607 /// Used only if an object of this type is returned as a trait impl by a method
1608 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1609 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannelV2)).clone() })) as *mut c_void
1612 /// Creates a copy of the OpenChannelV2
1613 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1616 /// Get a string which allows debug introspection of a OpenChannelV2 object
1617 pub extern "C" fn OpenChannelV2_debug_str_void(o: *const c_void) -> Str {
1618 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannelV2 }).into()}
1619 /// Generates a non-cryptographic 64-bit hash of the OpenChannelV2.
1621 pub extern "C" fn OpenChannelV2_hash(o: &OpenChannelV2) -> u64 {
1622 if o.inner.is_null() { return 0; }
1623 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1624 #[allow(deprecated)]
1625 let mut hasher = core::hash::SipHasher::new();
1626 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1627 core::hash::Hasher::finish(&hasher)
1629 /// Checks if two OpenChannelV2s contain equal inner contents.
1630 /// This ignores pointers and is_owned flags and looks at the values in fields.
1631 /// Two objects with NULL inner values will be considered "equal" here.
1633 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1634 if a.inner == b.inner { return true; }
1635 if a.inner.is_null() || b.inner.is_null() { return false; }
1636 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1639 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1640 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1642 /// An [`accept_channel`] message to be sent to or received from a peer.
1644 /// Used in V1 channel establishment
1646 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1649 pub struct AcceptChannel {
1650 /// A pointer to the opaque Rust object.
1652 /// Nearly everywhere, inner must be non-null, however in places where
1653 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1654 pub inner: *mut nativeAcceptChannel,
1655 /// Indicates that this is the only struct which contains the same pointer.
1657 /// Rust functions which take ownership of an object provided via an argument require
1658 /// this to be true and invalidate the object pointed to by inner.
1662 impl Drop for AcceptChannel {
1663 fn drop(&mut self) {
1664 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1665 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1669 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1671 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1673 /// Used only if an object of this type is returned as a trait impl by a method
1674 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1675 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1678 impl AcceptChannel {
1679 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1680 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1682 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1683 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1685 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1686 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1687 assert!(self.is_owned);
1688 let ret = ObjOps::untweak_ptr(self.inner);
1689 self.inner = core::ptr::null_mut();
1693 /// A temporary channel ID, until the funding outpoint is announced
1695 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1696 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1699 /// A temporary channel ID, until the funding outpoint is announced
1701 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1702 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1704 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1706 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1707 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1710 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1712 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1713 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1715 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1717 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1718 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1721 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1723 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1724 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1726 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1728 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1729 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1732 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1734 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1735 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1737 /// The minimum HTLC size incoming to sender, in milli-satoshi
1739 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1740 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1743 /// The minimum HTLC size incoming to sender, in milli-satoshi
1745 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1746 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1748 /// Minimum depth of the funding transaction before the channel is considered open
1750 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1751 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1754 /// Minimum depth of the funding transaction before the channel is considered open
1756 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1757 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1759 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1761 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1762 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1765 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1767 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1768 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1770 /// The maximum number of inbound HTLCs towards sender
1772 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1773 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1776 /// The maximum number of inbound HTLCs towards sender
1778 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1779 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1781 /// The sender's key controlling the funding transaction
1783 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1784 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1785 crate::c_types::PublicKey::from_rust(&inner_val)
1787 /// The sender's key controlling the funding transaction
1789 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1790 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1792 /// Used to derive a revocation key for transactions broadcast by counterparty
1794 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1795 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1796 crate::c_types::PublicKey::from_rust(&inner_val)
1798 /// Used to derive a revocation key for transactions broadcast by counterparty
1800 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1801 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1803 /// A payment key to sender for transactions broadcast by counterparty
1805 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1806 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1807 crate::c_types::PublicKey::from_rust(&inner_val)
1809 /// A payment key to sender for transactions broadcast by counterparty
1811 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1812 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1814 /// Used to derive a payment key to sender for transactions broadcast by sender
1816 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1817 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1818 crate::c_types::PublicKey::from_rust(&inner_val)
1820 /// Used to derive a payment key to sender for transactions broadcast by sender
1822 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1823 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1825 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1827 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1828 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1829 crate::c_types::PublicKey::from_rust(&inner_val)
1831 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1833 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1834 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1836 /// The first to-be-broadcast-by-sender transaction's per commitment point
1838 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1839 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1840 crate::c_types::PublicKey::from_rust(&inner_val)
1842 /// The first to-be-broadcast-by-sender transaction's per commitment point
1844 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1845 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1847 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1849 pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1850 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1851 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) };
1854 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1856 pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1857 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
1858 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1860 /// The channel type that this channel will represent.
1862 /// If this is `None`, we derive the channel type from the intersection of
1863 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1864 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1866 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1868 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1869 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1870 let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1873 /// The channel type that this channel will represent.
1875 /// If this is `None`, we derive the channel type from the intersection of
1876 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1877 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1879 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1881 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1882 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1883 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1885 /// Constructs a new AcceptChannel given each field
1887 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1890 pub extern "C" fn AcceptChannel_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> AcceptChannel {
1891 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1892 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1893 AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1894 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1895 dust_limit_satoshis: dust_limit_satoshis_arg,
1896 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1897 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1898 htlc_minimum_msat: htlc_minimum_msat_arg,
1899 minimum_depth: minimum_depth_arg,
1900 to_self_delay: to_self_delay_arg,
1901 max_accepted_htlcs: max_accepted_htlcs_arg,
1902 funding_pubkey: funding_pubkey_arg.into_rust(),
1903 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1904 payment_point: payment_point_arg.into_rust(),
1905 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1906 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1907 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1908 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1909 channel_type: local_channel_type_arg,
1910 }), is_owned: true }
1912 impl Clone for AcceptChannel {
1913 fn clone(&self) -> Self {
1915 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1916 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1922 /// Used only if an object of this type is returned as a trait impl by a method
1923 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1924 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannel)).clone() })) as *mut c_void
1927 /// Creates a copy of the AcceptChannel
1928 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1931 /// Get a string which allows debug introspection of a AcceptChannel object
1932 pub extern "C" fn AcceptChannel_debug_str_void(o: *const c_void) -> Str {
1933 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AcceptChannel }).into()}
1934 /// Generates a non-cryptographic 64-bit hash of the AcceptChannel.
1936 pub extern "C" fn AcceptChannel_hash(o: &AcceptChannel) -> u64 {
1937 if o.inner.is_null() { return 0; }
1938 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1939 #[allow(deprecated)]
1940 let mut hasher = core::hash::SipHasher::new();
1941 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1942 core::hash::Hasher::finish(&hasher)
1944 /// Checks if two AcceptChannels contain equal inner contents.
1945 /// This ignores pointers and is_owned flags and looks at the values in fields.
1946 /// Two objects with NULL inner values will be considered "equal" here.
1948 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1949 if a.inner == b.inner { return true; }
1950 if a.inner.is_null() || b.inner.is_null() { return false; }
1951 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1954 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1955 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1957 /// An accept_channel2 message to be sent by or received from the channel accepter.
1959 /// Used in V2 channel establishment
1963 pub struct AcceptChannelV2 {
1964 /// A pointer to the opaque Rust object.
1966 /// Nearly everywhere, inner must be non-null, however in places where
1967 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1968 pub inner: *mut nativeAcceptChannelV2,
1969 /// Indicates that this is the only struct which contains the same pointer.
1971 /// Rust functions which take ownership of an object provided via an argument require
1972 /// this to be true and invalidate the object pointed to by inner.
1976 impl Drop for AcceptChannelV2 {
1977 fn drop(&mut self) {
1978 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
1979 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1983 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
1985 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
1987 /// Used only if an object of this type is returned as a trait impl by a method
1988 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
1989 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
1992 impl AcceptChannelV2 {
1993 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
1994 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1996 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
1997 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1999 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2000 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
2001 assert!(self.is_owned);
2002 let ret = ObjOps::untweak_ptr(self.inner);
2003 self.inner = core::ptr::null_mut();
2007 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
2009 pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] {
2010 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2013 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
2015 pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
2016 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
2018 /// Part of the channel value contributed by the channel acceptor
2020 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
2021 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
2024 /// Part of the channel value contributed by the channel acceptor
2026 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2027 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
2029 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
2032 pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
2033 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
2036 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
2039 pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2040 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
2042 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
2044 pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 {
2045 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
2048 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
2050 pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2051 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
2053 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
2055 pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 {
2056 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
2059 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
2061 pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2062 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
2064 /// Minimum depth of the funding transaction before the channel is considered open
2066 pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 {
2067 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
2070 /// Minimum depth of the funding transaction before the channel is considered open
2072 pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) {
2073 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
2075 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
2076 /// broadcast a commitment transaction
2078 pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 {
2079 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
2082 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
2083 /// broadcast a commitment transaction
2085 pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) {
2086 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
2088 /// The maximum number of inbound HTLCs towards channel acceptor
2090 pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 {
2091 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
2094 /// The maximum number of inbound HTLCs towards channel acceptor
2096 pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) {
2097 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
2099 /// The channel acceptor's key controlling the funding transaction
2101 pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2102 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
2103 crate::c_types::PublicKey::from_rust(&inner_val)
2105 /// The channel acceptor's key controlling the funding transaction
2107 pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2108 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
2110 /// Used to derive a revocation key for transactions broadcast by counterparty
2112 pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2113 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
2114 crate::c_types::PublicKey::from_rust(&inner_val)
2116 /// Used to derive a revocation key for transactions broadcast by counterparty
2118 pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2119 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
2121 /// A payment key to channel acceptor for transactions broadcast by counterparty
2123 pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2124 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
2125 crate::c_types::PublicKey::from_rust(&inner_val)
2127 /// A payment key to channel acceptor for transactions broadcast by counterparty
2129 pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2130 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
2132 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2135 pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2136 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
2137 crate::c_types::PublicKey::from_rust(&inner_val)
2139 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2142 pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2143 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
2145 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2147 pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2148 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
2149 crate::c_types::PublicKey::from_rust(&inner_val)
2151 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2153 pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2154 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
2156 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2158 pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2159 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
2160 crate::c_types::PublicKey::from_rust(&inner_val)
2162 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2164 pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2165 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
2167 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2169 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2170 let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2171 crate::c_types::PublicKey::from_rust(&inner_val)
2173 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2175 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2176 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2178 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2179 /// collaboratively close
2181 pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
2182 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
2183 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) };
2186 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2187 /// collaboratively close
2189 pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
2190 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
2191 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
2193 /// The channel type that this channel will represent. If none is set, we derive the channel
2194 /// type from the intersection of our feature bits with our counterparty's feature bits from
2195 /// the Init message.
2197 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2199 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2201 pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
2202 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
2203 let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
2206 /// The channel type that this channel will represent. If none is set, we derive the channel
2207 /// type from the intersection of our feature bits with our counterparty's feature bits from
2208 /// the Init message.
2210 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2212 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
2214 pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
2215 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2216 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
2218 /// Optionally, a requirement that only confirmed inputs can be added
2220 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2221 let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2222 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ };
2225 /// Optionally, a requirement that only confirmed inputs can be added
2227 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2228 let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2229 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2231 /// Constructs a new AcceptChannelV2 given each field
2233 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
2236 pub extern "C" fn AcceptChannelV2_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 {
2237 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
2238 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
2239 let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2240 AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2241 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2242 funding_satoshis: funding_satoshis_arg,
2243 dust_limit_satoshis: dust_limit_satoshis_arg,
2244 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
2245 htlc_minimum_msat: htlc_minimum_msat_arg,
2246 minimum_depth: minimum_depth_arg,
2247 to_self_delay: to_self_delay_arg,
2248 max_accepted_htlcs: max_accepted_htlcs_arg,
2249 funding_pubkey: funding_pubkey_arg.into_rust(),
2250 revocation_basepoint: revocation_basepoint_arg.into_rust(),
2251 payment_basepoint: payment_basepoint_arg.into_rust(),
2252 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
2253 htlc_basepoint: htlc_basepoint_arg.into_rust(),
2254 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
2255 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2256 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
2257 channel_type: local_channel_type_arg,
2258 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2259 }), is_owned: true }
2261 impl Clone for AcceptChannelV2 {
2262 fn clone(&self) -> Self {
2264 inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2265 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2271 /// Used only if an object of this type is returned as a trait impl by a method
2272 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2273 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannelV2)).clone() })) as *mut c_void
2276 /// Creates a copy of the AcceptChannelV2
2277 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2280 /// Get a string which allows debug introspection of a AcceptChannelV2 object
2281 pub extern "C" fn AcceptChannelV2_debug_str_void(o: *const c_void) -> Str {
2282 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AcceptChannelV2 }).into()}
2283 /// Generates a non-cryptographic 64-bit hash of the AcceptChannelV2.
2285 pub extern "C" fn AcceptChannelV2_hash(o: &AcceptChannelV2) -> u64 {
2286 if o.inner.is_null() { return 0; }
2287 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2288 #[allow(deprecated)]
2289 let mut hasher = core::hash::SipHasher::new();
2290 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2291 core::hash::Hasher::finish(&hasher)
2293 /// Checks if two AcceptChannelV2s contain equal inner contents.
2294 /// This ignores pointers and is_owned flags and looks at the values in fields.
2295 /// Two objects with NULL inner values will be considered "equal" here.
2297 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2298 if a.inner == b.inner { return true; }
2299 if a.inner.is_null() || b.inner.is_null() { return false; }
2300 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2303 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2304 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2306 /// A [`funding_created`] message to be sent to or received from a peer.
2308 /// Used in V1 channel establishment
2310 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2313 pub struct FundingCreated {
2314 /// A pointer to the opaque Rust object.
2316 /// Nearly everywhere, inner must be non-null, however in places where
2317 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2318 pub inner: *mut nativeFundingCreated,
2319 /// Indicates that this is the only struct which contains the same pointer.
2321 /// Rust functions which take ownership of an object provided via an argument require
2322 /// this to be true and invalidate the object pointed to by inner.
2326 impl Drop for FundingCreated {
2327 fn drop(&mut self) {
2328 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2329 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2333 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2335 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2337 /// Used only if an object of this type is returned as a trait impl by a method
2338 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2339 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2342 impl FundingCreated {
2343 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2344 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2346 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2347 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2349 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2350 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2351 assert!(self.is_owned);
2352 let ret = ObjOps::untweak_ptr(self.inner);
2353 self.inner = core::ptr::null_mut();
2357 /// A temporary channel ID, until the funding is established
2359 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
2360 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2363 /// A temporary channel ID, until the funding is established
2365 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2366 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
2368 /// The funding transaction ID
2370 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2371 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2374 /// The funding transaction ID
2376 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2377 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2379 /// The specific output index funding this channel
2381 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2382 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2385 /// The specific output index funding this channel
2387 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2388 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2390 /// The signature of the channel initiator (funder) on the initial commitment transaction
2392 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::ECDSASignature {
2393 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2394 crate::c_types::ECDSASignature::from_rust(&inner_val)
2396 /// The signature of the channel initiator (funder) on the initial commitment transaction
2398 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::ECDSASignature) {
2399 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2401 /// Constructs a new FundingCreated given each field
2404 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::ECDSASignature) -> FundingCreated {
2405 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2406 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2407 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2408 funding_output_index: funding_output_index_arg,
2409 signature: signature_arg.into_rust(),
2410 }), is_owned: true }
2412 impl Clone for FundingCreated {
2413 fn clone(&self) -> Self {
2415 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2416 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2422 /// Used only if an object of this type is returned as a trait impl by a method
2423 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2424 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingCreated)).clone() })) as *mut c_void
2427 /// Creates a copy of the FundingCreated
2428 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2431 /// Get a string which allows debug introspection of a FundingCreated object
2432 pub extern "C" fn FundingCreated_debug_str_void(o: *const c_void) -> Str {
2433 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::FundingCreated }).into()}
2434 /// Generates a non-cryptographic 64-bit hash of the FundingCreated.
2436 pub extern "C" fn FundingCreated_hash(o: &FundingCreated) -> u64 {
2437 if o.inner.is_null() { return 0; }
2438 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2439 #[allow(deprecated)]
2440 let mut hasher = core::hash::SipHasher::new();
2441 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2442 core::hash::Hasher::finish(&hasher)
2444 /// Checks if two FundingCreateds contain equal inner contents.
2445 /// This ignores pointers and is_owned flags and looks at the values in fields.
2446 /// Two objects with NULL inner values will be considered "equal" here.
2448 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2449 if a.inner == b.inner { return true; }
2450 if a.inner.is_null() || b.inner.is_null() { return false; }
2451 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2454 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2455 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2457 /// A [`funding_signed`] message to be sent to or received from a peer.
2459 /// Used in V1 channel establishment
2461 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2464 pub struct FundingSigned {
2465 /// A pointer to the opaque Rust object.
2467 /// Nearly everywhere, inner must be non-null, however in places where
2468 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2469 pub inner: *mut nativeFundingSigned,
2470 /// Indicates that this is the only struct which contains the same pointer.
2472 /// Rust functions which take ownership of an object provided via an argument require
2473 /// this to be true and invalidate the object pointed to by inner.
2477 impl Drop for FundingSigned {
2478 fn drop(&mut self) {
2479 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2480 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2484 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2486 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2488 /// Used only if an object of this type is returned as a trait impl by a method
2489 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2490 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2493 impl FundingSigned {
2494 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2495 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2497 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2498 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2500 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2501 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2502 assert!(self.is_owned);
2503 let ret = ObjOps::untweak_ptr(self.inner);
2504 self.inner = core::ptr::null_mut();
2510 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
2511 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2516 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2517 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2519 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2521 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::ECDSASignature {
2522 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2523 crate::c_types::ECDSASignature::from_rust(&inner_val)
2525 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2527 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::ECDSASignature) {
2528 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2530 /// Constructs a new FundingSigned given each field
2533 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned {
2534 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2535 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2536 signature: signature_arg.into_rust(),
2537 }), is_owned: true }
2539 impl Clone for FundingSigned {
2540 fn clone(&self) -> Self {
2542 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2543 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2549 /// Used only if an object of this type is returned as a trait impl by a method
2550 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2551 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingSigned)).clone() })) as *mut c_void
2554 /// Creates a copy of the FundingSigned
2555 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2558 /// Get a string which allows debug introspection of a FundingSigned object
2559 pub extern "C" fn FundingSigned_debug_str_void(o: *const c_void) -> Str {
2560 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::FundingSigned }).into()}
2561 /// Generates a non-cryptographic 64-bit hash of the FundingSigned.
2563 pub extern "C" fn FundingSigned_hash(o: &FundingSigned) -> u64 {
2564 if o.inner.is_null() { return 0; }
2565 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2566 #[allow(deprecated)]
2567 let mut hasher = core::hash::SipHasher::new();
2568 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2569 core::hash::Hasher::finish(&hasher)
2571 /// Checks if two FundingSigneds contain equal inner contents.
2572 /// This ignores pointers and is_owned flags and looks at the values in fields.
2573 /// Two objects with NULL inner values will be considered "equal" here.
2575 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2576 if a.inner == b.inner { return true; }
2577 if a.inner.is_null() || b.inner.is_null() { return false; }
2578 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2581 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2582 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2584 /// A [`channel_ready`] message to be sent to or received from a peer.
2586 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2589 pub struct ChannelReady {
2590 /// A pointer to the opaque Rust object.
2592 /// Nearly everywhere, inner must be non-null, however in places where
2593 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2594 pub inner: *mut nativeChannelReady,
2595 /// Indicates that this is the only struct which contains the same pointer.
2597 /// Rust functions which take ownership of an object provided via an argument require
2598 /// this to be true and invalidate the object pointed to by inner.
2602 impl Drop for ChannelReady {
2603 fn drop(&mut self) {
2604 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2605 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2609 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2611 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2613 /// Used only if an object of this type is returned as a trait impl by a method
2614 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2615 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2619 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2620 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2622 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2623 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2625 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2626 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2627 assert!(self.is_owned);
2628 let ret = ObjOps::untweak_ptr(self.inner);
2629 self.inner = core::ptr::null_mut();
2635 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
2636 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2641 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
2642 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2644 /// The per-commitment point of the second commitment transaction
2646 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2647 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2648 crate::c_types::PublicKey::from_rust(&inner_val)
2650 /// The per-commitment point of the second commitment transaction
2652 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2653 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2655 /// If set, provides a `short_channel_id` alias for this channel.
2657 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2658 /// messages' recipient.
2660 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2661 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2662 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
2665 /// If set, provides a `short_channel_id` alias for this channel.
2667 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2668 /// messages' recipient.
2670 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2671 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2672 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2674 /// Constructs a new ChannelReady given each field
2677 pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady {
2678 let mut local_short_channel_id_alias_arg = if short_channel_id_alias_arg.is_some() { Some( { short_channel_id_alias_arg.take() }) } else { None };
2679 ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2680 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2681 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2682 short_channel_id_alias: local_short_channel_id_alias_arg,
2683 }), is_owned: true }
2685 impl Clone for ChannelReady {
2686 fn clone(&self) -> Self {
2688 inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2689 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2695 /// Used only if an object of this type is returned as a trait impl by a method
2696 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2697 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReady)).clone() })) as *mut c_void
2700 /// Creates a copy of the ChannelReady
2701 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2704 /// Get a string which allows debug introspection of a ChannelReady object
2705 pub extern "C" fn ChannelReady_debug_str_void(o: *const c_void) -> Str {
2706 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelReady }).into()}
2707 /// Generates a non-cryptographic 64-bit hash of the ChannelReady.
2709 pub extern "C" fn ChannelReady_hash(o: &ChannelReady) -> u64 {
2710 if o.inner.is_null() { return 0; }
2711 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2712 #[allow(deprecated)]
2713 let mut hasher = core::hash::SipHasher::new();
2714 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2715 core::hash::Hasher::finish(&hasher)
2717 /// Checks if two ChannelReadys contain equal inner contents.
2718 /// This ignores pointers and is_owned flags and looks at the values in fields.
2719 /// Two objects with NULL inner values will be considered "equal" here.
2721 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2722 if a.inner == b.inner { return true; }
2723 if a.inner.is_null() || b.inner.is_null() { return false; }
2724 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2727 use lightning::ln::msgs::Stfu as nativeStfuImport;
2728 pub(crate) type nativeStfu = nativeStfuImport;
2730 /// An stfu (quiescence) message to be sent by or received from the stfu initiator.
2734 /// A pointer to the opaque Rust object.
2736 /// Nearly everywhere, inner must be non-null, however in places where
2737 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2738 pub inner: *mut nativeStfu,
2739 /// Indicates that this is the only struct which contains the same pointer.
2741 /// Rust functions which take ownership of an object provided via an argument require
2742 /// this to be true and invalidate the object pointed to by inner.
2746 impl Drop for Stfu {
2747 fn drop(&mut self) {
2748 if self.is_owned && !<*mut nativeStfu>::is_null(self.inner) {
2749 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2753 /// Frees any resources used by the Stfu, if is_owned is set and inner is non-NULL.
2755 pub extern "C" fn Stfu_free(this_obj: Stfu) { }
2757 /// Used only if an object of this type is returned as a trait impl by a method
2758 pub(crate) extern "C" fn Stfu_free_void(this_ptr: *mut c_void) {
2759 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeStfu) };
2763 pub(crate) fn get_native_ref(&self) -> &'static nativeStfu {
2764 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2766 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeStfu {
2767 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2769 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2770 pub(crate) fn take_inner(mut self) -> *mut nativeStfu {
2771 assert!(self.is_owned);
2772 let ret = ObjOps::untweak_ptr(self.inner);
2773 self.inner = core::ptr::null_mut();
2777 /// The channel ID where quiescence is intended
2779 pub extern "C" fn Stfu_get_channel_id(this_ptr: &Stfu) -> *const [u8; 32] {
2780 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2783 /// The channel ID where quiescence is intended
2785 pub extern "C" fn Stfu_set_channel_id(this_ptr: &mut Stfu, mut val: crate::c_types::ThirtyTwoBytes) {
2786 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2788 /// Initiator flag, 1 if initiating, 0 if replying to an stfu.
2790 pub extern "C" fn Stfu_get_initiator(this_ptr: &Stfu) -> u8 {
2791 let mut inner_val = &mut this_ptr.get_native_mut_ref().initiator;
2794 /// Initiator flag, 1 if initiating, 0 if replying to an stfu.
2796 pub extern "C" fn Stfu_set_initiator(this_ptr: &mut Stfu, mut val: u8) {
2797 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.initiator = val;
2799 /// Constructs a new Stfu given each field
2802 pub extern "C" fn Stfu_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut initiator_arg: u8) -> Stfu {
2803 Stfu { inner: ObjOps::heap_alloc(nativeStfu {
2804 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2805 initiator: initiator_arg,
2806 }), is_owned: true }
2808 impl Clone for Stfu {
2809 fn clone(&self) -> Self {
2811 inner: if <*mut nativeStfu>::is_null(self.inner) { core::ptr::null_mut() } else {
2812 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2818 /// Used only if an object of this type is returned as a trait impl by a method
2819 pub(crate) extern "C" fn Stfu_clone_void(this_ptr: *const c_void) -> *mut c_void {
2820 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeStfu)).clone() })) as *mut c_void
2823 /// Creates a copy of the Stfu
2824 pub extern "C" fn Stfu_clone(orig: &Stfu) -> Stfu {
2827 /// Get a string which allows debug introspection of a Stfu object
2828 pub extern "C" fn Stfu_debug_str_void(o: *const c_void) -> Str {
2829 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Stfu }).into()}
2830 /// Checks if two Stfus contain equal inner contents.
2831 /// This ignores pointers and is_owned flags and looks at the values in fields.
2832 /// Two objects with NULL inner values will be considered "equal" here.
2834 pub extern "C" fn Stfu_eq(a: &Stfu, b: &Stfu) -> bool {
2835 if a.inner == b.inner { return true; }
2836 if a.inner.is_null() || b.inner.is_null() { return false; }
2837 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2840 use lightning::ln::msgs::Splice as nativeSpliceImport;
2841 pub(crate) type nativeSplice = nativeSpliceImport;
2843 /// A splice message to be sent by or received from the stfu initiator (splice initiator).
2847 /// A pointer to the opaque Rust object.
2849 /// Nearly everywhere, inner must be non-null, however in places where
2850 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2851 pub inner: *mut nativeSplice,
2852 /// Indicates that this is the only struct which contains the same pointer.
2854 /// Rust functions which take ownership of an object provided via an argument require
2855 /// this to be true and invalidate the object pointed to by inner.
2859 impl Drop for Splice {
2860 fn drop(&mut self) {
2861 if self.is_owned && !<*mut nativeSplice>::is_null(self.inner) {
2862 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2866 /// Frees any resources used by the Splice, if is_owned is set and inner is non-NULL.
2868 pub extern "C" fn Splice_free(this_obj: Splice) { }
2870 /// Used only if an object of this type is returned as a trait impl by a method
2871 pub(crate) extern "C" fn Splice_free_void(this_ptr: *mut c_void) {
2872 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSplice) };
2876 pub(crate) fn get_native_ref(&self) -> &'static nativeSplice {
2877 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2879 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSplice {
2880 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2882 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2883 pub(crate) fn take_inner(mut self) -> *mut nativeSplice {
2884 assert!(self.is_owned);
2885 let ret = ObjOps::untweak_ptr(self.inner);
2886 self.inner = core::ptr::null_mut();
2890 /// The channel ID where splicing is intended
2892 pub extern "C" fn Splice_get_channel_id(this_ptr: &Splice) -> *const [u8; 32] {
2893 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2896 /// The channel ID where splicing is intended
2898 pub extern "C" fn Splice_set_channel_id(this_ptr: &mut Splice, mut val: crate::c_types::ThirtyTwoBytes) {
2899 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2901 /// The genesis hash of the blockchain where the channel is intended to be spliced
2903 pub extern "C" fn Splice_get_chain_hash(this_ptr: &Splice) -> *const [u8; 32] {
2904 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
2907 /// The genesis hash of the blockchain where the channel is intended to be spliced
2909 pub extern "C" fn Splice_set_chain_hash(this_ptr: &mut Splice, mut val: crate::c_types::ThirtyTwoBytes) {
2910 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
2912 /// The intended change in channel capacity: the amount to be added (positive value)
2913 /// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
2915 pub extern "C" fn Splice_get_relative_satoshis(this_ptr: &Splice) -> i64 {
2916 let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis;
2919 /// The intended change in channel capacity: the amount to be added (positive value)
2920 /// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
2922 pub extern "C" fn Splice_set_relative_satoshis(this_ptr: &mut Splice, mut val: i64) {
2923 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val;
2925 /// The feerate for the new funding transaction, set by the splice initiator
2927 pub extern "C" fn Splice_get_funding_feerate_perkw(this_ptr: &Splice) -> u32 {
2928 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_perkw;
2931 /// The feerate for the new funding transaction, set by the splice initiator
2933 pub extern "C" fn Splice_set_funding_feerate_perkw(this_ptr: &mut Splice, mut val: u32) {
2934 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_perkw = val;
2936 /// The locktime for the new funding transaction
2938 pub extern "C" fn Splice_get_locktime(this_ptr: &Splice) -> u32 {
2939 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
2942 /// The locktime for the new funding transaction
2944 pub extern "C" fn Splice_set_locktime(this_ptr: &mut Splice, mut val: u32) {
2945 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
2947 /// The key of the sender (splice initiator) controlling the new funding transaction
2949 pub extern "C" fn Splice_get_funding_pubkey(this_ptr: &Splice) -> crate::c_types::PublicKey {
2950 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
2951 crate::c_types::PublicKey::from_rust(&inner_val)
2953 /// The key of the sender (splice initiator) controlling the new funding transaction
2955 pub extern "C" fn Splice_set_funding_pubkey(this_ptr: &mut Splice, mut val: crate::c_types::PublicKey) {
2956 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
2958 /// Constructs a new Splice given each field
2961 pub extern "C" fn Splice_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_feerate_perkw_arg: u32, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey) -> Splice {
2962 Splice { inner: ObjOps::heap_alloc(nativeSplice {
2963 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2964 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
2965 relative_satoshis: relative_satoshis_arg,
2966 funding_feerate_perkw: funding_feerate_perkw_arg,
2967 locktime: locktime_arg,
2968 funding_pubkey: funding_pubkey_arg.into_rust(),
2969 }), is_owned: true }
2971 impl Clone for Splice {
2972 fn clone(&self) -> Self {
2974 inner: if <*mut nativeSplice>::is_null(self.inner) { core::ptr::null_mut() } else {
2975 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2981 /// Used only if an object of this type is returned as a trait impl by a method
2982 pub(crate) extern "C" fn Splice_clone_void(this_ptr: *const c_void) -> *mut c_void {
2983 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSplice)).clone() })) as *mut c_void
2986 /// Creates a copy of the Splice
2987 pub extern "C" fn Splice_clone(orig: &Splice) -> Splice {
2990 /// Get a string which allows debug introspection of a Splice object
2991 pub extern "C" fn Splice_debug_str_void(o: *const c_void) -> Str {
2992 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Splice }).into()}
2993 /// Checks if two Splices contain equal inner contents.
2994 /// This ignores pointers and is_owned flags and looks at the values in fields.
2995 /// Two objects with NULL inner values will be considered "equal" here.
2997 pub extern "C" fn Splice_eq(a: &Splice, b: &Splice) -> bool {
2998 if a.inner == b.inner { return true; }
2999 if a.inner.is_null() || b.inner.is_null() { return false; }
3000 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3003 use lightning::ln::msgs::SpliceAck as nativeSpliceAckImport;
3004 pub(crate) type nativeSpliceAck = nativeSpliceAckImport;
3006 /// A splice_ack message to be received by or sent to the splice initiator.
3010 pub struct SpliceAck {
3011 /// A pointer to the opaque Rust object.
3013 /// Nearly everywhere, inner must be non-null, however in places where
3014 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3015 pub inner: *mut nativeSpliceAck,
3016 /// Indicates that this is the only struct which contains the same pointer.
3018 /// Rust functions which take ownership of an object provided via an argument require
3019 /// this to be true and invalidate the object pointed to by inner.
3023 impl Drop for SpliceAck {
3024 fn drop(&mut self) {
3025 if self.is_owned && !<*mut nativeSpliceAck>::is_null(self.inner) {
3026 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3030 /// Frees any resources used by the SpliceAck, if is_owned is set and inner is non-NULL.
3032 pub extern "C" fn SpliceAck_free(this_obj: SpliceAck) { }
3034 /// Used only if an object of this type is returned as a trait impl by a method
3035 pub(crate) extern "C" fn SpliceAck_free_void(this_ptr: *mut c_void) {
3036 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceAck) };
3040 pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceAck {
3041 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3043 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceAck {
3044 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3046 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3047 pub(crate) fn take_inner(mut self) -> *mut nativeSpliceAck {
3048 assert!(self.is_owned);
3049 let ret = ObjOps::untweak_ptr(self.inner);
3050 self.inner = core::ptr::null_mut();
3054 /// The channel ID where splicing is intended
3056 pub extern "C" fn SpliceAck_get_channel_id(this_ptr: &SpliceAck) -> *const [u8; 32] {
3057 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3060 /// The channel ID where splicing is intended
3062 pub extern "C" fn SpliceAck_set_channel_id(this_ptr: &mut SpliceAck, mut val: crate::c_types::ThirtyTwoBytes) {
3063 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3065 /// The genesis hash of the blockchain where the channel is intended to be spliced
3067 pub extern "C" fn SpliceAck_get_chain_hash(this_ptr: &SpliceAck) -> *const [u8; 32] {
3068 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3071 /// The genesis hash of the blockchain where the channel is intended to be spliced
3073 pub extern "C" fn SpliceAck_set_chain_hash(this_ptr: &mut SpliceAck, mut val: crate::c_types::ThirtyTwoBytes) {
3074 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
3076 /// The intended change in channel capacity: the amount to be added (positive value)
3077 /// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
3079 pub extern "C" fn SpliceAck_get_relative_satoshis(this_ptr: &SpliceAck) -> i64 {
3080 let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis;
3083 /// The intended change in channel capacity: the amount to be added (positive value)
3084 /// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
3086 pub extern "C" fn SpliceAck_set_relative_satoshis(this_ptr: &mut SpliceAck, mut val: i64) {
3087 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val;
3089 /// The key of the sender (splice acceptor) controlling the new funding transaction
3091 pub extern "C" fn SpliceAck_get_funding_pubkey(this_ptr: &SpliceAck) -> crate::c_types::PublicKey {
3092 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
3093 crate::c_types::PublicKey::from_rust(&inner_val)
3095 /// The key of the sender (splice acceptor) controlling the new funding transaction
3097 pub extern "C" fn SpliceAck_set_funding_pubkey(this_ptr: &mut SpliceAck, mut val: crate::c_types::PublicKey) {
3098 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
3100 /// Constructs a new SpliceAck given each field
3103 pub extern "C" fn SpliceAck_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_pubkey_arg: crate::c_types::PublicKey) -> SpliceAck {
3104 SpliceAck { inner: ObjOps::heap_alloc(nativeSpliceAck {
3105 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3106 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
3107 relative_satoshis: relative_satoshis_arg,
3108 funding_pubkey: funding_pubkey_arg.into_rust(),
3109 }), is_owned: true }
3111 impl Clone for SpliceAck {
3112 fn clone(&self) -> Self {
3114 inner: if <*mut nativeSpliceAck>::is_null(self.inner) { core::ptr::null_mut() } else {
3115 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3121 /// Used only if an object of this type is returned as a trait impl by a method
3122 pub(crate) extern "C" fn SpliceAck_clone_void(this_ptr: *const c_void) -> *mut c_void {
3123 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceAck)).clone() })) as *mut c_void
3126 /// Creates a copy of the SpliceAck
3127 pub extern "C" fn SpliceAck_clone(orig: &SpliceAck) -> SpliceAck {
3130 /// Get a string which allows debug introspection of a SpliceAck object
3131 pub extern "C" fn SpliceAck_debug_str_void(o: *const c_void) -> Str {
3132 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceAck }).into()}
3133 /// Checks if two SpliceAcks contain equal inner contents.
3134 /// This ignores pointers and is_owned flags and looks at the values in fields.
3135 /// Two objects with NULL inner values will be considered "equal" here.
3137 pub extern "C" fn SpliceAck_eq(a: &SpliceAck, b: &SpliceAck) -> bool {
3138 if a.inner == b.inner { return true; }
3139 if a.inner.is_null() || b.inner.is_null() { return false; }
3140 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3143 use lightning::ln::msgs::SpliceLocked as nativeSpliceLockedImport;
3144 pub(crate) type nativeSpliceLocked = nativeSpliceLockedImport;
3146 /// A splice_locked message to be sent to or received from a peer.
3150 pub struct SpliceLocked {
3151 /// A pointer to the opaque Rust object.
3153 /// Nearly everywhere, inner must be non-null, however in places where
3154 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3155 pub inner: *mut nativeSpliceLocked,
3156 /// Indicates that this is the only struct which contains the same pointer.
3158 /// Rust functions which take ownership of an object provided via an argument require
3159 /// this to be true and invalidate the object pointed to by inner.
3163 impl Drop for SpliceLocked {
3164 fn drop(&mut self) {
3165 if self.is_owned && !<*mut nativeSpliceLocked>::is_null(self.inner) {
3166 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3170 /// Frees any resources used by the SpliceLocked, if is_owned is set and inner is non-NULL.
3172 pub extern "C" fn SpliceLocked_free(this_obj: SpliceLocked) { }
3174 /// Used only if an object of this type is returned as a trait impl by a method
3175 pub(crate) extern "C" fn SpliceLocked_free_void(this_ptr: *mut c_void) {
3176 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceLocked) };
3180 pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceLocked {
3181 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3183 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceLocked {
3184 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3186 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3187 pub(crate) fn take_inner(mut self) -> *mut nativeSpliceLocked {
3188 assert!(self.is_owned);
3189 let ret = ObjOps::untweak_ptr(self.inner);
3190 self.inner = core::ptr::null_mut();
3196 pub extern "C" fn SpliceLocked_get_channel_id(this_ptr: &SpliceLocked) -> *const [u8; 32] {
3197 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3202 pub extern "C" fn SpliceLocked_set_channel_id(this_ptr: &mut SpliceLocked, mut val: crate::c_types::ThirtyTwoBytes) {
3203 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3205 /// Constructs a new SpliceLocked given each field
3208 pub extern "C" fn SpliceLocked_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> SpliceLocked {
3209 SpliceLocked { inner: ObjOps::heap_alloc(nativeSpliceLocked {
3210 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3211 }), is_owned: true }
3213 impl Clone for SpliceLocked {
3214 fn clone(&self) -> Self {
3216 inner: if <*mut nativeSpliceLocked>::is_null(self.inner) { core::ptr::null_mut() } else {
3217 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3223 /// Used only if an object of this type is returned as a trait impl by a method
3224 pub(crate) extern "C" fn SpliceLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
3225 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceLocked)).clone() })) as *mut c_void
3228 /// Creates a copy of the SpliceLocked
3229 pub extern "C" fn SpliceLocked_clone(orig: &SpliceLocked) -> SpliceLocked {
3232 /// Get a string which allows debug introspection of a SpliceLocked object
3233 pub extern "C" fn SpliceLocked_debug_str_void(o: *const c_void) -> Str {
3234 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceLocked }).into()}
3235 /// Checks if two SpliceLockeds contain equal inner contents.
3236 /// This ignores pointers and is_owned flags and looks at the values in fields.
3237 /// Two objects with NULL inner values will be considered "equal" here.
3239 pub extern "C" fn SpliceLocked_eq(a: &SpliceLocked, b: &SpliceLocked) -> bool {
3240 if a.inner == b.inner { return true; }
3241 if a.inner.is_null() || b.inner.is_null() { return false; }
3242 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3245 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
3246 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
3248 /// A tx_add_input message for adding an input during interactive transaction construction
3252 pub struct TxAddInput {
3253 /// A pointer to the opaque Rust object.
3255 /// Nearly everywhere, inner must be non-null, however in places where
3256 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3257 pub inner: *mut nativeTxAddInput,
3258 /// Indicates that this is the only struct which contains the same pointer.
3260 /// Rust functions which take ownership of an object provided via an argument require
3261 /// this to be true and invalidate the object pointed to by inner.
3265 impl Drop for TxAddInput {
3266 fn drop(&mut self) {
3267 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
3268 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3272 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
3274 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
3276 /// Used only if an object of this type is returned as a trait impl by a method
3277 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
3278 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
3282 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
3283 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3285 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
3286 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3288 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3289 pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
3290 assert!(self.is_owned);
3291 let ret = ObjOps::untweak_ptr(self.inner);
3292 self.inner = core::ptr::null_mut();
3298 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] {
3299 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3304 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) {
3305 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3307 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
3310 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
3311 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3314 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
3317 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
3318 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3320 /// Serialized transaction that contains the output this input spends to verify that it is non
3323 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
3324 let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
3325 crate::lightning::util::ser::TransactionU16LenLimited { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::ser::TransactionU16LenLimited<>) as *mut _) }, is_owned: false }
3327 /// Serialized transaction that contains the output this input spends to verify that it is non
3330 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
3331 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
3333 /// The index of the output being spent
3335 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
3336 let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
3339 /// The index of the output being spent
3341 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
3342 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
3344 /// The sequence number of this input
3346 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
3347 let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
3350 /// The sequence number of this input
3352 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
3353 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
3355 /// Constructs a new TxAddInput given each field
3358 pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput {
3359 TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
3360 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3361 serial_id: serial_id_arg,
3362 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
3363 prevtx_out: prevtx_out_arg,
3364 sequence: sequence_arg,
3365 }), is_owned: true }
3367 impl Clone for TxAddInput {
3368 fn clone(&self) -> Self {
3370 inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
3371 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3377 /// Used only if an object of this type is returned as a trait impl by a method
3378 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3379 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddInput)).clone() })) as *mut c_void
3382 /// Creates a copy of the TxAddInput
3383 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
3386 /// Get a string which allows debug introspection of a TxAddInput object
3387 pub extern "C" fn TxAddInput_debug_str_void(o: *const c_void) -> Str {
3388 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAddInput }).into()}
3389 /// Generates a non-cryptographic 64-bit hash of the TxAddInput.
3391 pub extern "C" fn TxAddInput_hash(o: &TxAddInput) -> u64 {
3392 if o.inner.is_null() { return 0; }
3393 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3394 #[allow(deprecated)]
3395 let mut hasher = core::hash::SipHasher::new();
3396 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3397 core::hash::Hasher::finish(&hasher)
3399 /// Checks if two TxAddInputs contain equal inner contents.
3400 /// This ignores pointers and is_owned flags and looks at the values in fields.
3401 /// Two objects with NULL inner values will be considered "equal" here.
3403 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
3404 if a.inner == b.inner { return true; }
3405 if a.inner.is_null() || b.inner.is_null() { return false; }
3406 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3409 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
3410 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
3412 /// A tx_add_output message for adding an output during interactive transaction construction.
3416 pub struct TxAddOutput {
3417 /// A pointer to the opaque Rust object.
3419 /// Nearly everywhere, inner must be non-null, however in places where
3420 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3421 pub inner: *mut nativeTxAddOutput,
3422 /// Indicates that this is the only struct which contains the same pointer.
3424 /// Rust functions which take ownership of an object provided via an argument require
3425 /// this to be true and invalidate the object pointed to by inner.
3429 impl Drop for TxAddOutput {
3430 fn drop(&mut self) {
3431 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
3432 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3436 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
3438 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
3440 /// Used only if an object of this type is returned as a trait impl by a method
3441 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
3442 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
3446 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
3447 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3449 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
3450 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3452 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3453 pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
3454 assert!(self.is_owned);
3455 let ret = ObjOps::untweak_ptr(self.inner);
3456 self.inner = core::ptr::null_mut();
3462 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] {
3463 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3468 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) {
3469 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3471 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
3474 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
3475 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3478 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
3481 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
3482 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3484 /// The satoshi value of the output
3486 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
3487 let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
3490 /// The satoshi value of the output
3492 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
3493 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
3495 /// The scriptPubKey for the output
3497 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
3498 let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
3499 inner_val.as_bytes().to_vec().into()
3501 /// The scriptPubKey for the output
3503 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
3504 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust());
3506 /// Constructs a new TxAddOutput given each field
3509 pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput {
3510 TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
3511 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3512 serial_id: serial_id_arg,
3514 script: ::bitcoin::blockdata::script::ScriptBuf::from(script_arg.into_rust()),
3515 }), is_owned: true }
3517 impl Clone for TxAddOutput {
3518 fn clone(&self) -> Self {
3520 inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3521 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3527 /// Used only if an object of this type is returned as a trait impl by a method
3528 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3529 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddOutput)).clone() })) as *mut c_void
3532 /// Creates a copy of the TxAddOutput
3533 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
3536 /// Get a string which allows debug introspection of a TxAddOutput object
3537 pub extern "C" fn TxAddOutput_debug_str_void(o: *const c_void) -> Str {
3538 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAddOutput }).into()}
3539 /// Generates a non-cryptographic 64-bit hash of the TxAddOutput.
3541 pub extern "C" fn TxAddOutput_hash(o: &TxAddOutput) -> u64 {
3542 if o.inner.is_null() { return 0; }
3543 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3544 #[allow(deprecated)]
3545 let mut hasher = core::hash::SipHasher::new();
3546 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3547 core::hash::Hasher::finish(&hasher)
3549 /// Checks if two TxAddOutputs contain equal inner contents.
3550 /// This ignores pointers and is_owned flags and looks at the values in fields.
3551 /// Two objects with NULL inner values will be considered "equal" here.
3553 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
3554 if a.inner == b.inner { return true; }
3555 if a.inner.is_null() || b.inner.is_null() { return false; }
3556 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3559 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
3560 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
3562 /// A tx_remove_input message for removing an input during interactive transaction construction.
3566 pub struct TxRemoveInput {
3567 /// A pointer to the opaque Rust object.
3569 /// Nearly everywhere, inner must be non-null, however in places where
3570 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3571 pub inner: *mut nativeTxRemoveInput,
3572 /// Indicates that this is the only struct which contains the same pointer.
3574 /// Rust functions which take ownership of an object provided via an argument require
3575 /// this to be true and invalidate the object pointed to by inner.
3579 impl Drop for TxRemoveInput {
3580 fn drop(&mut self) {
3581 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
3582 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3586 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
3588 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
3590 /// Used only if an object of this type is returned as a trait impl by a method
3591 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
3592 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
3595 impl TxRemoveInput {
3596 pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
3597 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3599 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
3600 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3602 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3603 pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
3604 assert!(self.is_owned);
3605 let ret = ObjOps::untweak_ptr(self.inner);
3606 self.inner = core::ptr::null_mut();
3612 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] {
3613 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3618 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) {
3619 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3621 /// The serial ID of the input to be removed
3623 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
3624 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3627 /// The serial ID of the input to be removed
3629 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
3630 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3632 /// Constructs a new TxRemoveInput given each field
3635 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput {
3636 TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
3637 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3638 serial_id: serial_id_arg,
3639 }), is_owned: true }
3641 impl Clone for TxRemoveInput {
3642 fn clone(&self) -> Self {
3644 inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
3645 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3651 /// Used only if an object of this type is returned as a trait impl by a method
3652 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3653 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveInput)).clone() })) as *mut c_void
3656 /// Creates a copy of the TxRemoveInput
3657 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
3660 /// Get a string which allows debug introspection of a TxRemoveInput object
3661 pub extern "C" fn TxRemoveInput_debug_str_void(o: *const c_void) -> Str {
3662 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxRemoveInput }).into()}
3663 /// Generates a non-cryptographic 64-bit hash of the TxRemoveInput.
3665 pub extern "C" fn TxRemoveInput_hash(o: &TxRemoveInput) -> u64 {
3666 if o.inner.is_null() { return 0; }
3667 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3668 #[allow(deprecated)]
3669 let mut hasher = core::hash::SipHasher::new();
3670 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3671 core::hash::Hasher::finish(&hasher)
3673 /// Checks if two TxRemoveInputs contain equal inner contents.
3674 /// This ignores pointers and is_owned flags and looks at the values in fields.
3675 /// Two objects with NULL inner values will be considered "equal" here.
3677 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
3678 if a.inner == b.inner { return true; }
3679 if a.inner.is_null() || b.inner.is_null() { return false; }
3680 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3683 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
3684 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
3686 /// A tx_remove_output message for removing an output during interactive transaction construction.
3690 pub struct TxRemoveOutput {
3691 /// A pointer to the opaque Rust object.
3693 /// Nearly everywhere, inner must be non-null, however in places where
3694 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3695 pub inner: *mut nativeTxRemoveOutput,
3696 /// Indicates that this is the only struct which contains the same pointer.
3698 /// Rust functions which take ownership of an object provided via an argument require
3699 /// this to be true and invalidate the object pointed to by inner.
3703 impl Drop for TxRemoveOutput {
3704 fn drop(&mut self) {
3705 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
3706 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3710 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
3712 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
3714 /// Used only if an object of this type is returned as a trait impl by a method
3715 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
3716 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
3719 impl TxRemoveOutput {
3720 pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
3721 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3723 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
3724 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3726 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3727 pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
3728 assert!(self.is_owned);
3729 let ret = ObjOps::untweak_ptr(self.inner);
3730 self.inner = core::ptr::null_mut();
3736 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] {
3737 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3742 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) {
3743 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3745 /// The serial ID of the output to be removed
3747 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3748 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3751 /// The serial ID of the output to be removed
3753 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3754 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3756 /// Constructs a new TxRemoveOutput given each field
3759 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput {
3760 TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3761 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3762 serial_id: serial_id_arg,
3763 }), is_owned: true }
3765 impl Clone for TxRemoveOutput {
3766 fn clone(&self) -> Self {
3768 inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3769 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3775 /// Used only if an object of this type is returned as a trait impl by a method
3776 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3777 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveOutput)).clone() })) as *mut c_void
3780 /// Creates a copy of the TxRemoveOutput
3781 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3784 /// Get a string which allows debug introspection of a TxRemoveOutput object
3785 pub extern "C" fn TxRemoveOutput_debug_str_void(o: *const c_void) -> Str {
3786 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxRemoveOutput }).into()}
3787 /// Generates a non-cryptographic 64-bit hash of the TxRemoveOutput.
3789 pub extern "C" fn TxRemoveOutput_hash(o: &TxRemoveOutput) -> u64 {
3790 if o.inner.is_null() { return 0; }
3791 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3792 #[allow(deprecated)]
3793 let mut hasher = core::hash::SipHasher::new();
3794 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3795 core::hash::Hasher::finish(&hasher)
3797 /// Checks if two TxRemoveOutputs contain equal inner contents.
3798 /// This ignores pointers and is_owned flags and looks at the values in fields.
3799 /// Two objects with NULL inner values will be considered "equal" here.
3801 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3802 if a.inner == b.inner { return true; }
3803 if a.inner.is_null() || b.inner.is_null() { return false; }
3804 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3807 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3808 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3810 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3811 /// interactive transaction construction.
3815 pub struct TxComplete {
3816 /// A pointer to the opaque Rust object.
3818 /// Nearly everywhere, inner must be non-null, however in places where
3819 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3820 pub inner: *mut nativeTxComplete,
3821 /// Indicates that this is the only struct which contains the same pointer.
3823 /// Rust functions which take ownership of an object provided via an argument require
3824 /// this to be true and invalidate the object pointed to by inner.
3828 impl Drop for TxComplete {
3829 fn drop(&mut self) {
3830 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3831 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3835 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3837 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3839 /// Used only if an object of this type is returned as a trait impl by a method
3840 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3841 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3845 pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3846 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3848 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3849 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3851 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3852 pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3853 assert!(self.is_owned);
3854 let ret = ObjOps::untweak_ptr(self.inner);
3855 self.inner = core::ptr::null_mut();
3861 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] {
3862 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3867 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) {
3868 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3870 /// Constructs a new TxComplete given each field
3873 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete {
3874 TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3875 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3876 }), is_owned: true }
3878 impl Clone for TxComplete {
3879 fn clone(&self) -> Self {
3881 inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3882 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3888 /// Used only if an object of this type is returned as a trait impl by a method
3889 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3890 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxComplete)).clone() })) as *mut c_void
3893 /// Creates a copy of the TxComplete
3894 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3897 /// Get a string which allows debug introspection of a TxComplete object
3898 pub extern "C" fn TxComplete_debug_str_void(o: *const c_void) -> Str {
3899 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxComplete }).into()}
3900 /// Generates a non-cryptographic 64-bit hash of the TxComplete.
3902 pub extern "C" fn TxComplete_hash(o: &TxComplete) -> u64 {
3903 if o.inner.is_null() { return 0; }
3904 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3905 #[allow(deprecated)]
3906 let mut hasher = core::hash::SipHasher::new();
3907 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3908 core::hash::Hasher::finish(&hasher)
3910 /// Checks if two TxCompletes contain equal inner contents.
3911 /// This ignores pointers and is_owned flags and looks at the values in fields.
3912 /// Two objects with NULL inner values will be considered "equal" here.
3914 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3915 if a.inner == b.inner { return true; }
3916 if a.inner.is_null() || b.inner.is_null() { return false; }
3917 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3920 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3921 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3923 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3924 /// interactive transaction construction.
3928 pub struct TxSignatures {
3929 /// A pointer to the opaque Rust object.
3931 /// Nearly everywhere, inner must be non-null, however in places where
3932 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3933 pub inner: *mut nativeTxSignatures,
3934 /// Indicates that this is the only struct which contains the same pointer.
3936 /// Rust functions which take ownership of an object provided via an argument require
3937 /// this to be true and invalidate the object pointed to by inner.
3941 impl Drop for TxSignatures {
3942 fn drop(&mut self) {
3943 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3944 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3948 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3950 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3952 /// Used only if an object of this type is returned as a trait impl by a method
3953 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3954 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3958 pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3959 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3961 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3962 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3964 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3965 pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3966 assert!(self.is_owned);
3967 let ret = ObjOps::untweak_ptr(self.inner);
3968 self.inner = core::ptr::null_mut();
3974 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] {
3975 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3980 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3981 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3985 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3986 let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3991 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3992 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3994 /// The list of witnesses
3996 /// Returns a copy of the field.
3998 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3999 let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
4000 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Witness::from_bitcoin(&item) }); };
4001 local_inner_val.into()
4003 /// The list of witnesses
4005 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
4006 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
4007 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
4009 /// Constructs a new TxSignatures given each field
4012 pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ) -> TxSignatures {
4013 let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
4014 TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
4015 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4016 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
4017 witnesses: local_witnesses_arg,
4018 }), is_owned: true }
4020 impl Clone for TxSignatures {
4021 fn clone(&self) -> Self {
4023 inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
4024 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4030 /// Used only if an object of this type is returned as a trait impl by a method
4031 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
4032 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxSignatures)).clone() })) as *mut c_void
4035 /// Creates a copy of the TxSignatures
4036 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
4039 /// Get a string which allows debug introspection of a TxSignatures object
4040 pub extern "C" fn TxSignatures_debug_str_void(o: *const c_void) -> Str {
4041 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxSignatures }).into()}
4042 /// Generates a non-cryptographic 64-bit hash of the TxSignatures.
4044 pub extern "C" fn TxSignatures_hash(o: &TxSignatures) -> u64 {
4045 if o.inner.is_null() { return 0; }
4046 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4047 #[allow(deprecated)]
4048 let mut hasher = core::hash::SipHasher::new();
4049 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4050 core::hash::Hasher::finish(&hasher)
4052 /// Checks if two TxSignaturess contain equal inner contents.
4053 /// This ignores pointers and is_owned flags and looks at the values in fields.
4054 /// Two objects with NULL inner values will be considered "equal" here.
4056 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
4057 if a.inner == b.inner { return true; }
4058 if a.inner.is_null() || b.inner.is_null() { return false; }
4059 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4062 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
4063 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
4065 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
4070 pub struct TxInitRbf {
4071 /// A pointer to the opaque Rust object.
4073 /// Nearly everywhere, inner must be non-null, however in places where
4074 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4075 pub inner: *mut nativeTxInitRbf,
4076 /// Indicates that this is the only struct which contains the same pointer.
4078 /// Rust functions which take ownership of an object provided via an argument require
4079 /// this to be true and invalidate the object pointed to by inner.
4083 impl Drop for TxInitRbf {
4084 fn drop(&mut self) {
4085 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
4086 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4090 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
4092 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
4094 /// Used only if an object of this type is returned as a trait impl by a method
4095 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
4096 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
4100 pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
4101 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4103 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
4104 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4106 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4107 pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
4108 assert!(self.is_owned);
4109 let ret = ObjOps::untweak_ptr(self.inner);
4110 self.inner = core::ptr::null_mut();
4116 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] {
4117 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4122 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) {
4123 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4125 /// The locktime of the transaction
4127 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
4128 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
4131 /// The locktime of the transaction
4133 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
4134 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
4136 /// The feerate of the transaction
4138 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
4139 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
4142 /// The feerate of the transaction
4144 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
4145 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
4147 /// The number of satoshis the sender will contribute to or, if negative, remove from
4148 /// (e.g. splice-out) the funding output of the transaction
4150 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
4151 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
4152 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) };
4155 /// The number of satoshis the sender will contribute to or, if negative, remove from
4156 /// (e.g. splice-out) the funding output of the transaction
4158 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
4159 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4160 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
4162 /// Constructs a new TxInitRbf given each field
4165 pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf {
4166 let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
4167 TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
4168 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4169 locktime: locktime_arg,
4170 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
4171 funding_output_contribution: local_funding_output_contribution_arg,
4172 }), is_owned: true }
4174 impl Clone for TxInitRbf {
4175 fn clone(&self) -> Self {
4177 inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
4178 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4184 /// Used only if an object of this type is returned as a trait impl by a method
4185 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
4186 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxInitRbf)).clone() })) as *mut c_void
4189 /// Creates a copy of the TxInitRbf
4190 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
4193 /// Get a string which allows debug introspection of a TxInitRbf object
4194 pub extern "C" fn TxInitRbf_debug_str_void(o: *const c_void) -> Str {
4195 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxInitRbf }).into()}
4196 /// Generates a non-cryptographic 64-bit hash of the TxInitRbf.
4198 pub extern "C" fn TxInitRbf_hash(o: &TxInitRbf) -> u64 {
4199 if o.inner.is_null() { return 0; }
4200 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4201 #[allow(deprecated)]
4202 let mut hasher = core::hash::SipHasher::new();
4203 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4204 core::hash::Hasher::finish(&hasher)
4206 /// Checks if two TxInitRbfs contain equal inner contents.
4207 /// This ignores pointers and is_owned flags and looks at the values in fields.
4208 /// Two objects with NULL inner values will be considered "equal" here.
4210 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
4211 if a.inner == b.inner { return true; }
4212 if a.inner.is_null() || b.inner.is_null() { return false; }
4213 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4216 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
4217 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
4219 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
4224 pub struct TxAckRbf {
4225 /// A pointer to the opaque Rust object.
4227 /// Nearly everywhere, inner must be non-null, however in places where
4228 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4229 pub inner: *mut nativeTxAckRbf,
4230 /// Indicates that this is the only struct which contains the same pointer.
4232 /// Rust functions which take ownership of an object provided via an argument require
4233 /// this to be true and invalidate the object pointed to by inner.
4237 impl Drop for TxAckRbf {
4238 fn drop(&mut self) {
4239 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
4240 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4244 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
4246 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
4248 /// Used only if an object of this type is returned as a trait impl by a method
4249 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
4250 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
4254 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
4255 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4257 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
4258 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4260 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4261 pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
4262 assert!(self.is_owned);
4263 let ret = ObjOps::untweak_ptr(self.inner);
4264 self.inner = core::ptr::null_mut();
4270 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] {
4271 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4276 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) {
4277 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4279 /// The number of satoshis the sender will contribute to or, if negative, remove from
4280 /// (e.g. splice-out) the funding output of the transaction
4282 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
4283 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
4284 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) };
4287 /// The number of satoshis the sender will contribute to or, if negative, remove from
4288 /// (e.g. splice-out) the funding output of the transaction
4290 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
4291 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4292 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
4294 /// Constructs a new TxAckRbf given each field
4297 pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf {
4298 let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
4299 TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
4300 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4301 funding_output_contribution: local_funding_output_contribution_arg,
4302 }), is_owned: true }
4304 impl Clone for TxAckRbf {
4305 fn clone(&self) -> Self {
4307 inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
4308 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4314 /// Used only if an object of this type is returned as a trait impl by a method
4315 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
4316 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAckRbf)).clone() })) as *mut c_void
4319 /// Creates a copy of the TxAckRbf
4320 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
4323 /// Get a string which allows debug introspection of a TxAckRbf object
4324 pub extern "C" fn TxAckRbf_debug_str_void(o: *const c_void) -> Str {
4325 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAckRbf }).into()}
4326 /// Generates a non-cryptographic 64-bit hash of the TxAckRbf.
4328 pub extern "C" fn TxAckRbf_hash(o: &TxAckRbf) -> u64 {
4329 if o.inner.is_null() { return 0; }
4330 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4331 #[allow(deprecated)]
4332 let mut hasher = core::hash::SipHasher::new();
4333 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4334 core::hash::Hasher::finish(&hasher)
4336 /// Checks if two TxAckRbfs contain equal inner contents.
4337 /// This ignores pointers and is_owned flags and looks at the values in fields.
4338 /// Two objects with NULL inner values will be considered "equal" here.
4340 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
4341 if a.inner == b.inner { return true; }
4342 if a.inner.is_null() || b.inner.is_null() { return false; }
4343 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4346 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
4347 pub(crate) type nativeTxAbort = nativeTxAbortImport;
4349 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
4353 pub struct TxAbort {
4354 /// A pointer to the opaque Rust object.
4356 /// Nearly everywhere, inner must be non-null, however in places where
4357 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4358 pub inner: *mut nativeTxAbort,
4359 /// Indicates that this is the only struct which contains the same pointer.
4361 /// Rust functions which take ownership of an object provided via an argument require
4362 /// this to be true and invalidate the object pointed to by inner.
4366 impl Drop for TxAbort {
4367 fn drop(&mut self) {
4368 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
4369 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4373 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
4375 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
4377 /// Used only if an object of this type is returned as a trait impl by a method
4378 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
4379 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
4383 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
4384 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4386 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
4387 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4389 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4390 pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
4391 assert!(self.is_owned);
4392 let ret = ObjOps::untweak_ptr(self.inner);
4393 self.inner = core::ptr::null_mut();
4399 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] {
4400 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4405 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) {
4406 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4410 /// Returns a copy of the field.
4412 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
4413 let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
4414 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4415 local_inner_val.into()
4419 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
4420 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4421 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
4423 /// Constructs a new TxAbort given each field
4426 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
4427 let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
4428 TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
4429 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4430 data: local_data_arg,
4431 }), is_owned: true }
4433 impl Clone for TxAbort {
4434 fn clone(&self) -> Self {
4436 inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
4437 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4443 /// Used only if an object of this type is returned as a trait impl by a method
4444 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
4445 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAbort)).clone() })) as *mut c_void
4448 /// Creates a copy of the TxAbort
4449 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
4452 /// Get a string which allows debug introspection of a TxAbort object
4453 pub extern "C" fn TxAbort_debug_str_void(o: *const c_void) -> Str {
4454 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAbort }).into()}
4455 /// Generates a non-cryptographic 64-bit hash of the TxAbort.
4457 pub extern "C" fn TxAbort_hash(o: &TxAbort) -> u64 {
4458 if o.inner.is_null() { return 0; }
4459 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4460 #[allow(deprecated)]
4461 let mut hasher = core::hash::SipHasher::new();
4462 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4463 core::hash::Hasher::finish(&hasher)
4465 /// Checks if two TxAborts contain equal inner contents.
4466 /// This ignores pointers and is_owned flags and looks at the values in fields.
4467 /// Two objects with NULL inner values will be considered "equal" here.
4469 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
4470 if a.inner == b.inner { return true; }
4471 if a.inner.is_null() || b.inner.is_null() { return false; }
4472 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4475 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
4476 pub(crate) type nativeShutdown = nativeShutdownImport;
4478 /// A [`shutdown`] message to be sent to or received from a peer.
4480 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
4483 pub struct Shutdown {
4484 /// A pointer to the opaque Rust object.
4486 /// Nearly everywhere, inner must be non-null, however in places where
4487 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4488 pub inner: *mut nativeShutdown,
4489 /// Indicates that this is the only struct which contains the same pointer.
4491 /// Rust functions which take ownership of an object provided via an argument require
4492 /// this to be true and invalidate the object pointed to by inner.
4496 impl Drop for Shutdown {
4497 fn drop(&mut self) {
4498 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
4499 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4503 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
4505 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
4507 /// Used only if an object of this type is returned as a trait impl by a method
4508 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
4509 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
4513 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
4514 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4516 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
4517 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4519 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4520 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
4521 assert!(self.is_owned);
4522 let ret = ObjOps::untweak_ptr(self.inner);
4523 self.inner = core::ptr::null_mut();
4529 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
4530 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4535 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
4536 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4538 /// The destination of this peer's funds on closing.
4540 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
4542 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
4543 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
4544 inner_val.as_bytes().to_vec().into()
4546 /// The destination of this peer's funds on closing.
4548 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
4550 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
4551 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust());
4553 /// Constructs a new Shutdown given each field
4556 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
4557 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
4558 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4559 scriptpubkey: ::bitcoin::blockdata::script::ScriptBuf::from(scriptpubkey_arg.into_rust()),
4560 }), is_owned: true }
4562 impl Clone for Shutdown {
4563 fn clone(&self) -> Self {
4565 inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
4566 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4572 /// Used only if an object of this type is returned as a trait impl by a method
4573 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
4574 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeShutdown)).clone() })) as *mut c_void
4577 /// Creates a copy of the Shutdown
4578 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
4581 /// Get a string which allows debug introspection of a Shutdown object
4582 pub extern "C" fn Shutdown_debug_str_void(o: *const c_void) -> Str {
4583 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Shutdown }).into()}
4584 /// Generates a non-cryptographic 64-bit hash of the Shutdown.
4586 pub extern "C" fn Shutdown_hash(o: &Shutdown) -> u64 {
4587 if o.inner.is_null() { return 0; }
4588 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4589 #[allow(deprecated)]
4590 let mut hasher = core::hash::SipHasher::new();
4591 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4592 core::hash::Hasher::finish(&hasher)
4594 /// Checks if two Shutdowns contain equal inner contents.
4595 /// This ignores pointers and is_owned flags and looks at the values in fields.
4596 /// Two objects with NULL inner values will be considered "equal" here.
4598 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
4599 if a.inner == b.inner { return true; }
4600 if a.inner.is_null() || b.inner.is_null() { return false; }
4601 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4604 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
4605 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
4607 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
4609 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
4613 pub struct ClosingSignedFeeRange {
4614 /// A pointer to the opaque Rust object.
4616 /// Nearly everywhere, inner must be non-null, however in places where
4617 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4618 pub inner: *mut nativeClosingSignedFeeRange,
4619 /// Indicates that this is the only struct which contains the same pointer.
4621 /// Rust functions which take ownership of an object provided via an argument require
4622 /// this to be true and invalidate the object pointed to by inner.
4626 impl Drop for ClosingSignedFeeRange {
4627 fn drop(&mut self) {
4628 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
4629 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4633 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
4635 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
4637 /// Used only if an object of this type is returned as a trait impl by a method
4638 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
4639 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
4642 impl ClosingSignedFeeRange {
4643 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
4644 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4646 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
4647 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4649 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4650 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
4651 assert!(self.is_owned);
4652 let ret = ObjOps::untweak_ptr(self.inner);
4653 self.inner = core::ptr::null_mut();
4657 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
4660 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
4661 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
4664 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
4667 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
4668 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
4670 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
4673 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
4674 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
4677 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
4680 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
4681 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
4683 /// Constructs a new ClosingSignedFeeRange given each field
4686 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
4687 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
4688 min_fee_satoshis: min_fee_satoshis_arg,
4689 max_fee_satoshis: max_fee_satoshis_arg,
4690 }), is_owned: true }
4692 impl Clone for ClosingSignedFeeRange {
4693 fn clone(&self) -> Self {
4695 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4696 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4702 /// Used only if an object of this type is returned as a trait impl by a method
4703 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4704 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSignedFeeRange)).clone() })) as *mut c_void
4707 /// Creates a copy of the ClosingSignedFeeRange
4708 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
4711 /// Get a string which allows debug introspection of a ClosingSignedFeeRange object
4712 pub extern "C" fn ClosingSignedFeeRange_debug_str_void(o: *const c_void) -> Str {
4713 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ClosingSignedFeeRange }).into()}
4714 /// Generates a non-cryptographic 64-bit hash of the ClosingSignedFeeRange.
4716 pub extern "C" fn ClosingSignedFeeRange_hash(o: &ClosingSignedFeeRange) -> u64 {
4717 if o.inner.is_null() { return 0; }
4718 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4719 #[allow(deprecated)]
4720 let mut hasher = core::hash::SipHasher::new();
4721 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4722 core::hash::Hasher::finish(&hasher)
4724 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
4725 /// This ignores pointers and is_owned flags and looks at the values in fields.
4726 /// Two objects with NULL inner values will be considered "equal" here.
4728 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
4729 if a.inner == b.inner { return true; }
4730 if a.inner.is_null() || b.inner.is_null() { return false; }
4731 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4734 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
4735 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
4737 /// A [`closing_signed`] message to be sent to or received from a peer.
4739 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
4742 pub struct ClosingSigned {
4743 /// A pointer to the opaque Rust object.
4745 /// Nearly everywhere, inner must be non-null, however in places where
4746 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4747 pub inner: *mut nativeClosingSigned,
4748 /// Indicates that this is the only struct which contains the same pointer.
4750 /// Rust functions which take ownership of an object provided via an argument require
4751 /// this to be true and invalidate the object pointed to by inner.
4755 impl Drop for ClosingSigned {
4756 fn drop(&mut self) {
4757 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
4758 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4762 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
4764 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
4766 /// Used only if an object of this type is returned as a trait impl by a method
4767 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
4768 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
4771 impl ClosingSigned {
4772 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
4773 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4775 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
4776 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4778 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4779 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
4780 assert!(self.is_owned);
4781 let ret = ObjOps::untweak_ptr(self.inner);
4782 self.inner = core::ptr::null_mut();
4788 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
4789 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4794 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
4795 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4797 /// The proposed total fee for the closing transaction
4799 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
4800 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
4803 /// The proposed total fee for the closing transaction
4805 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
4806 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
4808 /// A signature on the closing transaction
4810 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::ECDSASignature {
4811 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4812 crate::c_types::ECDSASignature::from_rust(&inner_val)
4814 /// A signature on the closing transaction
4816 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ECDSASignature) {
4817 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4819 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4822 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4824 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
4825 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
4826 let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ClosingSignedFeeRange<>) as *mut _ }, is_owned: false };
4829 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4832 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4834 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
4835 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4836 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
4838 /// Constructs a new ClosingSigned given each field
4840 /// Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4843 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::ECDSASignature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
4844 let mut local_fee_range_arg = if fee_range_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(fee_range_arg.take_inner()) } }) };
4845 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
4846 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4847 fee_satoshis: fee_satoshis_arg,
4848 signature: signature_arg.into_rust(),
4849 fee_range: local_fee_range_arg,
4850 }), is_owned: true }
4852 impl Clone for ClosingSigned {
4853 fn clone(&self) -> Self {
4855 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4856 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4862 /// Used only if an object of this type is returned as a trait impl by a method
4863 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4864 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSigned)).clone() })) as *mut c_void
4867 /// Creates a copy of the ClosingSigned
4868 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4871 /// Get a string which allows debug introspection of a ClosingSigned object
4872 pub extern "C" fn ClosingSigned_debug_str_void(o: *const c_void) -> Str {
4873 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ClosingSigned }).into()}
4874 /// Generates a non-cryptographic 64-bit hash of the ClosingSigned.
4876 pub extern "C" fn ClosingSigned_hash(o: &ClosingSigned) -> u64 {
4877 if o.inner.is_null() { return 0; }
4878 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4879 #[allow(deprecated)]
4880 let mut hasher = core::hash::SipHasher::new();
4881 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4882 core::hash::Hasher::finish(&hasher)
4884 /// Checks if two ClosingSigneds contain equal inner contents.
4885 /// This ignores pointers and is_owned flags and looks at the values in fields.
4886 /// Two objects with NULL inner values will be considered "equal" here.
4888 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4889 if a.inner == b.inner { return true; }
4890 if a.inner.is_null() || b.inner.is_null() { return false; }
4891 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4894 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4895 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4897 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4899 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4902 pub struct UpdateAddHTLC {
4903 /// A pointer to the opaque Rust object.
4905 /// Nearly everywhere, inner must be non-null, however in places where
4906 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4907 pub inner: *mut nativeUpdateAddHTLC,
4908 /// Indicates that this is the only struct which contains the same pointer.
4910 /// Rust functions which take ownership of an object provided via an argument require
4911 /// this to be true and invalidate the object pointed to by inner.
4915 impl Drop for UpdateAddHTLC {
4916 fn drop(&mut self) {
4917 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4918 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4922 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4924 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4926 /// Used only if an object of this type is returned as a trait impl by a method
4927 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4928 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4931 impl UpdateAddHTLC {
4932 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4933 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4935 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4936 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4938 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4939 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4940 assert!(self.is_owned);
4941 let ret = ObjOps::untweak_ptr(self.inner);
4942 self.inner = core::ptr::null_mut();
4948 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4949 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4954 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4955 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4959 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4960 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4965 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4966 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4968 /// The HTLC value in milli-satoshi
4970 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4971 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4974 /// The HTLC value in milli-satoshi
4976 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4977 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4979 /// The payment hash, the pre-image of which controls HTLC redemption
4981 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4982 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4985 /// The payment hash, the pre-image of which controls HTLC redemption
4987 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4988 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
4990 /// The expiry height of the HTLC
4992 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4993 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4996 /// The expiry height of the HTLC
4998 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4999 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
5001 /// The extra fee skimmed by the sender of this message. See
5002 /// [`ChannelConfig::accept_underpaying_htlcs`].
5004 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
5006 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
5007 let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
5008 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
5011 /// The extra fee skimmed by the sender of this message. See
5012 /// [`ChannelConfig::accept_underpaying_htlcs`].
5014 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
5016 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
5017 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
5018 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
5020 /// The onion routing packet with encrypted data for the next hop.
5022 pub extern "C" fn UpdateAddHTLC_get_onion_routing_packet(this_ptr: &UpdateAddHTLC) -> crate::lightning::ln::msgs::OnionPacket {
5023 let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
5024 crate::lightning::ln::msgs::OnionPacket { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::OnionPacket<>) as *mut _) }, is_owned: false }
5026 /// The onion routing packet with encrypted data for the next hop.
5028 pub extern "C" fn UpdateAddHTLC_set_onion_routing_packet(this_ptr: &mut UpdateAddHTLC, mut val: crate::lightning::ln::msgs::OnionPacket) {
5029 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
5031 /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
5032 /// routing packet and the recipient-provided encrypted payload within.
5034 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
5036 pub extern "C" fn UpdateAddHTLC_get_blinding_point(this_ptr: &UpdateAddHTLC) -> crate::c_types::PublicKey {
5037 let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
5038 let mut local_inner_val = if inner_val.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(inner_val.unwrap())) } };
5041 /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
5042 /// routing packet and the recipient-provided encrypted payload within.
5044 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
5046 pub extern "C" fn UpdateAddHTLC_set_blinding_point(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::PublicKey) {
5047 let mut local_val = if val.is_null() { None } else { Some( { val.into_rust() }) };
5048 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = local_val;
5050 /// Constructs a new UpdateAddHTLC given each field
5052 /// Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
5055 pub extern "C" fn UpdateAddHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut amount_msat_arg: u64, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut cltv_expiry_arg: u32, mut skimmed_fee_msat_arg: crate::c_types::derived::COption_u64Z, mut onion_routing_packet_arg: crate::lightning::ln::msgs::OnionPacket, mut blinding_point_arg: crate::c_types::PublicKey) -> UpdateAddHTLC {
5056 let mut local_skimmed_fee_msat_arg = if skimmed_fee_msat_arg.is_some() { Some( { skimmed_fee_msat_arg.take() }) } else { None };
5057 let mut local_blinding_point_arg = if blinding_point_arg.is_null() { None } else { Some( { blinding_point_arg.into_rust() }) };
5058 UpdateAddHTLC { inner: ObjOps::heap_alloc(nativeUpdateAddHTLC {
5059 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5060 htlc_id: htlc_id_arg,
5061 amount_msat: amount_msat_arg,
5062 payment_hash: ::lightning::ln::PaymentHash(payment_hash_arg.data),
5063 cltv_expiry: cltv_expiry_arg,
5064 skimmed_fee_msat: local_skimmed_fee_msat_arg,
5065 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
5066 blinding_point: local_blinding_point_arg,
5067 }), is_owned: true }
5069 impl Clone for UpdateAddHTLC {
5070 fn clone(&self) -> Self {
5072 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5073 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5079 /// Used only if an object of this type is returned as a trait impl by a method
5080 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5081 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateAddHTLC)).clone() })) as *mut c_void
5084 /// Creates a copy of the UpdateAddHTLC
5085 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
5088 /// Get a string which allows debug introspection of a UpdateAddHTLC object
5089 pub extern "C" fn UpdateAddHTLC_debug_str_void(o: *const c_void) -> Str {
5090 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateAddHTLC }).into()}
5091 /// Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC.
5093 pub extern "C" fn UpdateAddHTLC_hash(o: &UpdateAddHTLC) -> u64 {
5094 if o.inner.is_null() { return 0; }
5095 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5096 #[allow(deprecated)]
5097 let mut hasher = core::hash::SipHasher::new();
5098 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5099 core::hash::Hasher::finish(&hasher)
5101 /// Checks if two UpdateAddHTLCs contain equal inner contents.
5102 /// This ignores pointers and is_owned flags and looks at the values in fields.
5103 /// Two objects with NULL inner values will be considered "equal" here.
5105 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
5106 if a.inner == b.inner { return true; }
5107 if a.inner.is_null() || b.inner.is_null() { return false; }
5108 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5111 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
5112 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
5114 /// An onion message to be sent to or received from a peer.
5118 pub struct OnionMessage {
5119 /// A pointer to the opaque Rust object.
5121 /// Nearly everywhere, inner must be non-null, however in places where
5122 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5123 pub inner: *mut nativeOnionMessage,
5124 /// Indicates that this is the only struct which contains the same pointer.
5126 /// Rust functions which take ownership of an object provided via an argument require
5127 /// this to be true and invalidate the object pointed to by inner.
5131 impl Drop for OnionMessage {
5132 fn drop(&mut self) {
5133 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
5134 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5138 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
5140 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
5142 /// Used only if an object of this type is returned as a trait impl by a method
5143 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
5144 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
5148 pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
5149 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5151 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
5152 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5154 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5155 pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
5156 assert!(self.is_owned);
5157 let ret = ObjOps::untweak_ptr(self.inner);
5158 self.inner = core::ptr::null_mut();
5162 /// Used in decrypting the onion packet's payload.
5164 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
5165 let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
5166 crate::c_types::PublicKey::from_rust(&inner_val)
5168 /// Used in decrypting the onion packet's payload.
5170 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
5171 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
5173 /// The full onion packet including hop data, pubkey, and hmac
5175 pub extern "C" fn OnionMessage_get_onion_routing_packet(this_ptr: &OnionMessage) -> crate::lightning::onion_message::packet::Packet {
5176 let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
5177 crate::lightning::onion_message::packet::Packet { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::onion_message::packet::Packet<>) as *mut _) }, is_owned: false }
5179 /// The full onion packet including hop data, pubkey, and hmac
5181 pub extern "C" fn OnionMessage_set_onion_routing_packet(this_ptr: &mut OnionMessage, mut val: crate::lightning::onion_message::packet::Packet) {
5182 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
5184 /// Constructs a new OnionMessage given each field
5187 pub extern "C" fn OnionMessage_new(mut blinding_point_arg: crate::c_types::PublicKey, mut onion_routing_packet_arg: crate::lightning::onion_message::packet::Packet) -> OnionMessage {
5188 OnionMessage { inner: ObjOps::heap_alloc(nativeOnionMessage {
5189 blinding_point: blinding_point_arg.into_rust(),
5190 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
5191 }), is_owned: true }
5193 impl Clone for OnionMessage {
5194 fn clone(&self) -> Self {
5196 inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
5197 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5203 /// Used only if an object of this type is returned as a trait impl by a method
5204 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
5205 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionMessage)).clone() })) as *mut c_void
5208 /// Creates a copy of the OnionMessage
5209 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
5212 /// Get a string which allows debug introspection of a OnionMessage object
5213 pub extern "C" fn OnionMessage_debug_str_void(o: *const c_void) -> Str {
5214 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionMessage }).into()}
5215 /// Generates a non-cryptographic 64-bit hash of the OnionMessage.
5217 pub extern "C" fn OnionMessage_hash(o: &OnionMessage) -> u64 {
5218 if o.inner.is_null() { return 0; }
5219 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5220 #[allow(deprecated)]
5221 let mut hasher = core::hash::SipHasher::new();
5222 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5223 core::hash::Hasher::finish(&hasher)
5225 /// Checks if two OnionMessages contain equal inner contents.
5226 /// This ignores pointers and is_owned flags and looks at the values in fields.
5227 /// Two objects with NULL inner values will be considered "equal" here.
5229 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
5230 if a.inner == b.inner { return true; }
5231 if a.inner.is_null() || b.inner.is_null() { return false; }
5232 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5235 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
5236 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
5238 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
5240 /// [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
5243 pub struct UpdateFulfillHTLC {
5244 /// A pointer to the opaque Rust object.
5246 /// Nearly everywhere, inner must be non-null, however in places where
5247 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5248 pub inner: *mut nativeUpdateFulfillHTLC,
5249 /// Indicates that this is the only struct which contains the same pointer.
5251 /// Rust functions which take ownership of an object provided via an argument require
5252 /// this to be true and invalidate the object pointed to by inner.
5256 impl Drop for UpdateFulfillHTLC {
5257 fn drop(&mut self) {
5258 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
5259 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5263 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
5265 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
5267 /// Used only if an object of this type is returned as a trait impl by a method
5268 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
5269 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
5272 impl UpdateFulfillHTLC {
5273 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
5274 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5276 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
5277 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5279 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5280 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
5281 assert!(self.is_owned);
5282 let ret = ObjOps::untweak_ptr(self.inner);
5283 self.inner = core::ptr::null_mut();
5289 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
5290 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5295 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5296 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5300 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
5301 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5306 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
5307 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5309 /// The pre-image of the payment hash, allowing HTLC redemption
5311 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
5312 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
5315 /// The pre-image of the payment hash, allowing HTLC redemption
5317 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5318 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
5320 /// Constructs a new UpdateFulfillHTLC given each field
5323 pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC {
5324 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
5325 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5326 htlc_id: htlc_id_arg,
5327 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
5328 }), is_owned: true }
5330 impl Clone for UpdateFulfillHTLC {
5331 fn clone(&self) -> Self {
5333 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5334 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5340 /// Used only if an object of this type is returned as a trait impl by a method
5341 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5342 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
5345 /// Creates a copy of the UpdateFulfillHTLC
5346 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
5349 /// Get a string which allows debug introspection of a UpdateFulfillHTLC object
5350 pub extern "C" fn UpdateFulfillHTLC_debug_str_void(o: *const c_void) -> Str {
5351 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFulfillHTLC }).into()}
5352 /// Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC.
5354 pub extern "C" fn UpdateFulfillHTLC_hash(o: &UpdateFulfillHTLC) -> u64 {
5355 if o.inner.is_null() { return 0; }
5356 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5357 #[allow(deprecated)]
5358 let mut hasher = core::hash::SipHasher::new();
5359 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5360 core::hash::Hasher::finish(&hasher)
5362 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
5363 /// This ignores pointers and is_owned flags and looks at the values in fields.
5364 /// Two objects with NULL inner values will be considered "equal" here.
5366 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
5367 if a.inner == b.inner { return true; }
5368 if a.inner.is_null() || b.inner.is_null() { return false; }
5369 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5372 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
5373 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
5375 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
5377 /// [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
5380 pub struct UpdateFailHTLC {
5381 /// A pointer to the opaque Rust object.
5383 /// Nearly everywhere, inner must be non-null, however in places where
5384 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5385 pub inner: *mut nativeUpdateFailHTLC,
5386 /// Indicates that this is the only struct which contains the same pointer.
5388 /// Rust functions which take ownership of an object provided via an argument require
5389 /// this to be true and invalidate the object pointed to by inner.
5393 impl Drop for UpdateFailHTLC {
5394 fn drop(&mut self) {
5395 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
5396 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5400 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
5402 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
5404 /// Used only if an object of this type is returned as a trait impl by a method
5405 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
5406 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
5409 impl UpdateFailHTLC {
5410 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
5411 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5413 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
5414 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5416 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5417 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
5418 assert!(self.is_owned);
5419 let ret = ObjOps::untweak_ptr(self.inner);
5420 self.inner = core::ptr::null_mut();
5426 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
5427 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5432 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5433 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5437 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
5438 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5443 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
5444 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5446 impl Clone for UpdateFailHTLC {
5447 fn clone(&self) -> Self {
5449 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5450 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5456 /// Used only if an object of this type is returned as a trait impl by a method
5457 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5458 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailHTLC)).clone() })) as *mut c_void
5461 /// Creates a copy of the UpdateFailHTLC
5462 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
5465 /// Get a string which allows debug introspection of a UpdateFailHTLC object
5466 pub extern "C" fn UpdateFailHTLC_debug_str_void(o: *const c_void) -> Str {
5467 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailHTLC }).into()}
5468 /// Generates a non-cryptographic 64-bit hash of the UpdateFailHTLC.
5470 pub extern "C" fn UpdateFailHTLC_hash(o: &UpdateFailHTLC) -> u64 {
5471 if o.inner.is_null() { return 0; }
5472 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5473 #[allow(deprecated)]
5474 let mut hasher = core::hash::SipHasher::new();
5475 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5476 core::hash::Hasher::finish(&hasher)
5478 /// Checks if two UpdateFailHTLCs contain equal inner contents.
5479 /// This ignores pointers and is_owned flags and looks at the values in fields.
5480 /// Two objects with NULL inner values will be considered "equal" here.
5482 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
5483 if a.inner == b.inner { return true; }
5484 if a.inner.is_null() || b.inner.is_null() { return false; }
5485 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5488 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
5489 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
5491 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
5493 /// [`update_fail_malformed_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
5496 pub struct UpdateFailMalformedHTLC {
5497 /// A pointer to the opaque Rust object.
5499 /// Nearly everywhere, inner must be non-null, however in places where
5500 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5501 pub inner: *mut nativeUpdateFailMalformedHTLC,
5502 /// Indicates that this is the only struct which contains the same pointer.
5504 /// Rust functions which take ownership of an object provided via an argument require
5505 /// this to be true and invalidate the object pointed to by inner.
5509 impl Drop for UpdateFailMalformedHTLC {
5510 fn drop(&mut self) {
5511 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
5512 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5516 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
5518 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
5520 /// Used only if an object of this type is returned as a trait impl by a method
5521 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
5522 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
5525 impl UpdateFailMalformedHTLC {
5526 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
5527 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5529 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
5530 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5532 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5533 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
5534 assert!(self.is_owned);
5535 let ret = ObjOps::untweak_ptr(self.inner);
5536 self.inner = core::ptr::null_mut();
5542 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
5543 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5548 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5549 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5553 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
5554 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5559 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
5560 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5562 /// The failure code
5564 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
5565 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
5568 /// The failure code
5570 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
5571 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
5573 impl Clone for UpdateFailMalformedHTLC {
5574 fn clone(&self) -> Self {
5576 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5577 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5583 /// Used only if an object of this type is returned as a trait impl by a method
5584 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5585 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
5588 /// Creates a copy of the UpdateFailMalformedHTLC
5589 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
5592 /// Get a string which allows debug introspection of a UpdateFailMalformedHTLC object
5593 pub extern "C" fn UpdateFailMalformedHTLC_debug_str_void(o: *const c_void) -> Str {
5594 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailMalformedHTLC }).into()}
5595 /// Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC.
5597 pub extern "C" fn UpdateFailMalformedHTLC_hash(o: &UpdateFailMalformedHTLC) -> u64 {
5598 if o.inner.is_null() { return 0; }
5599 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5600 #[allow(deprecated)]
5601 let mut hasher = core::hash::SipHasher::new();
5602 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5603 core::hash::Hasher::finish(&hasher)
5605 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
5606 /// This ignores pointers and is_owned flags and looks at the values in fields.
5607 /// Two objects with NULL inner values will be considered "equal" here.
5609 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
5610 if a.inner == b.inner { return true; }
5611 if a.inner.is_null() || b.inner.is_null() { return false; }
5612 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5615 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
5616 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
5618 /// A [`commitment_signed`] message to be sent to or received from a peer.
5620 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
5623 pub struct CommitmentSigned {
5624 /// A pointer to the opaque Rust object.
5626 /// Nearly everywhere, inner must be non-null, however in places where
5627 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5628 pub inner: *mut nativeCommitmentSigned,
5629 /// Indicates that this is the only struct which contains the same pointer.
5631 /// Rust functions which take ownership of an object provided via an argument require
5632 /// this to be true and invalidate the object pointed to by inner.
5636 impl Drop for CommitmentSigned {
5637 fn drop(&mut self) {
5638 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
5639 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5643 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
5645 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
5647 /// Used only if an object of this type is returned as a trait impl by a method
5648 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
5649 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
5652 impl CommitmentSigned {
5653 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
5654 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5656 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
5657 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5659 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5660 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
5661 assert!(self.is_owned);
5662 let ret = ObjOps::untweak_ptr(self.inner);
5663 self.inner = core::ptr::null_mut();
5669 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
5670 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5675 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
5676 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5678 /// A signature on the commitment transaction
5680 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::ECDSASignature {
5681 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
5682 crate::c_types::ECDSASignature::from_rust(&inner_val)
5684 /// A signature on the commitment transaction
5686 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ECDSASignature) {
5687 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
5689 /// Signatures on the HTLC transactions
5691 /// Returns a copy of the field.
5693 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_ECDSASignatureZ {
5694 let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
5695 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::ECDSASignature::from_rust(&item) }); };
5696 local_inner_val.into()
5698 /// Signatures on the HTLC transactions
5700 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_ECDSASignatureZ) {
5701 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
5702 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
5704 /// Constructs a new CommitmentSigned given each field
5707 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ) -> CommitmentSigned {
5708 let mut local_htlc_signatures_arg = Vec::new(); for mut item in htlc_signatures_arg.into_rust().drain(..) { local_htlc_signatures_arg.push( { item.into_rust() }); };
5709 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
5710 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5711 signature: signature_arg.into_rust(),
5712 htlc_signatures: local_htlc_signatures_arg,
5713 }), is_owned: true }
5715 impl Clone for CommitmentSigned {
5716 fn clone(&self) -> Self {
5718 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
5719 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5725 /// Used only if an object of this type is returned as a trait impl by a method
5726 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
5727 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentSigned)).clone() })) as *mut c_void
5730 /// Creates a copy of the CommitmentSigned
5731 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
5734 /// Get a string which allows debug introspection of a CommitmentSigned object
5735 pub extern "C" fn CommitmentSigned_debug_str_void(o: *const c_void) -> Str {
5736 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentSigned }).into()}
5737 /// Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
5739 pub extern "C" fn CommitmentSigned_hash(o: &CommitmentSigned) -> u64 {
5740 if o.inner.is_null() { return 0; }
5741 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5742 #[allow(deprecated)]
5743 let mut hasher = core::hash::SipHasher::new();
5744 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5745 core::hash::Hasher::finish(&hasher)
5747 /// Checks if two CommitmentSigneds contain equal inner contents.
5748 /// This ignores pointers and is_owned flags and looks at the values in fields.
5749 /// Two objects with NULL inner values will be considered "equal" here.
5751 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
5752 if a.inner == b.inner { return true; }
5753 if a.inner.is_null() || b.inner.is_null() { return false; }
5754 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5757 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
5758 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
5760 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
5762 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
5765 pub struct RevokeAndACK {
5766 /// A pointer to the opaque Rust object.
5768 /// Nearly everywhere, inner must be non-null, however in places where
5769 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5770 pub inner: *mut nativeRevokeAndACK,
5771 /// Indicates that this is the only struct which contains the same pointer.
5773 /// Rust functions which take ownership of an object provided via an argument require
5774 /// this to be true and invalidate the object pointed to by inner.
5778 impl Drop for RevokeAndACK {
5779 fn drop(&mut self) {
5780 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
5781 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5785 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
5787 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
5789 /// Used only if an object of this type is returned as a trait impl by a method
5790 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
5791 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
5795 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
5796 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5798 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
5799 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5801 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5802 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
5803 assert!(self.is_owned);
5804 let ret = ObjOps::untweak_ptr(self.inner);
5805 self.inner = core::ptr::null_mut();
5811 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
5812 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5817 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
5818 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5820 /// The secret corresponding to the per-commitment point
5822 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
5823 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
5826 /// The secret corresponding to the per-commitment point
5828 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
5829 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
5831 /// The next sender-broadcast commitment transaction's per-commitment point
5833 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
5834 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
5835 crate::c_types::PublicKey::from_rust(&inner_val)
5837 /// The next sender-broadcast commitment transaction's per-commitment point
5839 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
5840 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
5842 /// Constructs a new RevokeAndACK given each field
5845 pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK {
5846 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
5847 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5848 per_commitment_secret: per_commitment_secret_arg.data,
5849 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
5850 }), is_owned: true }
5852 impl Clone for RevokeAndACK {
5853 fn clone(&self) -> Self {
5855 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
5856 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5862 /// Used only if an object of this type is returned as a trait impl by a method
5863 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
5864 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRevokeAndACK)).clone() })) as *mut c_void
5867 /// Creates a copy of the RevokeAndACK
5868 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
5871 /// Get a string which allows debug introspection of a RevokeAndACK object
5872 pub extern "C" fn RevokeAndACK_debug_str_void(o: *const c_void) -> Str {
5873 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::RevokeAndACK }).into()}
5874 /// Generates a non-cryptographic 64-bit hash of the RevokeAndACK.
5876 pub extern "C" fn RevokeAndACK_hash(o: &RevokeAndACK) -> u64 {
5877 if o.inner.is_null() { return 0; }
5878 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5879 #[allow(deprecated)]
5880 let mut hasher = core::hash::SipHasher::new();
5881 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5882 core::hash::Hasher::finish(&hasher)
5884 /// Checks if two RevokeAndACKs contain equal inner contents.
5885 /// This ignores pointers and is_owned flags and looks at the values in fields.
5886 /// Two objects with NULL inner values will be considered "equal" here.
5888 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
5889 if a.inner == b.inner { return true; }
5890 if a.inner.is_null() || b.inner.is_null() { return false; }
5891 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5894 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
5895 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
5897 /// An [`update_fee`] message to be sent to or received from a peer
5899 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
5902 pub struct UpdateFee {
5903 /// A pointer to the opaque Rust object.
5905 /// Nearly everywhere, inner must be non-null, however in places where
5906 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5907 pub inner: *mut nativeUpdateFee,
5908 /// Indicates that this is the only struct which contains the same pointer.
5910 /// Rust functions which take ownership of an object provided via an argument require
5911 /// this to be true and invalidate the object pointed to by inner.
5915 impl Drop for UpdateFee {
5916 fn drop(&mut self) {
5917 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
5918 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5922 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
5924 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
5926 /// Used only if an object of this type is returned as a trait impl by a method
5927 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
5928 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
5932 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
5933 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5935 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
5936 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5938 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5939 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
5940 assert!(self.is_owned);
5941 let ret = ObjOps::untweak_ptr(self.inner);
5942 self.inner = core::ptr::null_mut();
5948 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
5949 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5954 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
5955 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5957 /// Fee rate per 1000-weight of the transaction
5959 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
5960 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
5963 /// Fee rate per 1000-weight of the transaction
5965 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
5966 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
5968 /// Constructs a new UpdateFee given each field
5971 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
5972 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
5973 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5974 feerate_per_kw: feerate_per_kw_arg,
5975 }), is_owned: true }
5977 impl Clone for UpdateFee {
5978 fn clone(&self) -> Self {
5980 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
5981 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5987 /// Used only if an object of this type is returned as a trait impl by a method
5988 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
5989 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFee)).clone() })) as *mut c_void
5992 /// Creates a copy of the UpdateFee
5993 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
5996 /// Get a string which allows debug introspection of a UpdateFee object
5997 pub extern "C" fn UpdateFee_debug_str_void(o: *const c_void) -> Str {
5998 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFee }).into()}
5999 /// Generates a non-cryptographic 64-bit hash of the UpdateFee.
6001 pub extern "C" fn UpdateFee_hash(o: &UpdateFee) -> u64 {
6002 if o.inner.is_null() { return 0; }
6003 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6004 #[allow(deprecated)]
6005 let mut hasher = core::hash::SipHasher::new();
6006 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6007 core::hash::Hasher::finish(&hasher)
6009 /// Checks if two UpdateFees contain equal inner contents.
6010 /// This ignores pointers and is_owned flags and looks at the values in fields.
6011 /// Two objects with NULL inner values will be considered "equal" here.
6013 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
6014 if a.inner == b.inner { return true; }
6015 if a.inner.is_null() || b.inner.is_null() { return false; }
6016 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6019 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
6020 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
6022 /// A [`channel_reestablish`] message to be sent to or received from a peer.
6024 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
6027 pub struct ChannelReestablish {
6028 /// A pointer to the opaque Rust object.
6030 /// Nearly everywhere, inner must be non-null, however in places where
6031 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6032 pub inner: *mut nativeChannelReestablish,
6033 /// Indicates that this is the only struct which contains the same pointer.
6035 /// Rust functions which take ownership of an object provided via an argument require
6036 /// this to be true and invalidate the object pointed to by inner.
6040 impl Drop for ChannelReestablish {
6041 fn drop(&mut self) {
6042 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
6043 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6047 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
6049 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
6051 /// Used only if an object of this type is returned as a trait impl by a method
6052 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
6053 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
6056 impl ChannelReestablish {
6057 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
6058 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6060 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
6061 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6063 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6064 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
6065 assert!(self.is_owned);
6066 let ret = ObjOps::untweak_ptr(self.inner);
6067 self.inner = core::ptr::null_mut();
6073 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
6074 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
6079 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
6080 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
6082 /// The next commitment number for the sender
6084 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
6085 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
6088 /// The next commitment number for the sender
6090 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
6091 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
6093 /// The next commitment number for the recipient
6095 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
6096 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
6099 /// The next commitment number for the recipient
6101 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
6102 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
6104 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
6105 /// belonging to the recipient
6107 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
6108 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
6111 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
6112 /// belonging to the recipient
6114 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
6115 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
6117 /// The sender's per-commitment point for their current commitment transaction
6119 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
6120 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
6121 crate::c_types::PublicKey::from_rust(&inner_val)
6123 /// The sender's per-commitment point for their current commitment transaction
6125 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
6126 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
6128 /// The next funding transaction ID
6130 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
6131 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
6132 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: *(*inner_val.as_ref().unwrap()).clone().as_ref() } }) };
6135 /// The next funding transaction ID
6137 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
6138 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ val_opt.take() }.data[..]).unwrap() }})} };
6139 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
6141 /// Constructs a new ChannelReestablish given each field
6144 pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> ChannelReestablish {
6145 let mut local_next_funding_txid_arg = { /*next_funding_txid_arg*/ let next_funding_txid_arg_opt = next_funding_txid_arg; if next_funding_txid_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ next_funding_txid_arg_opt.take() }.data[..]).unwrap() }})} };
6146 ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
6147 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
6148 next_local_commitment_number: next_local_commitment_number_arg,
6149 next_remote_commitment_number: next_remote_commitment_number_arg,
6150 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
6151 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
6152 next_funding_txid: local_next_funding_txid_arg,
6153 }), is_owned: true }
6155 impl Clone for ChannelReestablish {
6156 fn clone(&self) -> Self {
6158 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
6159 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6165 /// Used only if an object of this type is returned as a trait impl by a method
6166 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
6167 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReestablish)).clone() })) as *mut c_void
6170 /// Creates a copy of the ChannelReestablish
6171 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
6174 /// Get a string which allows debug introspection of a ChannelReestablish object
6175 pub extern "C" fn ChannelReestablish_debug_str_void(o: *const c_void) -> Str {
6176 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelReestablish }).into()}
6177 /// Generates a non-cryptographic 64-bit hash of the ChannelReestablish.
6179 pub extern "C" fn ChannelReestablish_hash(o: &ChannelReestablish) -> u64 {
6180 if o.inner.is_null() { return 0; }
6181 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6182 #[allow(deprecated)]
6183 let mut hasher = core::hash::SipHasher::new();
6184 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6185 core::hash::Hasher::finish(&hasher)
6187 /// Checks if two ChannelReestablishs contain equal inner contents.
6188 /// This ignores pointers and is_owned flags and looks at the values in fields.
6189 /// Two objects with NULL inner values will be considered "equal" here.
6191 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
6192 if a.inner == b.inner { return true; }
6193 if a.inner.is_null() || b.inner.is_null() { return false; }
6194 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6197 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
6198 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
6200 /// An [`announcement_signatures`] message to be sent to or received from a peer.
6202 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
6205 pub struct AnnouncementSignatures {
6206 /// A pointer to the opaque Rust object.
6208 /// Nearly everywhere, inner must be non-null, however in places where
6209 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6210 pub inner: *mut nativeAnnouncementSignatures,
6211 /// Indicates that this is the only struct which contains the same pointer.
6213 /// Rust functions which take ownership of an object provided via an argument require
6214 /// this to be true and invalidate the object pointed to by inner.
6218 impl Drop for AnnouncementSignatures {
6219 fn drop(&mut self) {
6220 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
6221 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6225 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
6227 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
6229 /// Used only if an object of this type is returned as a trait impl by a method
6230 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
6231 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
6234 impl AnnouncementSignatures {
6235 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
6236 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6238 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
6239 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6241 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6242 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
6243 assert!(self.is_owned);
6244 let ret = ObjOps::untweak_ptr(self.inner);
6245 self.inner = core::ptr::null_mut();
6251 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
6252 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
6257 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
6258 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
6260 /// The short channel ID
6262 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
6263 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6266 /// The short channel ID
6268 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
6269 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6271 /// A signature by the node key
6273 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
6274 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
6275 crate::c_types::ECDSASignature::from_rust(&inner_val)
6277 /// A signature by the node key
6279 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
6280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
6282 /// A signature by the funding key
6284 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
6285 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
6286 crate::c_types::ECDSASignature::from_rust(&inner_val)
6288 /// A signature by the funding key
6290 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
6291 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
6293 /// Constructs a new AnnouncementSignatures given each field
6296 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_arg: crate::c_types::ECDSASignature) -> AnnouncementSignatures {
6297 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
6298 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
6299 short_channel_id: short_channel_id_arg,
6300 node_signature: node_signature_arg.into_rust(),
6301 bitcoin_signature: bitcoin_signature_arg.into_rust(),
6302 }), is_owned: true }
6304 impl Clone for AnnouncementSignatures {
6305 fn clone(&self) -> Self {
6307 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
6308 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6314 /// Used only if an object of this type is returned as a trait impl by a method
6315 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
6316 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAnnouncementSignatures)).clone() })) as *mut c_void
6319 /// Creates a copy of the AnnouncementSignatures
6320 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
6323 /// Get a string which allows debug introspection of a AnnouncementSignatures object
6324 pub extern "C" fn AnnouncementSignatures_debug_str_void(o: *const c_void) -> Str {
6325 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AnnouncementSignatures }).into()}
6326 /// Generates a non-cryptographic 64-bit hash of the AnnouncementSignatures.
6328 pub extern "C" fn AnnouncementSignatures_hash(o: &AnnouncementSignatures) -> u64 {
6329 if o.inner.is_null() { return 0; }
6330 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6331 #[allow(deprecated)]
6332 let mut hasher = core::hash::SipHasher::new();
6333 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6334 core::hash::Hasher::finish(&hasher)
6336 /// Checks if two AnnouncementSignaturess contain equal inner contents.
6337 /// This ignores pointers and is_owned flags and looks at the values in fields.
6338 /// Two objects with NULL inner values will be considered "equal" here.
6340 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
6341 if a.inner == b.inner { return true; }
6342 if a.inner.is_null() || b.inner.is_null() { return false; }
6343 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6345 /// An address which can be used to connect to a remote peer.
6349 pub enum SocketAddress {
6350 /// An IPv4 address and port on which the peer is listening.
6352 /// The 4-byte IPv4 address
6353 addr: crate::c_types::FourBytes,
6354 /// The port on which the node is listening
6357 /// An IPv6 address and port on which the peer is listening.
6359 /// The 16-byte IPv6 address
6360 addr: crate::c_types::SixteenBytes,
6361 /// The port on which the node is listening
6364 /// An old-style Tor onion address/port on which the peer is listening.
6366 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
6367 /// addresses. Thus, the details are not parsed here.
6369 crate::c_types::TwelveBytes),
6370 /// A new-style Tor onion address/port on which the peer is listening.
6372 /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
6373 /// wrap as base32 and append \".onion\".
6375 /// The ed25519 long-term public key of the peer
6376 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
6377 /// The checksum of the pubkey and version, as included in the onion address
6379 /// The version byte, as defined by the Tor Onion v3 spec.
6381 /// The port on which the node is listening
6384 /// A hostname/port on which the peer is listening.
6386 /// The hostname on which the node is listening.
6387 hostname: crate::lightning::util::ser::Hostname,
6388 /// The port on which the node is listening.
6392 use lightning::ln::msgs::SocketAddress as SocketAddressImport;
6393 pub(crate) type nativeSocketAddress = SocketAddressImport;
6395 impl SocketAddress {
6397 pub(crate) fn to_native(&self) -> nativeSocketAddress {
6399 SocketAddress::TcpIpV4 {ref addr, ref port, } => {
6400 let mut addr_nonref = Clone::clone(addr);
6401 let mut port_nonref = Clone::clone(port);
6402 nativeSocketAddress::TcpIpV4 {
6403 addr: addr_nonref.data,
6407 SocketAddress::TcpIpV6 {ref addr, ref port, } => {
6408 let mut addr_nonref = Clone::clone(addr);
6409 let mut port_nonref = Clone::clone(port);
6410 nativeSocketAddress::TcpIpV6 {
6411 addr: addr_nonref.data,
6415 SocketAddress::OnionV2 (ref a, ) => {
6416 let mut a_nonref = Clone::clone(a);
6417 nativeSocketAddress::OnionV2 (
6421 SocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
6422 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
6423 let mut checksum_nonref = Clone::clone(checksum);
6424 let mut version_nonref = Clone::clone(version);
6425 let mut port_nonref = Clone::clone(port);
6426 nativeSocketAddress::OnionV3 {
6427 ed25519_pubkey: ed25519_pubkey_nonref.data,
6428 checksum: checksum_nonref,
6429 version: version_nonref,
6433 SocketAddress::Hostname {ref hostname, ref port, } => {
6434 let mut hostname_nonref = Clone::clone(hostname);
6435 let mut port_nonref = Clone::clone(port);
6436 nativeSocketAddress::Hostname {
6437 hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
6444 pub(crate) fn into_native(self) -> nativeSocketAddress {
6446 SocketAddress::TcpIpV4 {mut addr, mut port, } => {
6447 nativeSocketAddress::TcpIpV4 {
6452 SocketAddress::TcpIpV6 {mut addr, mut port, } => {
6453 nativeSocketAddress::TcpIpV6 {
6458 SocketAddress::OnionV2 (mut a, ) => {
6459 nativeSocketAddress::OnionV2 (
6463 SocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
6464 nativeSocketAddress::OnionV3 {
6465 ed25519_pubkey: ed25519_pubkey.data,
6471 SocketAddress::Hostname {mut hostname, mut port, } => {
6472 nativeSocketAddress::Hostname {
6473 hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
6480 pub(crate) fn from_native(native: &SocketAddressImport) -> Self {
6481 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSocketAddress) };
6483 nativeSocketAddress::TcpIpV4 {ref addr, ref port, } => {
6484 let mut addr_nonref = Clone::clone(addr);
6485 let mut port_nonref = Clone::clone(port);
6486 SocketAddress::TcpIpV4 {
6487 addr: crate::c_types::FourBytes { data: addr_nonref },
6491 nativeSocketAddress::TcpIpV6 {ref addr, ref port, } => {
6492 let mut addr_nonref = Clone::clone(addr);
6493 let mut port_nonref = Clone::clone(port);
6494 SocketAddress::TcpIpV6 {
6495 addr: crate::c_types::SixteenBytes { data: addr_nonref },
6499 nativeSocketAddress::OnionV2 (ref a, ) => {
6500 let mut a_nonref = Clone::clone(a);
6501 SocketAddress::OnionV2 (
6502 crate::c_types::TwelveBytes { data: a_nonref },
6505 nativeSocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
6506 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
6507 let mut checksum_nonref = Clone::clone(checksum);
6508 let mut version_nonref = Clone::clone(version);
6509 let mut port_nonref = Clone::clone(port);
6510 SocketAddress::OnionV3 {
6511 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
6512 checksum: checksum_nonref,
6513 version: version_nonref,
6517 nativeSocketAddress::Hostname {ref hostname, ref port, } => {
6518 let mut hostname_nonref = Clone::clone(hostname);
6519 let mut port_nonref = Clone::clone(port);
6520 SocketAddress::Hostname {
6521 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
6528 pub(crate) fn native_into(native: nativeSocketAddress) -> Self {
6530 nativeSocketAddress::TcpIpV4 {mut addr, mut port, } => {
6531 SocketAddress::TcpIpV4 {
6532 addr: crate::c_types::FourBytes { data: addr },
6536 nativeSocketAddress::TcpIpV6 {mut addr, mut port, } => {
6537 SocketAddress::TcpIpV6 {
6538 addr: crate::c_types::SixteenBytes { data: addr },
6542 nativeSocketAddress::OnionV2 (mut a, ) => {
6543 SocketAddress::OnionV2 (
6544 crate::c_types::TwelveBytes { data: a },
6547 nativeSocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
6548 SocketAddress::OnionV3 {
6549 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
6555 nativeSocketAddress::Hostname {mut hostname, mut port, } => {
6556 SocketAddress::Hostname {
6557 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
6564 /// Frees any resources used by the SocketAddress
6566 pub extern "C" fn SocketAddress_free(this_ptr: SocketAddress) { }
6567 /// Creates a copy of the SocketAddress
6569 pub extern "C" fn SocketAddress_clone(orig: &SocketAddress) -> SocketAddress {
6573 /// Used only if an object of this type is returned as a trait impl by a method
6574 pub(crate) extern "C" fn SocketAddress_clone_void(this_ptr: *const c_void) -> *mut c_void {
6575 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddress)).clone() })) as *mut c_void
6578 /// Used only if an object of this type is returned as a trait impl by a method
6579 pub(crate) extern "C" fn SocketAddress_free_void(this_ptr: *mut c_void) {
6580 let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddress) };
6583 /// Utility method to constructs a new TcpIpV4-variant SocketAddress
6584 pub extern "C" fn SocketAddress_tcp_ip_v4(addr: crate::c_types::FourBytes, port: u16) -> SocketAddress {
6585 SocketAddress::TcpIpV4 {
6591 /// Utility method to constructs a new TcpIpV6-variant SocketAddress
6592 pub extern "C" fn SocketAddress_tcp_ip_v6(addr: crate::c_types::SixteenBytes, port: u16) -> SocketAddress {
6593 SocketAddress::TcpIpV6 {
6599 /// Utility method to constructs a new OnionV2-variant SocketAddress
6600 pub extern "C" fn SocketAddress_onion_v2(a: crate::c_types::TwelveBytes) -> SocketAddress {
6601 SocketAddress::OnionV2(a, )
6604 /// Utility method to constructs a new OnionV3-variant SocketAddress
6605 pub extern "C" fn SocketAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> SocketAddress {
6606 SocketAddress::OnionV3 {
6614 /// Utility method to constructs a new Hostname-variant SocketAddress
6615 pub extern "C" fn SocketAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> SocketAddress {
6616 SocketAddress::Hostname {
6621 /// Get a string which allows debug introspection of a SocketAddress object
6622 pub extern "C" fn SocketAddress_debug_str_void(o: *const c_void) -> Str {
6623 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SocketAddress }).into()}
6624 /// Generates a non-cryptographic 64-bit hash of the SocketAddress.
6626 pub extern "C" fn SocketAddress_hash(o: &SocketAddress) -> u64 {
6627 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6628 #[allow(deprecated)]
6629 let mut hasher = core::hash::SipHasher::new();
6630 core::hash::Hash::hash(&o.to_native(), &mut hasher);
6631 core::hash::Hasher::finish(&hasher)
6633 /// Checks if two SocketAddresss contain equal inner contents.
6634 /// This ignores pointers and is_owned flags and looks at the values in fields.
6636 pub extern "C" fn SocketAddress_eq(a: &SocketAddress, b: &SocketAddress) -> bool {
6637 if &a.to_native() == &b.to_native() { true } else { false }
6640 /// Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read
6641 pub extern "C" fn SocketAddress_write(obj: &crate::lightning::ln::msgs::SocketAddress) -> crate::c_types::derived::CVec_u8Z {
6642 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6645 pub(crate) extern "C" fn SocketAddress_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6646 SocketAddress_write(unsafe { &*(obj as *const SocketAddress) })
6649 /// Read a SocketAddress from a byte array, created by SocketAddress_write
6650 pub extern "C" fn SocketAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SocketAddressDecodeErrorZ {
6651 let res: Result<lightning::ln::msgs::SocketAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6652 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
6655 /// [`SocketAddress`] error variants
6659 pub enum SocketAddressParseError {
6660 /// Socket address (IPv4/IPv6) parsing error
6662 /// Invalid input format
6666 /// Invalid onion v3 address
6669 use lightning::ln::msgs::SocketAddressParseError as SocketAddressParseErrorImport;
6670 pub(crate) type nativeSocketAddressParseError = SocketAddressParseErrorImport;
6672 impl SocketAddressParseError {
6674 pub(crate) fn to_native(&self) -> nativeSocketAddressParseError {
6676 SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
6677 SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
6678 SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
6679 SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
6683 pub(crate) fn into_native(self) -> nativeSocketAddressParseError {
6685 SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
6686 SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
6687 SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
6688 SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
6692 pub(crate) fn from_native(native: &SocketAddressParseErrorImport) -> Self {
6693 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSocketAddressParseError) };
6695 nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
6696 nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
6697 nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
6698 nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
6702 pub(crate) fn native_into(native: nativeSocketAddressParseError) -> Self {
6704 nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
6705 nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
6706 nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
6707 nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
6711 /// Creates a copy of the SocketAddressParseError
6713 pub extern "C" fn SocketAddressParseError_clone(orig: &SocketAddressParseError) -> SocketAddressParseError {
6717 /// Used only if an object of this type is returned as a trait impl by a method
6718 pub(crate) extern "C" fn SocketAddressParseError_clone_void(this_ptr: *const c_void) -> *mut c_void {
6719 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddressParseError)).clone() })) as *mut c_void
6722 /// Used only if an object of this type is returned as a trait impl by a method
6723 pub(crate) extern "C" fn SocketAddressParseError_free_void(this_ptr: *mut c_void) {
6724 let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddressParseError) };
6727 /// Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError
6728 pub extern "C" fn SocketAddressParseError_socket_addr_parse() -> SocketAddressParseError {
6729 SocketAddressParseError::SocketAddrParse}
6731 /// Utility method to constructs a new InvalidInput-variant SocketAddressParseError
6732 pub extern "C" fn SocketAddressParseError_invalid_input() -> SocketAddressParseError {
6733 SocketAddressParseError::InvalidInput}
6735 /// Utility method to constructs a new InvalidPort-variant SocketAddressParseError
6736 pub extern "C" fn SocketAddressParseError_invalid_port() -> SocketAddressParseError {
6737 SocketAddressParseError::InvalidPort}
6739 /// Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError
6740 pub extern "C" fn SocketAddressParseError_invalid_onion_v3() -> SocketAddressParseError {
6741 SocketAddressParseError::InvalidOnionV3}
6742 /// Get a string which allows debug introspection of a SocketAddressParseError object
6743 pub extern "C" fn SocketAddressParseError_debug_str_void(o: *const c_void) -> Str {
6744 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SocketAddressParseError }).into()}
6745 /// Generates a non-cryptographic 64-bit hash of the SocketAddressParseError.
6747 pub extern "C" fn SocketAddressParseError_hash(o: &SocketAddressParseError) -> u64 {
6748 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6749 #[allow(deprecated)]
6750 let mut hasher = core::hash::SipHasher::new();
6751 core::hash::Hash::hash(&o.to_native(), &mut hasher);
6752 core::hash::Hasher::finish(&hasher)
6754 /// Checks if two SocketAddressParseErrors contain equal inner contents.
6755 /// This ignores pointers and is_owned flags and looks at the values in fields.
6757 pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool {
6758 if &a.to_native() == &b.to_native() { true } else { false }
6760 /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
6762 /// The host part must end with \".onion\".
6764 pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6765 let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
6766 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::SocketAddressParseError::native_into(e) }).into() };
6771 /// Get the string representation of a SocketAddress object
6772 pub extern "C" fn SocketAddress_to_str(o: &crate::lightning::ln::msgs::SocketAddress) -> Str {
6773 alloc::format!("{}", &o.to_native()).into()
6776 /// Read a SocketAddress object from a string
6777 pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6778 match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
6780 crate::c_types::CResultTempl::ok(
6781 crate::lightning::ln::msgs::SocketAddress::native_into(r)
6785 crate::c_types::CResultTempl::err(
6786 crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
6791 /// Represents the set of gossip messages that require a signature from a node's identity key.
6795 pub enum UnsignedGossipMessage {
6796 /// An unsigned channel announcement.
6797 ChannelAnnouncement(
6798 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
6799 /// An unsigned channel update.
6801 crate::lightning::ln::msgs::UnsignedChannelUpdate),
6802 /// An unsigned node announcement.
6804 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
6806 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
6807 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
6809 impl UnsignedGossipMessage {
6811 pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
6813 UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6814 let mut a_nonref = Clone::clone(a);
6815 nativeUnsignedGossipMessage::ChannelAnnouncement (
6816 *unsafe { Box::from_raw(a_nonref.take_inner()) },
6819 UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6820 let mut a_nonref = Clone::clone(a);
6821 nativeUnsignedGossipMessage::ChannelUpdate (
6822 *unsafe { Box::from_raw(a_nonref.take_inner()) },
6825 UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6826 let mut a_nonref = Clone::clone(a);
6827 nativeUnsignedGossipMessage::NodeAnnouncement (
6828 *unsafe { Box::from_raw(a_nonref.take_inner()) },
6834 pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
6836 UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6837 nativeUnsignedGossipMessage::ChannelAnnouncement (
6838 *unsafe { Box::from_raw(a.take_inner()) },
6841 UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6842 nativeUnsignedGossipMessage::ChannelUpdate (
6843 *unsafe { Box::from_raw(a.take_inner()) },
6846 UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6847 nativeUnsignedGossipMessage::NodeAnnouncement (
6848 *unsafe { Box::from_raw(a.take_inner()) },
6854 pub(crate) fn from_native(native: &UnsignedGossipMessageImport) -> Self {
6855 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeUnsignedGossipMessage) };
6857 nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6858 let mut a_nonref = Clone::clone(a);
6859 UnsignedGossipMessage::ChannelAnnouncement (
6860 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6863 nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6864 let mut a_nonref = Clone::clone(a);
6865 UnsignedGossipMessage::ChannelUpdate (
6866 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6869 nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6870 let mut a_nonref = Clone::clone(a);
6871 UnsignedGossipMessage::NodeAnnouncement (
6872 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6878 pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
6880 nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6881 UnsignedGossipMessage::ChannelAnnouncement (
6882 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6885 nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6886 UnsignedGossipMessage::ChannelUpdate (
6887 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
6890 nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6891 UnsignedGossipMessage::NodeAnnouncement (
6892 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6898 /// Frees any resources used by the UnsignedGossipMessage
6900 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
6901 /// Creates a copy of the UnsignedGossipMessage
6903 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
6907 /// Used only if an object of this type is returned as a trait impl by a method
6908 pub(crate) extern "C" fn UnsignedGossipMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
6909 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const UnsignedGossipMessage)).clone() })) as *mut c_void
6912 /// Used only if an object of this type is returned as a trait impl by a method
6913 pub(crate) extern "C" fn UnsignedGossipMessage_free_void(this_ptr: *mut c_void) {
6914 let _ = unsafe { Box::from_raw(this_ptr as *mut UnsignedGossipMessage) };
6917 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
6918 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
6919 UnsignedGossipMessage::ChannelAnnouncement(a, )
6922 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
6923 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
6924 UnsignedGossipMessage::ChannelUpdate(a, )
6927 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
6928 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
6929 UnsignedGossipMessage::NodeAnnouncement(a, )
6932 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
6933 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
6934 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6937 pub(crate) extern "C" fn UnsignedGossipMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6938 UnsignedGossipMessage_write(unsafe { &*(obj as *const UnsignedGossipMessage) })
6941 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
6942 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
6944 /// The unsigned part of a [`node_announcement`] message.
6946 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
6949 pub struct UnsignedNodeAnnouncement {
6950 /// A pointer to the opaque Rust object.
6952 /// Nearly everywhere, inner must be non-null, however in places where
6953 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6954 pub inner: *mut nativeUnsignedNodeAnnouncement,
6955 /// Indicates that this is the only struct which contains the same pointer.
6957 /// Rust functions which take ownership of an object provided via an argument require
6958 /// this to be true and invalidate the object pointed to by inner.
6962 impl Drop for UnsignedNodeAnnouncement {
6963 fn drop(&mut self) {
6964 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
6965 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6969 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
6971 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
6973 /// Used only if an object of this type is returned as a trait impl by a method
6974 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
6975 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
6978 impl UnsignedNodeAnnouncement {
6979 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
6980 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6982 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
6983 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6985 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6986 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
6987 assert!(self.is_owned);
6988 let ret = ObjOps::untweak_ptr(self.inner);
6989 self.inner = core::ptr::null_mut();
6993 /// The advertised features
6995 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
6996 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6997 crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false }
6999 /// The advertised features
7001 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
7002 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
7004 /// A strictly monotonic announcement counter, with gaps allowed
7006 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
7007 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
7010 /// A strictly monotonic announcement counter, with gaps allowed
7012 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
7013 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
7015 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
7018 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7019 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
7020 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
7022 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
7025 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7026 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
7028 /// An RGB color for UI purposes
7030 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
7031 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
7034 /// An RGB color for UI purposes
7036 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
7037 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
7039 /// An alias, for UI purposes.
7041 /// This should be sanitized before use. There is no guarantee of uniqueness.
7043 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
7044 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
7045 crate::lightning::routing::gossip::NodeAlias { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeAlias<>) as *mut _) }, is_owned: false }
7047 /// An alias, for UI purposes.
7049 /// This should be sanitized before use. There is no guarantee of uniqueness.
7051 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
7052 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
7054 /// List of addresses on which this node is reachable
7056 /// Returns a copy of the field.
7058 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
7059 let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
7060 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); };
7061 local_inner_val.into()
7063 /// List of addresses on which this node is reachable
7065 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
7066 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
7067 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
7069 impl Clone for UnsignedNodeAnnouncement {
7070 fn clone(&self) -> Self {
7072 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7073 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7079 /// Used only if an object of this type is returned as a trait impl by a method
7080 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7081 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
7084 /// Creates a copy of the UnsignedNodeAnnouncement
7085 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
7088 /// Get a string which allows debug introspection of a UnsignedNodeAnnouncement object
7089 pub extern "C" fn UnsignedNodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7090 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedNodeAnnouncement }).into()}
7091 /// Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement.
7093 pub extern "C" fn UnsignedNodeAnnouncement_hash(o: &UnsignedNodeAnnouncement) -> u64 {
7094 if o.inner.is_null() { return 0; }
7095 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7096 #[allow(deprecated)]
7097 let mut hasher = core::hash::SipHasher::new();
7098 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7099 core::hash::Hasher::finish(&hasher)
7101 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
7102 /// This ignores pointers and is_owned flags and looks at the values in fields.
7103 /// Two objects with NULL inner values will be considered "equal" here.
7105 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
7106 if a.inner == b.inner { return true; }
7107 if a.inner.is_null() || b.inner.is_null() { return false; }
7108 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7111 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
7112 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
7114 /// A [`node_announcement`] message to be sent to or received from a peer.
7116 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
7119 pub struct NodeAnnouncement {
7120 /// A pointer to the opaque Rust object.
7122 /// Nearly everywhere, inner must be non-null, however in places where
7123 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7124 pub inner: *mut nativeNodeAnnouncement,
7125 /// Indicates that this is the only struct which contains the same pointer.
7127 /// Rust functions which take ownership of an object provided via an argument require
7128 /// this to be true and invalidate the object pointed to by inner.
7132 impl Drop for NodeAnnouncement {
7133 fn drop(&mut self) {
7134 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
7135 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7139 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
7141 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
7143 /// Used only if an object of this type is returned as a trait impl by a method
7144 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
7145 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
7148 impl NodeAnnouncement {
7149 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
7150 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7152 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
7153 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7155 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7156 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
7157 assert!(self.is_owned);
7158 let ret = ObjOps::untweak_ptr(self.inner);
7159 self.inner = core::ptr::null_mut();
7163 /// The signature by the node key
7165 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
7166 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7167 crate::c_types::ECDSASignature::from_rust(&inner_val)
7169 /// The signature by the node key
7171 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
7172 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7174 /// The actual content of the announcement
7176 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
7177 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7178 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedNodeAnnouncement<>) as *mut _) }, is_owned: false }
7180 /// The actual content of the announcement
7182 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
7183 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7185 /// Constructs a new NodeAnnouncement given each field
7188 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
7189 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
7190 signature: signature_arg.into_rust(),
7191 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7192 }), is_owned: true }
7194 impl Clone for NodeAnnouncement {
7195 fn clone(&self) -> Self {
7197 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7198 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7204 /// Used only if an object of this type is returned as a trait impl by a method
7205 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7206 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncement)).clone() })) as *mut c_void
7209 /// Creates a copy of the NodeAnnouncement
7210 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
7213 /// Get a string which allows debug introspection of a NodeAnnouncement object
7214 pub extern "C" fn NodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7215 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::NodeAnnouncement }).into()}
7216 /// Generates a non-cryptographic 64-bit hash of the NodeAnnouncement.
7218 pub extern "C" fn NodeAnnouncement_hash(o: &NodeAnnouncement) -> u64 {
7219 if o.inner.is_null() { return 0; }
7220 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7221 #[allow(deprecated)]
7222 let mut hasher = core::hash::SipHasher::new();
7223 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7224 core::hash::Hasher::finish(&hasher)
7226 /// Checks if two NodeAnnouncements contain equal inner contents.
7227 /// This ignores pointers and is_owned flags and looks at the values in fields.
7228 /// Two objects with NULL inner values will be considered "equal" here.
7230 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
7231 if a.inner == b.inner { return true; }
7232 if a.inner.is_null() || b.inner.is_null() { return false; }
7233 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7236 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
7237 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
7239 /// The unsigned part of a [`channel_announcement`] message.
7241 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7244 pub struct UnsignedChannelAnnouncement {
7245 /// A pointer to the opaque Rust object.
7247 /// Nearly everywhere, inner must be non-null, however in places where
7248 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7249 pub inner: *mut nativeUnsignedChannelAnnouncement,
7250 /// Indicates that this is the only struct which contains the same pointer.
7252 /// Rust functions which take ownership of an object provided via an argument require
7253 /// this to be true and invalidate the object pointed to by inner.
7257 impl Drop for UnsignedChannelAnnouncement {
7258 fn drop(&mut self) {
7259 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
7260 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7264 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
7266 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
7268 /// Used only if an object of this type is returned as a trait impl by a method
7269 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7270 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
7273 impl UnsignedChannelAnnouncement {
7274 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
7275 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7277 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
7278 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7280 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7281 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
7282 assert!(self.is_owned);
7283 let ret = ObjOps::untweak_ptr(self.inner);
7284 self.inner = core::ptr::null_mut();
7288 /// The advertised channel features
7290 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
7291 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
7292 crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false }
7294 /// The advertised channel features
7296 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
7297 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
7299 /// The genesis hash of the blockchain where the channel is to be opened
7301 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
7302 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7305 /// The genesis hash of the blockchain where the channel is to be opened
7307 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
7308 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7310 /// The short channel ID
7312 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
7313 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7316 /// The short channel ID
7318 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
7319 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7321 /// One of the two `node_id`s which are endpoints of this channel
7323 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7324 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
7325 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
7327 /// One of the two `node_id`s which are endpoints of this channel
7329 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7330 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
7332 /// The other of the two `node_id`s which are endpoints of this channel
7334 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7335 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
7336 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
7338 /// The other of the two `node_id`s which are endpoints of this channel
7340 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7341 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
7343 /// The funding key for the first node
7345 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7346 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
7347 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
7349 /// The funding key for the first node
7351 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7352 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
7354 /// The funding key for the second node
7356 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7357 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
7358 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
7360 /// The funding key for the second node
7362 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7363 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
7365 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7368 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7370 /// Returns a copy of the field.
7372 pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
7373 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7374 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7375 local_inner_val.into()
7377 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7380 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7382 pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
7383 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7384 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7386 /// Constructs a new UnsignedChannelAnnouncement given each field
7389 pub extern "C" fn UnsignedChannelAnnouncement_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_id_1_arg: crate::lightning::routing::gossip::NodeId, mut node_id_2_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_1_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_2_arg: crate::lightning::routing::gossip::NodeId, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelAnnouncement {
7390 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7391 UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
7392 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
7393 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7394 short_channel_id: short_channel_id_arg,
7395 node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
7396 node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
7397 bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
7398 bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
7399 excess_data: local_excess_data_arg,
7400 }), is_owned: true }
7402 impl Clone for UnsignedChannelAnnouncement {
7403 fn clone(&self) -> Self {
7405 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7406 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7412 /// Used only if an object of this type is returned as a trait impl by a method
7413 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7414 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
7417 /// Creates a copy of the UnsignedChannelAnnouncement
7418 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
7421 /// Get a string which allows debug introspection of a UnsignedChannelAnnouncement object
7422 pub extern "C" fn UnsignedChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7423 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelAnnouncement }).into()}
7424 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement.
7426 pub extern "C" fn UnsignedChannelAnnouncement_hash(o: &UnsignedChannelAnnouncement) -> u64 {
7427 if o.inner.is_null() { return 0; }
7428 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7429 #[allow(deprecated)]
7430 let mut hasher = core::hash::SipHasher::new();
7431 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7432 core::hash::Hasher::finish(&hasher)
7434 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
7435 /// This ignores pointers and is_owned flags and looks at the values in fields.
7436 /// Two objects with NULL inner values will be considered "equal" here.
7438 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
7439 if a.inner == b.inner { return true; }
7440 if a.inner.is_null() || b.inner.is_null() { return false; }
7441 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7444 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
7445 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
7447 /// A [`channel_announcement`] message to be sent to or received from a peer.
7449 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7452 pub struct ChannelAnnouncement {
7453 /// A pointer to the opaque Rust object.
7455 /// Nearly everywhere, inner must be non-null, however in places where
7456 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7457 pub inner: *mut nativeChannelAnnouncement,
7458 /// Indicates that this is the only struct which contains the same pointer.
7460 /// Rust functions which take ownership of an object provided via an argument require
7461 /// this to be true and invalidate the object pointed to by inner.
7465 impl Drop for ChannelAnnouncement {
7466 fn drop(&mut self) {
7467 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
7468 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7472 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
7474 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
7476 /// Used only if an object of this type is returned as a trait impl by a method
7477 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7478 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
7481 impl ChannelAnnouncement {
7482 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
7483 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7485 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
7486 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7488 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7489 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
7490 assert!(self.is_owned);
7491 let ret = ObjOps::untweak_ptr(self.inner);
7492 self.inner = core::ptr::null_mut();
7496 /// Authentication of the announcement by the first public node
7498 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7499 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
7500 crate::c_types::ECDSASignature::from_rust(&inner_val)
7502 /// Authentication of the announcement by the first public node
7504 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7505 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
7507 /// Authentication of the announcement by the second public node
7509 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7510 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
7511 crate::c_types::ECDSASignature::from_rust(&inner_val)
7513 /// Authentication of the announcement by the second public node
7515 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7516 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
7518 /// Proof of funding UTXO ownership by the first public node
7520 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7521 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
7522 crate::c_types::ECDSASignature::from_rust(&inner_val)
7524 /// Proof of funding UTXO ownership by the first public node
7526 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7527 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
7529 /// Proof of funding UTXO ownership by the second public node
7531 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7532 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
7533 crate::c_types::ECDSASignature::from_rust(&inner_val)
7535 /// Proof of funding UTXO ownership by the second public node
7537 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7538 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
7540 /// The actual announcement
7542 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
7543 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7544 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }
7546 /// The actual announcement
7548 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
7549 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7551 /// Constructs a new ChannelAnnouncement given each field
7554 pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_types::ECDSASignature, mut node_signature_2_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_1_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_2_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
7555 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
7556 node_signature_1: node_signature_1_arg.into_rust(),
7557 node_signature_2: node_signature_2_arg.into_rust(),
7558 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
7559 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
7560 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7561 }), is_owned: true }
7563 impl Clone for ChannelAnnouncement {
7564 fn clone(&self) -> Self {
7566 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7567 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7573 /// Used only if an object of this type is returned as a trait impl by a method
7574 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7575 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelAnnouncement)).clone() })) as *mut c_void
7578 /// Creates a copy of the ChannelAnnouncement
7579 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
7582 /// Get a string which allows debug introspection of a ChannelAnnouncement object
7583 pub extern "C" fn ChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7584 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelAnnouncement }).into()}
7585 /// Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement.
7587 pub extern "C" fn ChannelAnnouncement_hash(o: &ChannelAnnouncement) -> u64 {
7588 if o.inner.is_null() { return 0; }
7589 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7590 #[allow(deprecated)]
7591 let mut hasher = core::hash::SipHasher::new();
7592 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7593 core::hash::Hasher::finish(&hasher)
7595 /// Checks if two ChannelAnnouncements contain equal inner contents.
7596 /// This ignores pointers and is_owned flags and looks at the values in fields.
7597 /// Two objects with NULL inner values will be considered "equal" here.
7599 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
7600 if a.inner == b.inner { return true; }
7601 if a.inner.is_null() || b.inner.is_null() { return false; }
7602 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7605 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
7606 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
7608 /// The unsigned part of a [`channel_update`] message.
7610 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7613 pub struct UnsignedChannelUpdate {
7614 /// A pointer to the opaque Rust object.
7616 /// Nearly everywhere, inner must be non-null, however in places where
7617 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7618 pub inner: *mut nativeUnsignedChannelUpdate,
7619 /// Indicates that this is the only struct which contains the same pointer.
7621 /// Rust functions which take ownership of an object provided via an argument require
7622 /// this to be true and invalidate the object pointed to by inner.
7626 impl Drop for UnsignedChannelUpdate {
7627 fn drop(&mut self) {
7628 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
7629 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7633 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
7635 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
7637 /// Used only if an object of this type is returned as a trait impl by a method
7638 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
7639 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
7642 impl UnsignedChannelUpdate {
7643 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
7644 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7646 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
7647 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7649 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7650 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
7651 assert!(self.is_owned);
7652 let ret = ObjOps::untweak_ptr(self.inner);
7653 self.inner = core::ptr::null_mut();
7657 /// The genesis hash of the blockchain where the channel is to be opened
7659 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
7660 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7663 /// The genesis hash of the blockchain where the channel is to be opened
7665 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
7666 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7668 /// The short channel ID
7670 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
7671 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7674 /// The short channel ID
7676 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7677 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7679 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7681 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
7682 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
7685 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7687 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7688 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
7692 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
7693 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
7698 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
7699 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
7701 /// The number of blocks such that if:
7702 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7703 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7704 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7705 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7706 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7707 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7708 /// constructing the route.
7710 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
7711 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
7714 /// The number of blocks such that if:
7715 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7716 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7717 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7718 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7719 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7720 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7721 /// constructing the route.
7723 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
7724 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
7726 /// The minimum HTLC size incoming to sender, in milli-satoshi
7728 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7729 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
7732 /// The minimum HTLC size incoming to sender, in milli-satoshi
7734 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7735 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
7737 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7739 /// This used to be optional.
7741 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7742 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
7745 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7747 /// This used to be optional.
7749 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7750 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
7752 /// The base HTLC fee charged by sender, in milli-satoshi
7754 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
7755 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
7758 /// The base HTLC fee charged by sender, in milli-satoshi
7760 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7761 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
7763 /// The amount to fee multiplier, in micro-satoshi
7765 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
7766 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
7769 /// The amount to fee multiplier, in micro-satoshi
7771 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7772 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
7774 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7777 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7779 /// Returns a copy of the field.
7781 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
7782 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7783 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7784 local_inner_val.into()
7786 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7789 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7791 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
7792 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7793 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7795 /// Constructs a new UnsignedChannelUpdate given each field
7798 pub extern "C" fn UnsignedChannelUpdate_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut timestamp_arg: u32, mut flags_arg: u8, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelUpdate {
7799 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7800 UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
7801 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7802 short_channel_id: short_channel_id_arg,
7803 timestamp: timestamp_arg,
7805 cltv_expiry_delta: cltv_expiry_delta_arg,
7806 htlc_minimum_msat: htlc_minimum_msat_arg,
7807 htlc_maximum_msat: htlc_maximum_msat_arg,
7808 fee_base_msat: fee_base_msat_arg,
7809 fee_proportional_millionths: fee_proportional_millionths_arg,
7810 excess_data: local_excess_data_arg,
7811 }), is_owned: true }
7813 impl Clone for UnsignedChannelUpdate {
7814 fn clone(&self) -> Self {
7816 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7817 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7823 /// Used only if an object of this type is returned as a trait impl by a method
7824 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7825 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
7828 /// Creates a copy of the UnsignedChannelUpdate
7829 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
7832 /// Get a string which allows debug introspection of a UnsignedChannelUpdate object
7833 pub extern "C" fn UnsignedChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7834 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelUpdate }).into()}
7835 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate.
7837 pub extern "C" fn UnsignedChannelUpdate_hash(o: &UnsignedChannelUpdate) -> u64 {
7838 if o.inner.is_null() { return 0; }
7839 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7840 #[allow(deprecated)]
7841 let mut hasher = core::hash::SipHasher::new();
7842 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7843 core::hash::Hasher::finish(&hasher)
7845 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
7846 /// This ignores pointers and is_owned flags and looks at the values in fields.
7847 /// Two objects with NULL inner values will be considered "equal" here.
7849 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
7850 if a.inner == b.inner { return true; }
7851 if a.inner.is_null() || b.inner.is_null() { return false; }
7852 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7855 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
7856 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
7858 /// A [`channel_update`] message to be sent to or received from a peer.
7860 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7863 pub struct ChannelUpdate {
7864 /// A pointer to the opaque Rust object.
7866 /// Nearly everywhere, inner must be non-null, however in places where
7867 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7868 pub inner: *mut nativeChannelUpdate,
7869 /// Indicates that this is the only struct which contains the same pointer.
7871 /// Rust functions which take ownership of an object provided via an argument require
7872 /// this to be true and invalidate the object pointed to by inner.
7876 impl Drop for ChannelUpdate {
7877 fn drop(&mut self) {
7878 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
7879 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7883 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
7885 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
7887 /// Used only if an object of this type is returned as a trait impl by a method
7888 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
7889 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
7892 impl ChannelUpdate {
7893 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
7894 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7896 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
7897 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7899 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7900 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
7901 assert!(self.is_owned);
7902 let ret = ObjOps::untweak_ptr(self.inner);
7903 self.inner = core::ptr::null_mut();
7907 /// A signature of the channel update
7909 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
7910 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7911 crate::c_types::ECDSASignature::from_rust(&inner_val)
7913 /// A signature of the channel update
7915 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
7916 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7918 /// The actual channel update
7920 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
7921 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7922 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedChannelUpdate<>) as *mut _) }, is_owned: false }
7924 /// The actual channel update
7926 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
7927 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7929 /// Constructs a new ChannelUpdate given each field
7932 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
7933 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
7934 signature: signature_arg.into_rust(),
7935 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7936 }), is_owned: true }
7938 impl Clone for ChannelUpdate {
7939 fn clone(&self) -> Self {
7941 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7942 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7948 /// Used only if an object of this type is returned as a trait impl by a method
7949 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7950 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelUpdate)).clone() })) as *mut c_void
7953 /// Creates a copy of the ChannelUpdate
7954 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
7957 /// Get a string which allows debug introspection of a ChannelUpdate object
7958 pub extern "C" fn ChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7959 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelUpdate }).into()}
7960 /// Generates a non-cryptographic 64-bit hash of the ChannelUpdate.
7962 pub extern "C" fn ChannelUpdate_hash(o: &ChannelUpdate) -> u64 {
7963 if o.inner.is_null() { return 0; }
7964 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7965 #[allow(deprecated)]
7966 let mut hasher = core::hash::SipHasher::new();
7967 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7968 core::hash::Hasher::finish(&hasher)
7970 /// Checks if two ChannelUpdates contain equal inner contents.
7971 /// This ignores pointers and is_owned flags and looks at the values in fields.
7972 /// Two objects with NULL inner values will be considered "equal" here.
7974 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
7975 if a.inner == b.inner { return true; }
7976 if a.inner.is_null() || b.inner.is_null() { return false; }
7977 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7980 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
7981 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
7983 /// A [`query_channel_range`] message is used to query a peer for channel
7984 /// UTXOs in a range of blocks. The recipient of a query makes a best
7985 /// effort to reply to the query using one or more [`ReplyChannelRange`]
7988 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
7991 pub struct QueryChannelRange {
7992 /// A pointer to the opaque Rust object.
7994 /// Nearly everywhere, inner must be non-null, however in places where
7995 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7996 pub inner: *mut nativeQueryChannelRange,
7997 /// Indicates that this is the only struct which contains the same pointer.
7999 /// Rust functions which take ownership of an object provided via an argument require
8000 /// this to be true and invalidate the object pointed to by inner.
8004 impl Drop for QueryChannelRange {
8005 fn drop(&mut self) {
8006 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
8007 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8011 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
8013 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
8015 /// Used only if an object of this type is returned as a trait impl by a method
8016 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
8017 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
8020 impl QueryChannelRange {
8021 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
8022 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8024 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
8025 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8027 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8028 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
8029 assert!(self.is_owned);
8030 let ret = ObjOps::untweak_ptr(self.inner);
8031 self.inner = core::ptr::null_mut();
8035 /// The genesis hash of the blockchain being queried
8037 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
8038 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8041 /// The genesis hash of the blockchain being queried
8043 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
8044 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8046 /// The height of the first block for the channel UTXOs being queried
8048 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
8049 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
8052 /// The height of the first block for the channel UTXOs being queried
8054 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
8055 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
8057 /// The number of blocks to include in the query results
8059 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
8060 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
8063 /// The number of blocks to include in the query results
8065 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
8066 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
8068 /// Constructs a new QueryChannelRange given each field
8071 pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32) -> QueryChannelRange {
8072 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
8073 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8074 first_blocknum: first_blocknum_arg,
8075 number_of_blocks: number_of_blocks_arg,
8076 }), is_owned: true }
8078 impl Clone for QueryChannelRange {
8079 fn clone(&self) -> Self {
8081 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
8082 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8088 /// Used only if an object of this type is returned as a trait impl by a method
8089 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8090 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryChannelRange)).clone() })) as *mut c_void
8093 /// Creates a copy of the QueryChannelRange
8094 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
8097 /// Get a string which allows debug introspection of a QueryChannelRange object
8098 pub extern "C" fn QueryChannelRange_debug_str_void(o: *const c_void) -> Str {
8099 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryChannelRange }).into()}
8100 /// Generates a non-cryptographic 64-bit hash of the QueryChannelRange.
8102 pub extern "C" fn QueryChannelRange_hash(o: &QueryChannelRange) -> u64 {
8103 if o.inner.is_null() { return 0; }
8104 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8105 #[allow(deprecated)]
8106 let mut hasher = core::hash::SipHasher::new();
8107 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8108 core::hash::Hasher::finish(&hasher)
8110 /// Checks if two QueryChannelRanges contain equal inner contents.
8111 /// This ignores pointers and is_owned flags and looks at the values in fields.
8112 /// Two objects with NULL inner values will be considered "equal" here.
8114 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
8115 if a.inner == b.inner { return true; }
8116 if a.inner.is_null() || b.inner.is_null() { return false; }
8117 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8120 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
8121 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
8123 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
8126 /// Multiple `reply_channel_range` messages can be sent in reply
8127 /// to a single [`QueryChannelRange`] message. The query recipient makes a
8128 /// best effort to respond based on their local network view which may
8129 /// not be a perfect view of the network. The `short_channel_id`s in the
8130 /// reply are encoded. We only support `encoding_type=0` uncompressed
8131 /// serialization and do not support `encoding_type=1` zlib serialization.
8133 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
8136 pub struct ReplyChannelRange {
8137 /// A pointer to the opaque Rust object.
8139 /// Nearly everywhere, inner must be non-null, however in places where
8140 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8141 pub inner: *mut nativeReplyChannelRange,
8142 /// Indicates that this is the only struct which contains the same pointer.
8144 /// Rust functions which take ownership of an object provided via an argument require
8145 /// this to be true and invalidate the object pointed to by inner.
8149 impl Drop for ReplyChannelRange {
8150 fn drop(&mut self) {
8151 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
8152 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8156 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
8158 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
8160 /// Used only if an object of this type is returned as a trait impl by a method
8161 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
8162 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
8165 impl ReplyChannelRange {
8166 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
8167 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8169 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
8170 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8172 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8173 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
8174 assert!(self.is_owned);
8175 let ret = ObjOps::untweak_ptr(self.inner);
8176 self.inner = core::ptr::null_mut();
8180 /// The genesis hash of the blockchain being queried
8182 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
8183 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8186 /// The genesis hash of the blockchain being queried
8188 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
8189 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8191 /// The height of the first block in the range of the reply
8193 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
8194 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
8197 /// The height of the first block in the range of the reply
8199 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8200 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
8202 /// The number of blocks included in the range of the reply
8204 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
8205 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
8208 /// The number of blocks included in the range of the reply
8210 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8211 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
8213 /// True when this is the final reply for a query
8215 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
8216 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
8219 /// True when this is the final reply for a query
8221 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
8222 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
8224 /// The `short_channel_id`s in the channel range
8226 /// Returns a copy of the field.
8228 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
8229 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8230 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8231 local_inner_val.into()
8233 /// The `short_channel_id`s in the channel range
8235 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
8236 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8237 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8239 /// Constructs a new ReplyChannelRange given each field
8242 pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut sync_complete_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange {
8243 let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); };
8244 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
8245 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8246 first_blocknum: first_blocknum_arg,
8247 number_of_blocks: number_of_blocks_arg,
8248 sync_complete: sync_complete_arg,
8249 short_channel_ids: local_short_channel_ids_arg,
8250 }), is_owned: true }
8252 impl Clone for ReplyChannelRange {
8253 fn clone(&self) -> Self {
8255 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
8256 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8262 /// Used only if an object of this type is returned as a trait impl by a method
8263 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8264 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyChannelRange)).clone() })) as *mut c_void
8267 /// Creates a copy of the ReplyChannelRange
8268 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
8271 /// Get a string which allows debug introspection of a ReplyChannelRange object
8272 pub extern "C" fn ReplyChannelRange_debug_str_void(o: *const c_void) -> Str {
8273 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyChannelRange }).into()}
8274 /// Generates a non-cryptographic 64-bit hash of the ReplyChannelRange.
8276 pub extern "C" fn ReplyChannelRange_hash(o: &ReplyChannelRange) -> u64 {
8277 if o.inner.is_null() { return 0; }
8278 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8279 #[allow(deprecated)]
8280 let mut hasher = core::hash::SipHasher::new();
8281 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8282 core::hash::Hasher::finish(&hasher)
8284 /// Checks if two ReplyChannelRanges contain equal inner contents.
8285 /// This ignores pointers and is_owned flags and looks at the values in fields.
8286 /// Two objects with NULL inner values will be considered "equal" here.
8288 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
8289 if a.inner == b.inner { return true; }
8290 if a.inner.is_null() || b.inner.is_null() { return false; }
8291 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8294 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
8295 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
8297 /// A [`query_short_channel_ids`] message is used to query a peer for
8298 /// routing gossip messages related to one or more `short_channel_id`s.
8300 /// The query recipient will reply with the latest, if available,
8301 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
8302 /// it maintains for the requested `short_channel_id`s followed by a
8303 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
8304 /// this query are encoded. We only support `encoding_type=0` uncompressed
8305 /// serialization and do not support `encoding_type=1` zlib serialization.
8307 /// [`query_short_channel_ids`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
8310 pub struct QueryShortChannelIds {
8311 /// A pointer to the opaque Rust object.
8313 /// Nearly everywhere, inner must be non-null, however in places where
8314 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8315 pub inner: *mut nativeQueryShortChannelIds,
8316 /// Indicates that this is the only struct which contains the same pointer.
8318 /// Rust functions which take ownership of an object provided via an argument require
8319 /// this to be true and invalidate the object pointed to by inner.
8323 impl Drop for QueryShortChannelIds {
8324 fn drop(&mut self) {
8325 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
8326 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8330 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
8332 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
8334 /// Used only if an object of this type is returned as a trait impl by a method
8335 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
8336 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
8339 impl QueryShortChannelIds {
8340 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
8341 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8343 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
8344 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8346 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8347 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
8348 assert!(self.is_owned);
8349 let ret = ObjOps::untweak_ptr(self.inner);
8350 self.inner = core::ptr::null_mut();
8354 /// The genesis hash of the blockchain being queried
8356 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
8357 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8360 /// The genesis hash of the blockchain being queried
8362 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
8363 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8365 /// The short_channel_ids that are being queried
8367 /// Returns a copy of the field.
8369 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
8370 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8371 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8372 local_inner_val.into()
8374 /// The short_channel_ids that are being queried
8376 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
8377 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8378 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8380 /// Constructs a new QueryShortChannelIds given each field
8383 pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> QueryShortChannelIds {
8384 let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); };
8385 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
8386 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8387 short_channel_ids: local_short_channel_ids_arg,
8388 }), is_owned: true }
8390 impl Clone for QueryShortChannelIds {
8391 fn clone(&self) -> Self {
8393 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
8394 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8400 /// Used only if an object of this type is returned as a trait impl by a method
8401 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
8402 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryShortChannelIds)).clone() })) as *mut c_void
8405 /// Creates a copy of the QueryShortChannelIds
8406 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
8409 /// Get a string which allows debug introspection of a QueryShortChannelIds object
8410 pub extern "C" fn QueryShortChannelIds_debug_str_void(o: *const c_void) -> Str {
8411 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryShortChannelIds }).into()}
8412 /// Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds.
8414 pub extern "C" fn QueryShortChannelIds_hash(o: &QueryShortChannelIds) -> u64 {
8415 if o.inner.is_null() { return 0; }
8416 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8417 #[allow(deprecated)]
8418 let mut hasher = core::hash::SipHasher::new();
8419 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8420 core::hash::Hasher::finish(&hasher)
8422 /// Checks if two QueryShortChannelIdss contain equal inner contents.
8423 /// This ignores pointers and is_owned flags and looks at the values in fields.
8424 /// Two objects with NULL inner values will be considered "equal" here.
8426 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
8427 if a.inner == b.inner { return true; }
8428 if a.inner.is_null() || b.inner.is_null() { return false; }
8429 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8432 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
8433 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
8435 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
8436 /// message. The query recipient makes a best
8437 /// effort to respond based on their local network view which may not be
8438 /// a perfect view of the network.
8440 /// [`reply_short_channel_ids_end`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
8443 pub struct ReplyShortChannelIdsEnd {
8444 /// A pointer to the opaque Rust object.
8446 /// Nearly everywhere, inner must be non-null, however in places where
8447 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8448 pub inner: *mut nativeReplyShortChannelIdsEnd,
8449 /// Indicates that this is the only struct which contains the same pointer.
8451 /// Rust functions which take ownership of an object provided via an argument require
8452 /// this to be true and invalidate the object pointed to by inner.
8456 impl Drop for ReplyShortChannelIdsEnd {
8457 fn drop(&mut self) {
8458 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
8459 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8463 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
8465 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
8467 /// Used only if an object of this type is returned as a trait impl by a method
8468 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
8469 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
8472 impl ReplyShortChannelIdsEnd {
8473 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
8474 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8476 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
8477 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8479 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8480 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
8481 assert!(self.is_owned);
8482 let ret = ObjOps::untweak_ptr(self.inner);
8483 self.inner = core::ptr::null_mut();
8487 /// The genesis hash of the blockchain that was queried
8489 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
8490 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8493 /// The genesis hash of the blockchain that was queried
8495 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
8496 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8498 /// Indicates if the query recipient maintains up-to-date channel
8499 /// information for the `chain_hash`
8501 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
8502 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
8505 /// Indicates if the query recipient maintains up-to-date channel
8506 /// information for the `chain_hash`
8508 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
8509 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
8511 /// Constructs a new ReplyShortChannelIdsEnd given each field
8514 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
8515 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
8516 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8517 full_information: full_information_arg,
8518 }), is_owned: true }
8520 impl Clone for ReplyShortChannelIdsEnd {
8521 fn clone(&self) -> Self {
8523 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
8524 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8530 /// Used only if an object of this type is returned as a trait impl by a method
8531 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
8532 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
8535 /// Creates a copy of the ReplyShortChannelIdsEnd
8536 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
8539 /// Get a string which allows debug introspection of a ReplyShortChannelIdsEnd object
8540 pub extern "C" fn ReplyShortChannelIdsEnd_debug_str_void(o: *const c_void) -> Str {
8541 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyShortChannelIdsEnd }).into()}
8542 /// Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd.
8544 pub extern "C" fn ReplyShortChannelIdsEnd_hash(o: &ReplyShortChannelIdsEnd) -> u64 {
8545 if o.inner.is_null() { return 0; }
8546 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8547 #[allow(deprecated)]
8548 let mut hasher = core::hash::SipHasher::new();
8549 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8550 core::hash::Hasher::finish(&hasher)
8552 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
8553 /// This ignores pointers and is_owned flags and looks at the values in fields.
8554 /// Two objects with NULL inner values will be considered "equal" here.
8556 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
8557 if a.inner == b.inner { return true; }
8558 if a.inner.is_null() || b.inner.is_null() { return false; }
8559 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8562 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
8563 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
8565 /// A [`gossip_timestamp_filter`] message is used by a node to request
8566 /// gossip relay for messages in the requested time range when the
8567 /// `gossip_queries` feature has been negotiated.
8569 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
8572 pub struct GossipTimestampFilter {
8573 /// A pointer to the opaque Rust object.
8575 /// Nearly everywhere, inner must be non-null, however in places where
8576 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8577 pub inner: *mut nativeGossipTimestampFilter,
8578 /// Indicates that this is the only struct which contains the same pointer.
8580 /// Rust functions which take ownership of an object provided via an argument require
8581 /// this to be true and invalidate the object pointed to by inner.
8585 impl Drop for GossipTimestampFilter {
8586 fn drop(&mut self) {
8587 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
8588 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8592 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
8594 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
8596 /// Used only if an object of this type is returned as a trait impl by a method
8597 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
8598 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
8601 impl GossipTimestampFilter {
8602 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
8603 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8605 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
8606 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8608 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8609 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
8610 assert!(self.is_owned);
8611 let ret = ObjOps::untweak_ptr(self.inner);
8612 self.inner = core::ptr::null_mut();
8616 /// The genesis hash of the blockchain for channel and node information
8618 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
8619 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8622 /// The genesis hash of the blockchain for channel and node information
8624 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
8625 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8627 /// The starting unix timestamp
8629 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
8630 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
8633 /// The starting unix timestamp
8635 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8636 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
8638 /// The range of information in seconds
8640 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
8641 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
8644 /// The range of information in seconds
8646 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8647 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
8649 /// Constructs a new GossipTimestampFilter given each field
8652 pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_timestamp_arg: u32, mut timestamp_range_arg: u32) -> GossipTimestampFilter {
8653 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
8654 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8655 first_timestamp: first_timestamp_arg,
8656 timestamp_range: timestamp_range_arg,
8657 }), is_owned: true }
8659 impl Clone for GossipTimestampFilter {
8660 fn clone(&self) -> Self {
8662 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
8663 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8669 /// Used only if an object of this type is returned as a trait impl by a method
8670 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
8671 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeGossipTimestampFilter)).clone() })) as *mut c_void
8674 /// Creates a copy of the GossipTimestampFilter
8675 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
8678 /// Get a string which allows debug introspection of a GossipTimestampFilter object
8679 pub extern "C" fn GossipTimestampFilter_debug_str_void(o: *const c_void) -> Str {
8680 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::GossipTimestampFilter }).into()}
8681 /// Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter.
8683 pub extern "C" fn GossipTimestampFilter_hash(o: &GossipTimestampFilter) -> u64 {
8684 if o.inner.is_null() { return 0; }
8685 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8686 #[allow(deprecated)]
8687 let mut hasher = core::hash::SipHasher::new();
8688 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8689 core::hash::Hasher::finish(&hasher)
8691 /// Checks if two GossipTimestampFilters contain equal inner contents.
8692 /// This ignores pointers and is_owned flags and looks at the values in fields.
8693 /// Two objects with NULL inner values will be considered "equal" here.
8695 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
8696 if a.inner == b.inner { return true; }
8697 if a.inner.is_null() || b.inner.is_null() { return false; }
8698 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8700 /// Used to put an error message in a [`LightningError`].
8704 pub enum ErrorAction {
8705 /// The peer took some action which made us think they were useless. Disconnect them.
8707 /// An error message which we should make an effort to send before we disconnect.
8709 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
8710 msg: crate::lightning::ln::msgs::ErrorMessage,
8712 /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
8713 DisconnectPeerWithWarning {
8714 /// A warning message which we should make an effort to send before we disconnect.
8715 msg: crate::lightning::ln::msgs::WarningMessage,
8717 /// The peer did something harmless that we weren't able to process, just log and ignore
8719 /// The peer did something harmless that we weren't able to meaningfully process.
8720 /// If the error is logged, log it at the given level.
8722 crate::lightning::util::logger::Level),
8723 /// The peer provided us with a gossip message which we'd already seen. In most cases this
8724 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
8725 /// our own channel announcements.
8726 IgnoreDuplicateGossip,
8727 /// The peer did something incorrect. Tell them.
8729 /// The message to send.
8730 msg: crate::lightning::ln::msgs::ErrorMessage,
8732 /// The peer did something incorrect. Tell them without closing any channels.
8733 SendWarningMessage {
8734 /// The message to send.
8735 msg: crate::lightning::ln::msgs::WarningMessage,
8736 /// The peer may have done something harmless that we weren't able to meaningfully process,
8737 /// though we should still tell them about it.
8738 /// If this event is logged, log it at the given level.
8739 log_level: crate::lightning::util::logger::Level,
8742 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
8743 pub(crate) type nativeErrorAction = ErrorActionImport;
8747 pub(crate) fn to_native(&self) -> nativeErrorAction {
8749 ErrorAction::DisconnectPeer {ref msg, } => {
8750 let mut msg_nonref = Clone::clone(msg);
8751 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
8752 nativeErrorAction::DisconnectPeer {
8753 msg: local_msg_nonref,
8756 ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8757 let mut msg_nonref = Clone::clone(msg);
8758 nativeErrorAction::DisconnectPeerWithWarning {
8759 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8762 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8763 ErrorAction::IgnoreAndLog (ref a, ) => {
8764 let mut a_nonref = Clone::clone(a);
8765 nativeErrorAction::IgnoreAndLog (
8766 a_nonref.into_native(),
8769 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8770 ErrorAction::SendErrorMessage {ref msg, } => {
8771 let mut msg_nonref = Clone::clone(msg);
8772 nativeErrorAction::SendErrorMessage {
8773 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8776 ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8777 let mut msg_nonref = Clone::clone(msg);
8778 let mut log_level_nonref = Clone::clone(log_level);
8779 nativeErrorAction::SendWarningMessage {
8780 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8781 log_level: log_level_nonref.into_native(),
8787 pub(crate) fn into_native(self) -> nativeErrorAction {
8789 ErrorAction::DisconnectPeer {mut msg, } => {
8790 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
8791 nativeErrorAction::DisconnectPeer {
8795 ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8796 nativeErrorAction::DisconnectPeerWithWarning {
8797 msg: *unsafe { Box::from_raw(msg.take_inner()) },
8800 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8801 ErrorAction::IgnoreAndLog (mut a, ) => {
8802 nativeErrorAction::IgnoreAndLog (
8806 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8807 ErrorAction::SendErrorMessage {mut msg, } => {
8808 nativeErrorAction::SendErrorMessage {
8809 msg: *unsafe { Box::from_raw(msg.take_inner()) },
8812 ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8813 nativeErrorAction::SendWarningMessage {
8814 msg: *unsafe { Box::from_raw(msg.take_inner()) },
8815 log_level: log_level.into_native(),
8821 pub(crate) fn from_native(native: &ErrorActionImport) -> Self {
8822 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeErrorAction) };
8824 nativeErrorAction::DisconnectPeer {ref msg, } => {
8825 let mut msg_nonref = Clone::clone(msg);
8826 let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true };
8827 ErrorAction::DisconnectPeer {
8828 msg: local_msg_nonref,
8831 nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8832 let mut msg_nonref = Clone::clone(msg);
8833 ErrorAction::DisconnectPeerWithWarning {
8834 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8837 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8838 nativeErrorAction::IgnoreAndLog (ref a, ) => {
8839 let mut a_nonref = Clone::clone(a);
8840 ErrorAction::IgnoreAndLog (
8841 crate::lightning::util::logger::Level::native_into(a_nonref),
8844 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8845 nativeErrorAction::SendErrorMessage {ref msg, } => {
8846 let mut msg_nonref = Clone::clone(msg);
8847 ErrorAction::SendErrorMessage {
8848 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8851 nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8852 let mut msg_nonref = Clone::clone(msg);
8853 let mut log_level_nonref = Clone::clone(log_level);
8854 ErrorAction::SendWarningMessage {
8855 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8856 log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
8862 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
8864 nativeErrorAction::DisconnectPeer {mut msg, } => {
8865 let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true };
8866 ErrorAction::DisconnectPeer {
8870 nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8871 ErrorAction::DisconnectPeerWithWarning {
8872 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8875 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8876 nativeErrorAction::IgnoreAndLog (mut a, ) => {
8877 ErrorAction::IgnoreAndLog (
8878 crate::lightning::util::logger::Level::native_into(a),
8881 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8882 nativeErrorAction::SendErrorMessage {mut msg, } => {
8883 ErrorAction::SendErrorMessage {
8884 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8887 nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8888 ErrorAction::SendWarningMessage {
8889 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8890 log_level: crate::lightning::util::logger::Level::native_into(log_level),
8896 /// Frees any resources used by the ErrorAction
8898 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
8899 /// Creates a copy of the ErrorAction
8901 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
8905 /// Used only if an object of this type is returned as a trait impl by a method
8906 pub(crate) extern "C" fn ErrorAction_clone_void(this_ptr: *const c_void) -> *mut c_void {
8907 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ErrorAction)).clone() })) as *mut c_void
8910 /// Used only if an object of this type is returned as a trait impl by a method
8911 pub(crate) extern "C" fn ErrorAction_free_void(this_ptr: *mut c_void) {
8912 let _ = unsafe { Box::from_raw(this_ptr as *mut ErrorAction) };
8915 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
8916 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8917 ErrorAction::DisconnectPeer {
8922 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
8923 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
8924 ErrorAction::DisconnectPeerWithWarning {
8929 /// Utility method to constructs a new IgnoreError-variant ErrorAction
8930 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
8931 ErrorAction::IgnoreError}
8933 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
8934 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
8935 ErrorAction::IgnoreAndLog(a, )
8938 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
8939 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
8940 ErrorAction::IgnoreDuplicateGossip}
8942 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
8943 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8944 ErrorAction::SendErrorMessage {
8949 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
8950 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
8951 ErrorAction::SendWarningMessage {
8956 /// Get a string which allows debug introspection of a ErrorAction object
8957 pub extern "C" fn ErrorAction_debug_str_void(o: *const c_void) -> Str {
8958 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorAction }).into()}
8959 /// Generates a non-cryptographic 64-bit hash of the ErrorAction.
8961 pub extern "C" fn ErrorAction_hash(o: &ErrorAction) -> u64 {
8962 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8963 #[allow(deprecated)]
8964 let mut hasher = core::hash::SipHasher::new();
8965 core::hash::Hash::hash(&o.to_native(), &mut hasher);
8966 core::hash::Hasher::finish(&hasher)
8969 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
8970 pub(crate) type nativeLightningError = nativeLightningErrorImport;
8972 /// An Err type for failure to process messages.
8975 pub struct LightningError {
8976 /// A pointer to the opaque Rust object.
8978 /// Nearly everywhere, inner must be non-null, however in places where
8979 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8980 pub inner: *mut nativeLightningError,
8981 /// Indicates that this is the only struct which contains the same pointer.
8983 /// Rust functions which take ownership of an object provided via an argument require
8984 /// this to be true and invalidate the object pointed to by inner.
8988 impl Drop for LightningError {
8989 fn drop(&mut self) {
8990 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
8991 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8995 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
8997 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
8999 /// Used only if an object of this type is returned as a trait impl by a method
9000 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
9001 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
9004 impl LightningError {
9005 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
9006 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9008 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
9009 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9011 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9012 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
9013 assert!(self.is_owned);
9014 let ret = ObjOps::untweak_ptr(self.inner);
9015 self.inner = core::ptr::null_mut();
9019 /// A human-readable message describing the error
9021 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
9022 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
9023 inner_val.as_str().into()
9025 /// A human-readable message describing the error
9027 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
9028 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
9030 /// The action which should be taken against the offending peer.
9032 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
9033 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
9034 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
9036 /// The action which should be taken against the offending peer.
9038 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
9039 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
9041 /// Constructs a new LightningError given each field
9044 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
9045 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
9046 err: err_arg.into_string(),
9047 action: action_arg.into_native(),
9048 }), is_owned: true }
9050 impl Clone for LightningError {
9051 fn clone(&self) -> Self {
9053 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
9054 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9060 /// Used only if an object of this type is returned as a trait impl by a method
9061 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
9062 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLightningError)).clone() })) as *mut c_void
9065 /// Creates a copy of the LightningError
9066 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
9069 /// Get a string which allows debug introspection of a LightningError object
9070 pub extern "C" fn LightningError_debug_str_void(o: *const c_void) -> Str {
9071 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::LightningError }).into()}
9073 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
9074 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
9076 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
9077 /// transaction updates if they were pending.
9080 pub struct CommitmentUpdate {
9081 /// A pointer to the opaque Rust object.
9083 /// Nearly everywhere, inner must be non-null, however in places where
9084 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9085 pub inner: *mut nativeCommitmentUpdate,
9086 /// Indicates that this is the only struct which contains the same pointer.
9088 /// Rust functions which take ownership of an object provided via an argument require
9089 /// this to be true and invalidate the object pointed to by inner.
9093 impl Drop for CommitmentUpdate {
9094 fn drop(&mut self) {
9095 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
9096 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9100 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
9102 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
9104 /// Used only if an object of this type is returned as a trait impl by a method
9105 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
9106 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
9109 impl CommitmentUpdate {
9110 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
9111 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9113 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
9114 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9116 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9117 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
9118 assert!(self.is_owned);
9119 let ret = ObjOps::untweak_ptr(self.inner);
9120 self.inner = core::ptr::null_mut();
9124 /// `update_add_htlc` messages which should be sent
9126 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
9127 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
9128 let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false } }); };
9129 local_inner_val.into()
9131 /// `update_add_htlc` messages which should be sent
9133 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
9134 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9135 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
9137 /// `update_fulfill_htlc` messages which should be sent
9139 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
9140 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
9141 let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false } }); };
9142 local_inner_val.into()
9144 /// `update_fulfill_htlc` messages which should be sent
9146 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
9147 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9148 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
9150 /// `update_fail_htlc` messages which should be sent
9152 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
9153 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
9154 let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false } }); };
9155 local_inner_val.into()
9157 /// `update_fail_htlc` messages which should be sent
9159 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
9160 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9161 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
9163 /// `update_fail_malformed_htlc` messages which should be sent
9165 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
9166 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
9167 let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false } }); };
9168 local_inner_val.into()
9170 /// `update_fail_malformed_htlc` messages which should be sent
9172 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
9173 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9174 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
9176 /// An `update_fee` message which should be sent
9178 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9180 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
9181 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
9182 let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::UpdateFee<>) as *mut _ }, is_owned: false };
9185 /// An `update_fee` message which should be sent
9187 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
9189 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
9190 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
9191 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
9193 /// A `commitment_signed` message which should be sent
9195 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
9196 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
9197 crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false }
9199 /// A `commitment_signed` message which should be sent
9201 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
9202 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
9204 /// Constructs a new CommitmentUpdate given each field
9206 /// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
9209 pub extern "C" fn CommitmentUpdate_new(mut update_add_htlcs_arg: crate::c_types::derived::CVec_UpdateAddHTLCZ, mut update_fulfill_htlcs_arg: crate::c_types::derived::CVec_UpdateFulfillHTLCZ, mut update_fail_htlcs_arg: crate::c_types::derived::CVec_UpdateFailHTLCZ, mut update_fail_malformed_htlcs_arg: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ, mut update_fee_arg: crate::lightning::ln::msgs::UpdateFee, mut commitment_signed_arg: crate::lightning::ln::msgs::CommitmentSigned) -> CommitmentUpdate {
9210 let mut local_update_add_htlcs_arg = Vec::new(); for mut item in update_add_htlcs_arg.into_rust().drain(..) { local_update_add_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9211 let mut local_update_fulfill_htlcs_arg = Vec::new(); for mut item in update_fulfill_htlcs_arg.into_rust().drain(..) { local_update_fulfill_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9212 let mut local_update_fail_htlcs_arg = Vec::new(); for mut item in update_fail_htlcs_arg.into_rust().drain(..) { local_update_fail_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9213 let mut local_update_fail_malformed_htlcs_arg = Vec::new(); for mut item in update_fail_malformed_htlcs_arg.into_rust().drain(..) { local_update_fail_malformed_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9214 let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_inner()) } }) };
9215 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
9216 update_add_htlcs: local_update_add_htlcs_arg,
9217 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
9218 update_fail_htlcs: local_update_fail_htlcs_arg,
9219 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
9220 update_fee: local_update_fee_arg,
9221 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
9222 }), is_owned: true }
9224 impl Clone for CommitmentUpdate {
9225 fn clone(&self) -> Self {
9227 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
9228 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9234 /// Used only if an object of this type is returned as a trait impl by a method
9235 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
9236 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentUpdate)).clone() })) as *mut c_void
9239 /// Creates a copy of the CommitmentUpdate
9240 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
9243 /// Get a string which allows debug introspection of a CommitmentUpdate object
9244 pub extern "C" fn CommitmentUpdate_debug_str_void(o: *const c_void) -> Str {
9245 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentUpdate }).into()}
9246 /// Generates a non-cryptographic 64-bit hash of the CommitmentUpdate.
9248 pub extern "C" fn CommitmentUpdate_hash(o: &CommitmentUpdate) -> u64 {
9249 if o.inner.is_null() { return 0; }
9250 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
9251 #[allow(deprecated)]
9252 let mut hasher = core::hash::SipHasher::new();
9253 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
9254 core::hash::Hasher::finish(&hasher)
9256 /// Checks if two CommitmentUpdates contain equal inner contents.
9257 /// This ignores pointers and is_owned flags and looks at the values in fields.
9258 /// Two objects with NULL inner values will be considered "equal" here.
9260 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
9261 if a.inner == b.inner { return true; }
9262 if a.inner.is_null() || b.inner.is_null() { return false; }
9263 if a.get_native_ref() == b.get_native_ref() { true } else { false }
9265 /// A trait to describe an object which can receive channel messages.
9267 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
9268 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
9270 pub struct ChannelMessageHandler {
9271 /// An opaque pointer which is passed to your function implementations as an argument.
9272 /// This has no meaning in the LDK, and can be NULL or any other value.
9273 pub this_arg: *mut c_void,
9274 /// Handle an incoming `open_channel` message from the given peer.
9275 pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel),
9276 /// Handle an incoming `open_channel2` message from the given peer.
9277 pub handle_open_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2),
9278 /// Handle an incoming `accept_channel` message from the given peer.
9279 pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel),
9280 /// Handle an incoming `accept_channel2` message from the given peer.
9281 pub handle_accept_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2),
9282 /// Handle an incoming `funding_created` message from the given peer.
9283 pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated),
9284 /// Handle an incoming `funding_signed` message from the given peer.
9285 pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned),
9286 /// Handle an incoming `channel_ready` message from the given peer.
9287 pub handle_channel_ready: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady),
9288 /// Handle an incoming `shutdown` message from the given peer.
9289 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
9290 /// Handle an incoming `closing_signed` message from the given peer.
9291 pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned),
9292 /// Handle an incoming `stfu` message from the given peer.
9293 pub handle_stfu: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Stfu),
9294 /// Handle an incoming `splice` message from the given peer.
9295 pub handle_splice: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Splice),
9296 /// Handle an incoming `splice_ack` message from the given peer.
9297 pub handle_splice_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceAck),
9298 /// Handle an incoming `splice_locked` message from the given peer.
9299 pub handle_splice_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceLocked),
9300 /// Handle an incoming `tx_add_input message` from the given peer.
9301 pub handle_tx_add_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput),
9302 /// Handle an incoming `tx_add_output` message from the given peer.
9303 pub handle_tx_add_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput),
9304 /// Handle an incoming `tx_remove_input` message from the given peer.
9305 pub handle_tx_remove_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput),
9306 /// Handle an incoming `tx_remove_output` message from the given peer.
9307 pub handle_tx_remove_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput),
9308 /// Handle an incoming `tx_complete message` from the given peer.
9309 pub handle_tx_complete: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete),
9310 /// Handle an incoming `tx_signatures` message from the given peer.
9311 pub handle_tx_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures),
9312 /// Handle an incoming `tx_init_rbf` message from the given peer.
9313 pub handle_tx_init_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf),
9314 /// Handle an incoming `tx_ack_rbf` message from the given peer.
9315 pub handle_tx_ack_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf),
9316 /// Handle an incoming `tx_abort message` from the given peer.
9317 pub handle_tx_abort: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort),
9318 /// Handle an incoming `update_add_htlc` message from the given peer.
9319 pub handle_update_add_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC),
9320 /// Handle an incoming `update_fulfill_htlc` message from the given peer.
9321 pub handle_update_fulfill_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC),
9322 /// Handle an incoming `update_fail_htlc` message from the given peer.
9323 pub handle_update_fail_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC),
9324 /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
9325 pub handle_update_fail_malformed_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC),
9326 /// Handle an incoming `commitment_signed` message from the given peer.
9327 pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned),
9328 /// Handle an incoming `revoke_and_ack` message from the given peer.
9329 pub handle_revoke_and_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK),
9330 /// Handle an incoming `update_fee` message from the given peer.
9331 pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee),
9332 /// Handle an incoming `announcement_signatures` message from the given peer.
9333 pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures),
9334 /// Indicates a connection to the peer failed/an existing connection was lost.
9335 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9336 /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
9338 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9339 /// with us. Implementors should be somewhat conservative about doing so, however, as other
9340 /// message handlers may still wish to communicate with this peer.
9341 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
9342 /// Handle an incoming `channel_reestablish` message from the given peer.
9343 pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish),
9344 /// Handle an incoming `channel_update` message from the given peer.
9345 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate),
9346 /// Handle an incoming `error` message from the given peer.
9347 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
9348 /// Gets the node feature flags which this handler itself supports. All available handlers are
9349 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9350 /// which are broadcasted in our [`NodeAnnouncement`] message.
9351 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9352 /// Gets the init feature flags which should be sent to the given peer. All available handlers
9353 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9354 /// which are sent in our [`Init`] message.
9356 /// Note that this method is called before [`Self::peer_connected`].
9357 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9358 /// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
9360 /// If it's `None`, then no particular network chain hash compatibility will be enforced when
9361 /// connecting to peers.
9362 pub get_chain_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ,
9363 /// Implementation of MessageSendEventsProvider for this object.
9364 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9365 /// Frees any resources associated with this object given its this_arg pointer.
9366 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9367 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9369 unsafe impl Send for ChannelMessageHandler {}
9370 unsafe impl Sync for ChannelMessageHandler {}
9372 pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
9373 ChannelMessageHandler {
9374 this_arg: orig.this_arg,
9375 handle_open_channel: Clone::clone(&orig.handle_open_channel),
9376 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
9377 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
9378 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
9379 handle_funding_created: Clone::clone(&orig.handle_funding_created),
9380 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
9381 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
9382 handle_shutdown: Clone::clone(&orig.handle_shutdown),
9383 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
9384 handle_stfu: Clone::clone(&orig.handle_stfu),
9385 handle_splice: Clone::clone(&orig.handle_splice),
9386 handle_splice_ack: Clone::clone(&orig.handle_splice_ack),
9387 handle_splice_locked: Clone::clone(&orig.handle_splice_locked),
9388 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
9389 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
9390 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
9391 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
9392 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
9393 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
9394 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
9395 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
9396 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
9397 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
9398 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
9399 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
9400 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
9401 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
9402 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
9403 handle_update_fee: Clone::clone(&orig.handle_update_fee),
9404 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
9405 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9406 peer_connected: Clone::clone(&orig.peer_connected),
9407 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
9408 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9409 handle_error: Clone::clone(&orig.handle_error),
9410 provided_node_features: Clone::clone(&orig.provided_node_features),
9411 provided_init_features: Clone::clone(&orig.provided_init_features),
9412 get_chain_hashes: Clone::clone(&orig.get_chain_hashes),
9413 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9414 free: Clone::clone(&orig.free),
9417 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
9418 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9419 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9420 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9425 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
9426 impl rustChannelMessageHandler for ChannelMessageHandler {
9427 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
9428 (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false })
9430 fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
9431 (self.handle_open_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannelV2<>) as *mut _) }, is_owned: false })
9433 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
9434 (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false })
9436 fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
9437 (self.handle_accept_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannelV2<>) as *mut _) }, is_owned: false })
9439 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
9440 (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingCreated<>) as *mut _) }, is_owned: false })
9442 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
9443 (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingSigned<>) as *mut _) }, is_owned: false })
9445 fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
9446 (self.handle_channel_ready)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReady { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReady<>) as *mut _) }, is_owned: false })
9448 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
9449 (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false })
9451 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
9452 (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ClosingSigned<>) as *mut _) }, is_owned: false })
9454 fn handle_stfu(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Stfu) {
9455 (self.handle_stfu)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Stfu { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Stfu<>) as *mut _) }, is_owned: false })
9457 fn handle_splice(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Splice) {
9458 (self.handle_splice)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Splice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Splice<>) as *mut _) }, is_owned: false })
9460 fn handle_splice_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::SpliceAck) {
9461 (self.handle_splice_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::SpliceAck { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::SpliceAck<>) as *mut _) }, is_owned: false })
9463 fn handle_splice_locked(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::SpliceLocked) {
9464 (self.handle_splice_locked)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::SpliceLocked { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::SpliceLocked<>) as *mut _) }, is_owned: false })
9466 fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
9467 (self.handle_tx_add_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddInput<>) as *mut _) }, is_owned: false })
9469 fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
9470 (self.handle_tx_add_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddOutput<>) as *mut _) }, is_owned: false })
9472 fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
9473 (self.handle_tx_remove_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveInput<>) as *mut _) }, is_owned: false })
9475 fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
9476 (self.handle_tx_remove_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveOutput<>) as *mut _) }, is_owned: false })
9478 fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
9479 (self.handle_tx_complete)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxComplete { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxComplete<>) as *mut _) }, is_owned: false })
9481 fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
9482 (self.handle_tx_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxSignatures<>) as *mut _) }, is_owned: false })
9484 fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
9485 (self.handle_tx_init_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxInitRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxInitRbf<>) as *mut _) }, is_owned: false })
9487 fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
9488 (self.handle_tx_ack_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAckRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAckRbf<>) as *mut _) }, is_owned: false })
9490 fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
9491 (self.handle_tx_abort)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAbort { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAbort<>) as *mut _) }, is_owned: false })
9493 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
9494 (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false })
9496 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
9497 (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false })
9499 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
9500 (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false })
9502 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
9503 (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false })
9505 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
9506 (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false })
9508 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
9509 (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::RevokeAndACK<>) as *mut _) }, is_owned: false })
9511 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
9512 (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFee<>) as *mut _) }, is_owned: false })
9514 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
9515 (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AnnouncementSignatures<>) as *mut _) }, is_owned: false })
9517 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9518 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9520 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9521 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
9522 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
9525 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
9526 (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReestablish<>) as *mut _) }, is_owned: false })
9528 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
9529 (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false })
9531 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
9532 (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false })
9534 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9535 let mut ret = (self.provided_node_features)(self.this_arg);
9536 *unsafe { Box::from_raw(ret.take_inner()) }
9538 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9539 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9540 *unsafe { Box::from_raw(ret.take_inner()) }
9542 fn get_chain_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
9543 let mut ret = (self.get_chain_hashes)(self.this_arg);
9544 let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { let mut local_ret_0 = Vec::new(); for mut item in { ret_opt.take() }.into_rust().drain(..) { local_ret_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_ret_0 }})} };
9549 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9550 // directly as a Deref trait in higher-level structs:
9551 impl core::ops::Deref for ChannelMessageHandler {
9553 fn deref(&self) -> &Self {
9557 impl core::ops::DerefMut for ChannelMessageHandler {
9558 fn deref_mut(&mut self) -> &mut Self {
9562 /// Calls the free function if one is set
9564 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
9565 impl Drop for ChannelMessageHandler {
9566 fn drop(&mut self) {
9567 if let Some(f) = self.free {
9572 /// A trait to describe an object which can receive routing messages.
9574 /// # Implementor DoS Warnings
9576 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
9577 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
9578 /// repeated disk I/O for queries accessing different parts of the network graph.
9580 pub struct RoutingMessageHandler {
9581 /// An opaque pointer which is passed to your function implementations as an argument.
9582 /// This has no meaning in the LDK, and can be NULL or any other value.
9583 pub this_arg: *mut c_void,
9584 /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
9585 /// `false` or returning an `Err` otherwise.
9586 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9587 /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
9588 /// or returning an `Err` otherwise.
9589 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9590 /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
9591 /// `false` or returning an `Err` otherwise.
9592 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9593 /// Gets channel announcements and updates required to dump our routing table to a remote node,
9594 /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
9595 /// for a single channel.
9596 pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
9597 /// Gets a node announcement required to dump our routing table to a remote node, starting at
9598 /// the node *after* the provided pubkey and including up to one announcement immediately
9599 /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
9600 /// If `None` is provided for `starting_point`, we start at the first node.
9602 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
9603 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9604 pub get_next_node_announcement: extern "C" fn (this_arg: *const c_void, starting_point: crate::lightning::routing::gossip::NodeId) -> crate::lightning::ln::msgs::NodeAnnouncement,
9605 /// Called when a connection is established with a peer. This can be used to
9606 /// perform routing table synchronization using a strategy defined by the
9609 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9610 /// with us. Implementors should be somewhat conservative about doing so, however, as other
9611 /// message handlers may still wish to communicate with this peer.
9612 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
9613 /// Handles the reply of a query we initiated to learn about channels
9614 /// for a given range of blocks. We can expect to receive one or more
9615 /// replies to a single query.
9616 pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9617 /// Handles the reply of a query we initiated asking for routing gossip
9618 /// messages for a list of channels. We should receive this message when
9619 /// a node has completed its best effort to send us the pertaining routing
9620 /// gossip messages.
9621 pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9622 /// Handles when a peer asks us to send a list of `short_channel_id`s
9623 /// for the requested range of blocks.
9624 pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9625 /// Handles when a peer asks us to send routing gossip messages for a
9626 /// list of `short_channel_id`s.
9627 pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9628 /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
9629 /// pending some async action. While there is no guarantee of the rate of future messages, the
9630 /// caller should seek to reduce the rate of new gossip messages handled, especially
9631 /// [`ChannelAnnouncement`]s.
9632 pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
9633 /// Gets the node feature flags which this handler itself supports. All available handlers are
9634 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9635 /// which are broadcasted in our [`NodeAnnouncement`] message.
9636 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9637 /// Gets the init feature flags which should be sent to the given peer. All available handlers
9638 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9639 /// which are sent in our [`Init`] message.
9641 /// Note that this method is called before [`Self::peer_connected`].
9642 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9643 /// Implementation of MessageSendEventsProvider for this object.
9644 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9645 /// Frees any resources associated with this object given its this_arg pointer.
9646 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9647 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9649 unsafe impl Send for RoutingMessageHandler {}
9650 unsafe impl Sync for RoutingMessageHandler {}
9652 pub(crate) fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
9653 RoutingMessageHandler {
9654 this_arg: orig.this_arg,
9655 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
9656 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
9657 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9658 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
9659 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
9660 peer_connected: Clone::clone(&orig.peer_connected),
9661 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
9662 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
9663 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
9664 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
9665 processing_queue_high: Clone::clone(&orig.processing_queue_high),
9666 provided_node_features: Clone::clone(&orig.provided_node_features),
9667 provided_init_features: Clone::clone(&orig.provided_init_features),
9668 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9669 free: Clone::clone(&orig.free),
9672 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
9673 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9674 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9675 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9680 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
9681 impl rustRoutingMessageHandler for RoutingMessageHandler {
9682 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9683 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _) }, is_owned: false });
9684 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9687 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9688 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelAnnouncement<>) as *mut _) }, is_owned: false });
9689 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9692 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
9693 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false });
9694 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9697 fn get_next_channel_announcement(&self, mut starting_point: u64) -> Option<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
9698 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
9699 let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = ret.take().to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }) } else { None };
9702 fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
9703 let mut local_starting_point = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if starting_point.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (starting_point.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false };
9704 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
9705 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9708 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9709 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
9710 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
9713 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9714 let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true });
9715 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9718 fn handle_reply_short_channel_ids_end(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> {
9719 let mut ret = (self.handle_reply_short_channel_ids_end)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(msg), is_owned: true });
9720 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9723 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9724 let mut ret = (self.handle_query_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true });
9725 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9728 fn handle_query_short_channel_ids(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
9729 let mut ret = (self.handle_query_short_channel_ids)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true });
9730 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9733 fn processing_queue_high(&self) -> bool {
9734 let mut ret = (self.processing_queue_high)(self.this_arg);
9737 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9738 let mut ret = (self.provided_node_features)(self.this_arg);
9739 *unsafe { Box::from_raw(ret.take_inner()) }
9741 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9742 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9743 *unsafe { Box::from_raw(ret.take_inner()) }
9747 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9748 // directly as a Deref trait in higher-level structs:
9749 impl core::ops::Deref for RoutingMessageHandler {
9751 fn deref(&self) -> &Self {
9755 impl core::ops::DerefMut for RoutingMessageHandler {
9756 fn deref_mut(&mut self) -> &mut Self {
9760 /// Calls the free function if one is set
9762 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
9763 impl Drop for RoutingMessageHandler {
9764 fn drop(&mut self) {
9765 if let Some(f) = self.free {
9770 /// A handler for received [`OnionMessage`]s and for providing generated ones to send.
9772 pub struct OnionMessageHandler {
9773 /// An opaque pointer which is passed to your function implementations as an argument.
9774 /// This has no meaning in the LDK, and can be NULL or any other value.
9775 pub this_arg: *mut c_void,
9776 /// Because much of the lightning network does not yet support forwarding onion messages, we
9777 /// may need to directly connect to a node which will forward a message for us. In such a case,
9778 /// this method will return the set of nodes which need connection by node_id and the
9779 /// corresponding socket addresses where they may accept incoming connections.
9781 /// Thus, this method should be polled regularly to detect messages await such a direct
9783 pub get_and_clear_connections_needed: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ,
9784 /// Handle an incoming `onion_message` message from the given peer.
9785 pub handle_onion_message: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage),
9786 /// Returns the next pending onion message for the peer with the given node id.
9788 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9789 pub next_onion_message_for_peer: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage,
9790 /// Called when a connection is established with a peer. Can be used to track which peers
9791 /// advertise onion message support and are online.
9793 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9794 /// with us. Implementors should be somewhat conservative about doing so, however, as other
9795 /// message handlers may still wish to communicate with this peer.
9796 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
9797 /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
9798 /// drop and refuse to forward onion messages to this peer.
9799 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9800 /// Performs actions that should happen roughly every ten seconds after startup. Allows handlers
9801 /// to drop any buffered onion messages intended for prospective peers.
9802 pub timer_tick_occurred: extern "C" fn (this_arg: *const c_void),
9803 /// Gets the node feature flags which this handler itself supports. All available handlers are
9804 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9805 /// which are broadcasted in our [`NodeAnnouncement`] message.
9806 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9807 /// Gets the init feature flags which should be sent to the given peer. All available handlers
9808 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9809 /// which are sent in our [`Init`] message.
9811 /// Note that this method is called before [`Self::peer_connected`].
9812 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9813 /// Frees any resources associated with this object given its this_arg pointer.
9814 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9815 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9817 unsafe impl Send for OnionMessageHandler {}
9818 unsafe impl Sync for OnionMessageHandler {}
9820 pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
9821 OnionMessageHandler {
9822 this_arg: orig.this_arg,
9823 get_and_clear_connections_needed: Clone::clone(&orig.get_and_clear_connections_needed),
9824 handle_onion_message: Clone::clone(&orig.handle_onion_message),
9825 next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
9826 peer_connected: Clone::clone(&orig.peer_connected),
9827 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9828 timer_tick_occurred: Clone::clone(&orig.timer_tick_occurred),
9829 provided_node_features: Clone::clone(&orig.provided_node_features),
9830 provided_init_features: Clone::clone(&orig.provided_init_features),
9831 free: Clone::clone(&orig.free),
9835 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
9836 impl rustOnionMessageHandler for OnionMessageHandler {
9837 fn get_and_clear_connections_needed(&self) -> Vec<(bitcoin::secp256k1::PublicKey, Vec<lightning::ln::msgs::SocketAddress>)> {
9838 let mut ret = (self.get_and_clear_connections_needed)(self.this_arg);
9839 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_native() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }); };
9842 fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
9843 (self.handle_onion_message)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id), &crate::lightning::ln::msgs::OnionMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OnionMessage<>) as *mut _) }, is_owned: false })
9845 fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
9846 let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
9847 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9850 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9851 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
9852 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
9855 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9856 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9858 fn timer_tick_occurred(&self) {
9859 (self.timer_tick_occurred)(self.this_arg)
9861 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9862 let mut ret = (self.provided_node_features)(self.this_arg);
9863 *unsafe { Box::from_raw(ret.take_inner()) }
9865 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9866 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9867 *unsafe { Box::from_raw(ret.take_inner()) }
9871 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9872 // directly as a Deref trait in higher-level structs:
9873 impl core::ops::Deref for OnionMessageHandler {
9875 fn deref(&self) -> &Self {
9879 impl core::ops::DerefMut for OnionMessageHandler {
9880 fn deref_mut(&mut self) -> &mut Self {
9884 /// Calls the free function if one is set
9886 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
9887 impl Drop for OnionMessageHandler {
9888 fn drop(&mut self) {
9889 if let Some(f) = self.free {
9895 use lightning::ln::msgs::FinalOnionHopData as nativeFinalOnionHopDataImport;
9896 pub(crate) type nativeFinalOnionHopData = nativeFinalOnionHopDataImport;
9898 /// Information communicated in the onion to the recipient for multi-part tracking and proof that
9899 /// the payment is associated with an invoice.
9902 pub struct FinalOnionHopData {
9903 /// A pointer to the opaque Rust object.
9905 /// Nearly everywhere, inner must be non-null, however in places where
9906 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9907 pub inner: *mut nativeFinalOnionHopData,
9908 /// Indicates that this is the only struct which contains the same pointer.
9910 /// Rust functions which take ownership of an object provided via an argument require
9911 /// this to be true and invalidate the object pointed to by inner.
9915 impl Drop for FinalOnionHopData {
9916 fn drop(&mut self) {
9917 if self.is_owned && !<*mut nativeFinalOnionHopData>::is_null(self.inner) {
9918 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9922 /// Frees any resources used by the FinalOnionHopData, if is_owned is set and inner is non-NULL.
9924 pub extern "C" fn FinalOnionHopData_free(this_obj: FinalOnionHopData) { }
9926 /// Used only if an object of this type is returned as a trait impl by a method
9927 pub(crate) extern "C" fn FinalOnionHopData_free_void(this_ptr: *mut c_void) {
9928 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFinalOnionHopData) };
9931 impl FinalOnionHopData {
9932 pub(crate) fn get_native_ref(&self) -> &'static nativeFinalOnionHopData {
9933 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9935 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFinalOnionHopData {
9936 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9938 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9939 pub(crate) fn take_inner(mut self) -> *mut nativeFinalOnionHopData {
9940 assert!(self.is_owned);
9941 let ret = ObjOps::untweak_ptr(self.inner);
9942 self.inner = core::ptr::null_mut();
9946 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9947 /// Because it is generated by the recipient and included in the invoice, it also provides
9948 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9950 pub extern "C" fn FinalOnionHopData_get_payment_secret(this_ptr: &FinalOnionHopData) -> *const [u8; 32] {
9951 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret;
9954 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9955 /// Because it is generated by the recipient and included in the invoice, it also provides
9956 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9958 pub extern "C" fn FinalOnionHopData_set_payment_secret(this_ptr: &mut FinalOnionHopData, mut val: crate::c_types::ThirtyTwoBytes) {
9959 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::PaymentSecret(val.data);
9961 /// The intended total amount that this payment is for.
9963 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9965 pub extern "C" fn FinalOnionHopData_get_total_msat(this_ptr: &FinalOnionHopData) -> u64 {
9966 let mut inner_val = &mut this_ptr.get_native_mut_ref().total_msat;
9969 /// The intended total amount that this payment is for.
9971 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9973 pub extern "C" fn FinalOnionHopData_set_total_msat(this_ptr: &mut FinalOnionHopData, mut val: u64) {
9974 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.total_msat = val;
9976 /// Constructs a new FinalOnionHopData given each field
9979 pub extern "C" fn FinalOnionHopData_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut total_msat_arg: u64) -> FinalOnionHopData {
9980 FinalOnionHopData { inner: ObjOps::heap_alloc(nativeFinalOnionHopData {
9981 payment_secret: ::lightning::ln::PaymentSecret(payment_secret_arg.data),
9982 total_msat: total_msat_arg,
9983 }), is_owned: true }
9985 impl Clone for FinalOnionHopData {
9986 fn clone(&self) -> Self {
9988 inner: if <*mut nativeFinalOnionHopData>::is_null(self.inner) { core::ptr::null_mut() } else {
9989 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9995 /// Used only if an object of this type is returned as a trait impl by a method
9996 pub(crate) extern "C" fn FinalOnionHopData_clone_void(this_ptr: *const c_void) -> *mut c_void {
9997 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFinalOnionHopData)).clone() })) as *mut c_void
10000 /// Creates a copy of the FinalOnionHopData
10001 pub extern "C" fn FinalOnionHopData_clone(orig: &FinalOnionHopData) -> FinalOnionHopData {
10004 mod fuzzy_internal_msgs {
10006 use alloc::str::FromStr;
10007 use alloc::string::String;
10008 use core::ffi::c_void;
10009 use core::convert::Infallible;
10010 use bitcoin::hashes::Hash;
10011 use crate::c_types::*;
10012 #[cfg(feature="no-std")]
10013 use alloc::{vec::Vec, boxed::Box};
10017 use lightning::ln::msgs::OnionPacket as nativeOnionPacketImport;
10018 pub(crate) type nativeOnionPacket = nativeOnionPacketImport;
10020 /// BOLT 4 onion packet including hop data for the next peer.
10023 pub struct OnionPacket {
10024 /// A pointer to the opaque Rust object.
10026 /// Nearly everywhere, inner must be non-null, however in places where
10027 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
10028 pub inner: *mut nativeOnionPacket,
10029 /// Indicates that this is the only struct which contains the same pointer.
10031 /// Rust functions which take ownership of an object provided via an argument require
10032 /// this to be true and invalidate the object pointed to by inner.
10033 pub is_owned: bool,
10036 impl Drop for OnionPacket {
10037 fn drop(&mut self) {
10038 if self.is_owned && !<*mut nativeOnionPacket>::is_null(self.inner) {
10039 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
10043 /// Frees any resources used by the OnionPacket, if is_owned is set and inner is non-NULL.
10045 pub extern "C" fn OnionPacket_free(this_obj: OnionPacket) { }
10047 /// Used only if an object of this type is returned as a trait impl by a method
10048 pub(crate) extern "C" fn OnionPacket_free_void(this_ptr: *mut c_void) {
10049 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionPacket) };
10053 pub(crate) fn get_native_ref(&self) -> &'static nativeOnionPacket {
10054 unsafe { &*ObjOps::untweak_ptr(self.inner) }
10056 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionPacket {
10057 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
10059 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
10060 pub(crate) fn take_inner(mut self) -> *mut nativeOnionPacket {
10061 assert!(self.is_owned);
10062 let ret = ObjOps::untweak_ptr(self.inner);
10063 self.inner = core::ptr::null_mut();
10067 /// BOLT 4 version number.
10069 pub extern "C" fn OnionPacket_get_version(this_ptr: &OnionPacket) -> u8 {
10070 let mut inner_val = &mut this_ptr.get_native_mut_ref().version;
10073 /// BOLT 4 version number.
10075 pub extern "C" fn OnionPacket_set_version(this_ptr: &mut OnionPacket, mut val: u8) {
10076 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val;
10078 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
10079 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
10080 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
10081 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
10084 /// Returns a copy of the field.
10086 pub extern "C" fn OnionPacket_get_public_key(this_ptr: &OnionPacket) -> crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ {
10087 let mut inner_val = this_ptr.get_native_mut_ref().public_key.clone();
10088 let mut local_inner_val = match inner_val { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
10091 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
10092 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
10093 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
10094 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
10097 pub extern "C" fn OnionPacket_set_public_key(this_ptr: &mut OnionPacket, mut val: crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ) {
10098 let mut local_val = match val.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut val.contents.result)) }).into_rust() }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut val.contents.err)) }).into_rust() })};
10099 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = local_val;
10101 /// HMAC to verify the integrity of hop_data.
10103 pub extern "C" fn OnionPacket_get_hmac(this_ptr: &OnionPacket) -> *const [u8; 32] {
10104 let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac;
10107 /// HMAC to verify the integrity of hop_data.
10109 pub extern "C" fn OnionPacket_set_hmac(this_ptr: &mut OnionPacket, mut val: crate::c_types::ThirtyTwoBytes) {
10110 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data;
10112 impl Clone for OnionPacket {
10113 fn clone(&self) -> Self {
10115 inner: if <*mut nativeOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else {
10116 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
10122 /// Used only if an object of this type is returned as a trait impl by a method
10123 pub(crate) extern "C" fn OnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void {
10124 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionPacket)).clone() })) as *mut c_void
10127 /// Creates a copy of the OnionPacket
10128 pub extern "C" fn OnionPacket_clone(orig: &OnionPacket) -> OnionPacket {
10131 /// Generates a non-cryptographic 64-bit hash of the OnionPacket.
10133 pub extern "C" fn OnionPacket_hash(o: &OnionPacket) -> u64 {
10134 if o.inner.is_null() { return 0; }
10135 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
10136 #[allow(deprecated)]
10137 let mut hasher = core::hash::SipHasher::new();
10138 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
10139 core::hash::Hasher::finish(&hasher)
10141 /// Checks if two OnionPackets contain equal inner contents.
10142 /// This ignores pointers and is_owned flags and looks at the values in fields.
10143 /// Two objects with NULL inner values will be considered "equal" here.
10145 pub extern "C" fn OnionPacket_eq(a: &OnionPacket, b: &OnionPacket) -> bool {
10146 if a.inner == b.inner { return true; }
10147 if a.inner.is_null() || b.inner.is_null() { return false; }
10148 if a.get_native_ref() == b.get_native_ref() { true } else { false }
10150 /// Get a string which allows debug introspection of a OnionPacket object
10151 pub extern "C" fn OnionPacket_debug_str_void(o: *const c_void) -> Str {
10152 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionPacket }).into()}
10154 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
10155 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
10156 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10159 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10160 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
10163 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
10164 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
10165 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10166 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10170 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
10171 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
10172 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10175 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10176 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
10179 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
10180 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
10181 let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10182 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10186 /// Serialize the Stfu object into a byte array which can be read by Stfu_read
10187 pub extern "C" fn Stfu_write(obj: &crate::lightning::ln::msgs::Stfu) -> crate::c_types::derived::CVec_u8Z {
10188 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10191 pub(crate) extern "C" fn Stfu_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10192 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStfu) })
10195 /// Read a Stfu from a byte array, created by Stfu_write
10196 pub extern "C" fn Stfu_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_StfuDecodeErrorZ {
10197 let res: Result<lightning::ln::msgs::Stfu, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10198 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Stfu { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10202 /// Serialize the Splice object into a byte array which can be read by Splice_read
10203 pub extern "C" fn Splice_write(obj: &crate::lightning::ln::msgs::Splice) -> crate::c_types::derived::CVec_u8Z {
10204 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10207 pub(crate) extern "C" fn Splice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10208 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSplice) })
10211 /// Read a Splice from a byte array, created by Splice_write
10212 pub extern "C" fn Splice_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceDecodeErrorZ {
10213 let res: Result<lightning::ln::msgs::Splice, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10214 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Splice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10218 /// Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read
10219 pub extern "C" fn SpliceAck_write(obj: &crate::lightning::ln::msgs::SpliceAck) -> crate::c_types::derived::CVec_u8Z {
10220 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10223 pub(crate) extern "C" fn SpliceAck_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10224 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceAck) })
10227 /// Read a SpliceAck from a byte array, created by SpliceAck_write
10228 pub extern "C" fn SpliceAck_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceAckDecodeErrorZ {
10229 let res: Result<lightning::ln::msgs::SpliceAck, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10230 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SpliceAck { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10234 /// Serialize the SpliceLocked object into a byte array which can be read by SpliceLocked_read
10235 pub extern "C" fn SpliceLocked_write(obj: &crate::lightning::ln::msgs::SpliceLocked) -> crate::c_types::derived::CVec_u8Z {
10236 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10239 pub(crate) extern "C" fn SpliceLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10240 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceLocked) })
10243 /// Read a SpliceLocked from a byte array, created by SpliceLocked_write
10244 pub extern "C" fn SpliceLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceLockedDecodeErrorZ {
10245 let res: Result<lightning::ln::msgs::SpliceLocked, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10246 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SpliceLocked { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10250 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
10251 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
10252 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10255 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10256 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
10259 /// Read a TxAddInput from a byte array, created by TxAddInput_write
10260 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
10261 let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10262 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10266 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
10267 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
10268 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10271 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10272 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
10275 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
10276 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
10277 let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10278 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10282 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
10283 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
10284 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10287 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10288 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
10291 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
10292 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
10293 let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10294 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10298 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
10299 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
10300 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10303 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10304 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
10307 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
10308 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
10309 let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10310 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10314 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
10315 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
10316 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10319 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10320 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
10323 /// Read a TxComplete from a byte array, created by TxComplete_write
10324 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
10325 let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10326 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10330 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
10331 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
10332 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10335 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10336 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
10339 /// Read a TxSignatures from a byte array, created by TxSignatures_write
10340 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
10341 let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10342 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10346 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
10347 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
10348 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10351 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10352 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
10355 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
10356 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
10357 let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10358 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10362 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
10363 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
10364 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10367 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10368 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
10371 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
10372 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
10373 let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10374 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10378 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
10379 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
10380 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10383 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10384 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
10387 /// Read a TxAbort from a byte array, created by TxAbort_write
10388 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
10389 let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10390 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10394 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
10395 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
10396 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10399 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10400 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
10403 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
10404 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
10405 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10406 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10410 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
10411 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
10412 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10415 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10416 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
10419 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
10420 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
10421 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10422 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10426 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
10427 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
10428 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10431 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10432 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
10435 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
10436 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
10437 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10438 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10442 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
10443 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
10444 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10447 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10448 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
10451 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
10452 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
10453 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10454 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10458 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
10459 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
10460 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10463 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10464 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
10467 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
10468 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
10469 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10470 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::CommitmentSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10474 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
10475 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
10476 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10479 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10480 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
10483 /// Read a FundingCreated from a byte array, created by FundingCreated_write
10484 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
10485 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10486 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10490 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
10491 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
10492 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10495 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10496 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
10499 /// Read a FundingSigned from a byte array, created by FundingSigned_write
10500 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
10501 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10502 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10506 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
10507 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
10508 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10511 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10512 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
10515 /// Read a ChannelReady from a byte array, created by ChannelReady_write
10516 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
10517 let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10518 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10522 /// Serialize the Init object into a byte array which can be read by Init_read
10523 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
10524 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10527 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10528 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
10531 /// Read a Init from a byte array, created by Init_write
10532 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
10533 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10534 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Init { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10538 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
10539 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
10540 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10543 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10544 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
10547 /// Read a OpenChannel from a byte array, created by OpenChannel_write
10548 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
10549 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10550 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10554 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
10555 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
10556 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10559 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10560 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
10563 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
10564 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
10565 let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10566 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10570 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
10571 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
10572 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10575 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10576 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
10579 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
10580 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
10581 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10582 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10586 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
10587 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
10588 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10591 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10592 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
10595 /// Read a Shutdown from a byte array, created by Shutdown_write
10596 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
10597 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10598 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10602 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
10603 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
10604 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10607 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10608 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
10611 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
10612 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
10613 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10614 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10618 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
10619 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
10620 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10623 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10624 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
10627 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
10628 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
10629 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10630 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10634 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
10635 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
10636 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10639 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10640 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
10643 /// Read a UpdateFee from a byte array, created by UpdateFee_write
10644 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
10645 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10646 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFee { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10650 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
10651 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
10652 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10655 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10656 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
10659 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
10660 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
10661 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10662 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10666 /// Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read
10667 pub extern "C" fn OnionPacket_write(obj: &crate::lightning::ln::msgs::OnionPacket) -> crate::c_types::derived::CVec_u8Z {
10668 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10671 pub(crate) extern "C" fn OnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10672 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionPacket) })
10675 /// Read a OnionPacket from a byte array, created by OnionPacket_write
10676 pub extern "C" fn OnionPacket_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionPacketDecodeErrorZ {
10677 let res: Result<lightning::ln::msgs::OnionPacket, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10678 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OnionPacket { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10682 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
10683 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
10684 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10687 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10688 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
10691 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
10692 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
10693 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10694 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10698 /// Read a OnionMessage from a byte array, created by OnionMessage_write
10699 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
10700 let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10701 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10705 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
10706 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
10707 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10710 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10711 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
10714 /// Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read
10715 pub extern "C" fn FinalOnionHopData_write(obj: &crate::lightning::ln::msgs::FinalOnionHopData) -> crate::c_types::derived::CVec_u8Z {
10716 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10719 pub(crate) extern "C" fn FinalOnionHopData_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10720 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFinalOnionHopData) })
10723 /// Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write
10724 pub extern "C" fn FinalOnionHopData_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FinalOnionHopDataDecodeErrorZ {
10725 let res: Result<lightning::ln::msgs::FinalOnionHopData, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10726 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FinalOnionHopData { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10730 /// Serialize the Ping object into a byte array which can be read by Ping_read
10731 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
10732 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10735 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10736 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
10739 /// Read a Ping from a byte array, created by Ping_write
10740 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
10741 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10742 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Ping { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10746 /// Serialize the Pong object into a byte array which can be read by Pong_read
10747 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
10748 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10751 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10752 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
10755 /// Read a Pong from a byte array, created by Pong_write
10756 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
10757 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10758 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Pong { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10762 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
10763 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10764 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10767 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10768 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
10771 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
10772 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
10773 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10774 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10778 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
10779 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10780 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10783 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10784 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
10787 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
10788 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
10789 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10790 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10794 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
10795 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10796 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10799 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10800 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
10803 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
10804 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
10805 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10806 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10810 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
10811 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10812 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10815 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10816 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
10819 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
10820 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
10821 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10822 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10826 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
10827 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
10828 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10831 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10832 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
10835 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
10836 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
10837 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10838 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10842 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
10843 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
10844 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10847 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10848 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
10851 /// Read a WarningMessage from a byte array, created by WarningMessage_write
10852 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
10853 let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10854 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10858 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
10859 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10860 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10863 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10864 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
10867 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
10868 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
10869 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10870 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10874 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
10875 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10876 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10879 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10880 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
10883 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
10884 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
10885 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10886 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10890 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
10891 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
10892 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10893 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10897 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
10898 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
10899 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10902 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10903 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
10906 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
10907 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
10908 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10911 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10912 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
10915 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
10916 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
10917 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10918 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10921 /// Calculates the overflow safe ending block height for the query.
10923 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
10926 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
10927 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
10932 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
10933 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
10934 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10937 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10938 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
10941 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
10942 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
10943 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10944 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10948 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
10949 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
10950 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10951 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10955 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
10956 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
10957 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10960 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10961 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
10964 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
10965 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
10966 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10969 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10970 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
10973 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
10974 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
10975 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10976 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };